Below is a working example of how to create (1) a simple AppleScript application that registers a custom URL scheme, and (2) links that open a given PDF at a given page in Skim.
────────────────────────────────────────────────────────
- Create the AppleScript ────────────────────────────────────────────────────────
- Open “Script Editor” (in /Applications/Utilities).
- Create a new document and paste this script:
-- This handler is called when a URL with the scheme "skimpdf://" is opened. -- Example URL: skimpdf:///Users/yourUser/Desktop/paper.pdf?page=5
on open location theURL try (* theURL is something like: "skimpdf:///Users/yourUser/Desktop/paper.pdf?page=5" *)
-- Strip off the "skimpdf://" prefix
set AppleScript's text item delimiters to "skimpdf://"
set pathAndParams to text item 2 of theURL
-- Separate path from the "?page=" parameter
set AppleScript's text item delimiters to "?page="
set pdfPath to text item 1 of pathAndParams
set pageNumber to text item 2 of pathAndParams
-- Open file in Skim, go to that page
tell application "Skim"
activate
open POSIX file pdfPath
tell document 1
go to page (pageNumber as integer)
end tell
end tell
on error errMsg
display dialog "Error: " & errMsg
end try
- In Script Editor’s menu, choose File → Export…
• File Format: “Application”
• Give it a name (e.g., “SkimPDFOpener”) and save it somewhere convenient.
──────────────────────────────────────────────────────── 2. Configure the Info.plist to register "skimpdf" scheme ────────────────────────────────────────────────────────
- In Finder, right-click your newly saved application, and choose “Show Package Contents.”
- Go into the “Contents” folder and open “Info.plist” in a text editor (TextEdit or Xcode).
- Inside the main … , add:
- Save Info.plist.
- (Re)launch your AppleScript application by double-clicking it, so macOS registers the new scheme.
────────────────────────────────────────────────────────
3. Test it
────────────────────────────────────────────────────────
• Construct a URL in the form:
skimpdf:///absolute/path/to/file.pdf?page=NN
Example:
skimpdf:///Users/yourUser/Desktop/2310.01798v2.pdf?page=1
• Open that URL (for instance, in Safari, Terminal with “open 'skimpdf:///…'”, or a Markdown link).
• macOS should launch your script, which in turn launches Skim, opens the PDF, and jumps to the specified page.
────────────────────────────────────────────────────────
Notes / Tips
────────────────────────────────────────────────────────
• The path in the URL must be a valid absolute POSIX path. If your PDF filename has spaces or special characters, you’ll need to URL-encode them (e.g., “%20” for spaces).
• Only Skim is directly supported here because it has AppleScript support. Preview in macOS does not offer an official URL scheme or AppleScript command to jump to specific pages.
• If nothing happens, ensure that:
- Your AppleScript app is running once to register its scheme.
- The Info.plist is edited correctly and saved.
- Your path does indeed exist, and page numbers are valid.
With that in place, you can embed these custom links (like “skimpdf:///path/to/file.pdf?page=5”) in your Markdown or other documents. Clicking them will open Skim directly at the specified page.