Is it possible to use .desktop files to open local pdf files on specific pages with a browser?

Use url?

I need to look it up, but I seem to remember Type Link is deprecated in a .desktop file. Anyway, it won't work here as you found out. Encoding is deprecated for sure, but that isn't the issue. Furthermore, xdg-open won't work; it will open your default application for pdf files.

Then what to use?

Create a .desktop file, calling your preferred browser with the pdf file + page as argument. In your example:

[Desktop Entry]
Type=Application
Name=Open pdf on page 45
Exec=firefox 'file:///home/myhomefolder/mypdf.pdf#page=45'
Icon=application-pdf

enter image description here

Then make it executable and double-click. If you are using another browser, you need to change the Exec= -line to reflect that.


Some document viewers allow you to start them with an argument pointing to the desired page.

From evince --help:

  -i, --page-index=NUMBER     The page number of the document to display.

Therefore, your .desktop file could look like this:

[Desktop Entry]
Name=mypdf.pdf page 45
Type=Link
Exec=evince --page-index=45 /home/myhomefolder/mypdf.pdf
Icon=application-pdf

Tags:

Pdf

.Desktop