Sumatra PDF is a PDF, ePub, MOBI, CHM, XPS, DjVu, CBZ, CBR reader for Windows

Making SumatraPDF accept page-numbers from Zotero

In Zotero, if the source PDF has a TOC, I get an option to open the PDF directly to the section by clicking the following link:

Zotero_TOC_Link

In its raw format, Zotero parsed the TOC into zotero://open-pdf/0_VWWUW7AT/332

Also, documentations for commands in Stata, as I may recall, also have its PDF_links that jump to the proper section in the linked PDF.

If I was setting Sumatra as the default PDF reader (for filetype .pdf), three Sumatra window will pop up, with first two being blank (gray) windows and the third being the file on its first page.


May I get a simple answer, of whether Sumatra can handle these PDF_links?

I am not surprised that Adobe Acrobat can open these links when set as the default program for .pdf files. Surprisingly, Xchange PDF Viewer (the old version) is also able to handle such “PDF_links”.


Thanks a lot!

All the best,

-Linfeng

ToC entries are generally called the document “outline” but many people call them “bookmarks”

They are a collection of “named destinations”

When calling SumatraPDF via an external command you can specify them or a page label like this

SumatraPDF.exe -named-dest “my bookmark” “filename.pdf”

also you can set page (and others like zoom)

SumatraPDF.exe -page 24 “filename.pdf”

this is slightly different syntax to acrobat but the result should be similar

I dont know how Zotero applies the commands for different apps but it should be possible to make it function the same way, if it is not adjustable then you need to raise a support question with them. One technique that may be required is an intermediate “shim” that is you tell Zotero to use a dummy application called say acro2sumatra.cmd which translates the commands from Acrobat format to SumatraPDF format.

There are various ways to combine SumatraPDF and Zotero as discussed in https://forums.zotero.org/discussion/comment/334930/#Comment_334930

Many comments at https://forums.zotero.org/search/?Search=sumatrapdf suggest there is no highlight but if you use the pre-release version then although highlight is still going through changes it should be stable enough.

This was made more complicated by the fact that it is a combination of Zotero and a plugin called Zotfiles

I used a portable copy for testing and found that I needed to make a couple of changes as described above I found it easiest to add an acro2sumatra.cmd file into the SumatraPDF folder (but it does not really matter where it is located)

my acro2sumatra.cmd file was one line

start "" "c:\program files\sumatrapdf\sumatrapdf.exe" -reuse-instance -%2 %3 %4

and in Zotero i simply told it to use that file

image

It would be simpler if zotfiles can be modified to provide the correct method as my “shim” is a workaround for the method that it uses to call acrobat

1 Like

Fantastic! I can now keep the global PDF viewer as Sumatra, and use Xchange PDFViewer for annotating files through Zotero.

Thank you for the helpful pointer to the post on the Zotero forum. Indeed, there is an option to specify which PDF viewer/editor to use specifically for Zotero. Here is my current setting:


Just saw your recent post about appointing the acro2sumatra.cmd script as the “pdf viewer” for Zotero. Will check it out and update :slight_smile:

You will also find a technique in this forum to integrate xchange with sumatrapdf so the pages can be viewed via cross links between the two bypassing zotfiles when it may prove quicker see Use sumatra as external viewer

One more thing about running acro2sumatra.cmd. In my Zotero with version 5.0.85, it did not like the file extension .cmd. How did you set yours?

image

Using “Custom” navigate to the folder where you stored it and just type part of the name it should find the full name
image

Just learned another Windows trick!

I appointed the script with the following content. Though, when clicking on the “link”, a dark window flashes (I guess it is a command window) and nothing happened.

start "" "C:/Program Files (x86)/SumatraPDF/SumatraPDF.exe" -reuse-instance -%2 %3 %4

Running "C:/Program Files (x86)/SumatraPDF/SumatraPDF.exe" through the command prompt did open Sumatra.


Also, thank you for pointing me to this solution that can get Xchange Viewer to open up the current page as displayed in Sumatra! Learning too much good things on a Friday night :slight_smile:

The black window is the result of using the .cmd file in a background window and ideally if zotfiles did it directly or the cmd was a .exe or .com file that would not happen. (I tried a bat to exe converter, which can run “hidden” or minimized so as to avoid that brief flash, however it adds complexity and delay that for a single user is not worth the trouble, but can be useful in a multi-user setting to avoid suspicion that something else is happening :slight_smile:)

If you click on the cmd file it should only see the - before %2 and then it will open like this which confirms most of the line is respected

image

zotfiles adds the second third and fourth parameters as page # "filename"

Syntax can be troublesome in some cases note that I used \ rather than / and in some systems it can look like the yen symbol. "Double quotes" can also cause problems in some languages and should be simple one key producing a pair of uprights.