I'd like to use desktop files
to open pdf files on specific pages, I've tried creating a file with the following syntax:
[Desktop Entry]
Encoding=UTF-8
Name=mypdf.pdf
Type=Link
URL=file:///home/myhomefolder/mypdf.pdf#page=45
Icon=application-pdf
When I open this file the default browser opens my pdf file on page 1, it's like it considers #page=45
as a comment, even though if I paste the address file:///home/myhomefolder/mypdf.pdf#page=45
directly on the browser I get the expected result (the pdf opens on page 45)...
I realized that if I use this syntax for pdf files on the internet it works as expected and it opens the pdf on the page that I've predetermined, the problem is only with local files. Is it possible to use desktop files to open local pdf files on specific pages? Or is it a limitation of desktop files
?
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:
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
:Therefore, your .desktop file could look like this: