I'm specifically curious about Windows, but answers about different OS are interesting too.
Afaik in URLs a specific PDF page can be indicated by adding a #page=<page number>
field. According to the URI specification, fields (using the #<field>
syntax) and queries (using the ?<key>=<value>
syntax) should be possible. However, URIs of the form file:///path_to_document.pdf#page=20
or file:///path_to_document.pdf?page=20
didn't work for me, Windows is interpreting the whole string as a path, which it then can't find.
Is there any way to accomplish this? I couldn't find anything online.
When calling files from the Operating System there are rules that are system based. So calling a file from OS needs a certain syntax, that needs quoting for some characters, so these work, whatever the default PDF handler may be:-
That default handler may include a different page switch syntax such as exe -page ## filename.
When using a URL you need a URL handler, so this will work in Windows
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" "file:///C:/Apps/PDF/poppler/%2333.pdf#page=20"
The URL can be on a LAN server and windows will often fiddle with the usage of \ and / but not aways accept both. So the rule is "use quotes" AND replace system punctuation with safe characters AND ensure "Remember last page" is not active.
The use of #
fragments for PDF navigation was introduced by Adobe for their Acrobat plug-in and has in parts been adopted by some browser plug-ins . So some work one way in Chrome but some can be different name or behaviour in FireFox, so beware which browser you use as default.
One example is #search=
works well in FireFox but is totally different in Chromium. #:~:text=Chromium but does not work with PDF nor this page !
In comments you mentioned Obsidian which is a closed product (not open source for easy modifications). What I found is it need an object per link thus in the vault you would need to use a window.lnk file as the shim from internal to external calling
in the vault it would be
Open 3pages.pdf @ page 2 [page 2 of 3Pages.pdf](file:///C:%5CApps%5CPIM%5CObsidian%5C3Pages.pdf%20-%20Shortcut.lnk)
externally the shortcut could be
"C:\Program Files\SumatraPDF\SumatraPDF.exe" -page 2 C:\Apps\PIM\Obsidian\vault\3Pages.pdf
As I tested this workaround each link would be a highly wasteful 4Kb of disk space, so there are perhaps better ways to call 1 file with 2 arguments, which works in many cases as a "Shim", however there are open source plug-ins that are perhaps close enough to adapt see https://github.com/MichalBures/obsidian-file-path-to-uri