PDF Links Opening Wrong PDF Viewer

Hello -

Links to bookmarks (and presumably annotations also) in PDF files are opening the PDFs in the wrong viewer. I have both Zotero and Mac system default preferences set to open in Acrobat. However, these links (generated from Zotfile's "Get Table of Contents"; presumably those generated from "Extract Annotations" will suffer the same problem) open the PDF in Mac Preview instead.

Meanwhile, regular PDF attachments do open in the proper set viewer (Acrobat, in my case).

Any advice appreciated.
Other thread on this: https://forums.zotero.org/discussion/comment/353825
https://forums.zotero.org/discussion/comment/354579#Comment_354579

Debug Id: D1181675234

Thank you for any advice on this.

Best,
ZM
  • Hi ZenonMarko,

    Thank you for doing the grunt work of testing. I wanted to do it as well but I had my hands full with a scholarship application.

    I'm done with that now, so, to all the devs, if you want me to do further testing, please let me know.

    All the best,
    João
  • So this might be considered a bug, but it's not totally straightforward.

    We can only open PDFs to specific pages in certain programs. On macOS, we currently support Preview, Skim, and PDF Expert, and as far as I know there's no way to open a PDF to a specific page in Acrobat on a Mac. Since zotero://open-pdf links exist pretty much specifically to open a page at a given PDF, simply opening a PDF in the configured program even if we can't open it to the specified page isn't necessarily helpful or desired. It's possible that opening to a specific page in Preview is better than just opening the PDF in Acrobat (which you can do just by double-clicking on the attachment).

    For what it's worth, on Windows, it looks like we do currently open via the custom handler regardless of whether it's supported (since the way it's implemented we just include the two possible command-line flags we know about when calling the handler).
  • For Acrobat on macOS, the "go to page" keyboard shortcut should be Cmd+Shift+N. (On Windows it's Ctrl+Shift+N.) If this is the case, it could be worth trying to use the AppleScript currently used for Preview (here), but with keystroke "n" using {option down, command down}. At least in the past this might have worked, see here. (According to this site, "Enable access for assistive devices" should be enabled in the "Universal Access" pane of the System Preferences.) For Acrobat Pro, there might also be a "dictionary" solution, see https://stackoverflow.com/a/12921817. But the GUI scripting option might work for both Acrobat Reader and Pro.

    (I don't have a Mac to test this. It's odd that Mac doesn't seem to support command-line options for this.)
  • Hello, all -

    I thought to go back and forth between Preview and Acrobat then as needed, annotating in either program, whichever happens to open from Zotero (clicking a PDF item directly opens Acrobat, double-clicking a chapter/section link opens Preview)... Since annotations in PDF are supposedly standardized and should carry over properly between programs. This used to work fine as I recall from years ago.

    However, I am experiencing erratic behavior with this solution (Mac with latest Mojave updates, latest Preview and Acrobat Pro DC). For any sections of text with highlighting done in Acrobat, Preview will add a blank annotation box. This leads to a text littered with empty annotation boxes.

    Also a quick web search shows many experiences of lost annotations and other document corruptions with recent versions of Preview. So it looks like I have to stay away from Preview....

    If anyone has had better luck working with Preview, or between Acrobat and Preview, please advise (not exactly a Zotero-specific question, but I hope this is acceptable here as it is relevant to many Zotero users).

    Thank you...

    Best regards,
    ZM
  • it could be worth trying to use the AppleScript currently used for Preview […], but with keystroke "n" using {option down, command down}
    @qqbb: Thanks — I've implemented this in the latest Zotero beta. Tested with Acrobat Acrobat Reader, and it hopefully will work with the non-Reader versions as well.
  • @dstillman Thank for your this! Zotero is now opening the PDFs for book sections in Acrobat! That's wonderful.

    However: Some of my saved book section links work properly, in that the open to the correct page; others do not.

    It seems that some of the page number references in the open-pdf URI are interpreted as leading to the book's published page numbers; others are interpreted as leading to the actual page number of the PDF document. Those can vary, of course, due the existence of un-numbered front matter, Roman-numeral or other numbered introductions and prefaces, and so on.

    Apparently this is because Adobe Acrobat differentiates "logical" from "printed page numbers". Some documents will show both sets at the top, so one can see the page number as "693 (720 of 938)". So those PDFs of mine which only have a single set of page numbers work properly (i.e. the open-pdf goes to the correct page); those with 2 sets of page numbering do not.

    This seems to depend on what Adobe calls "logical page numbering". Preview did not work this way and all opened based on the page number within the PDF.

    By turning off Adobe's Preference:Page Display:use logical page numbers, my old links work. I assumed "Logical Page Number" is the book's page numbering, but the picture here seems to indicate it's the PDF's page numbering:
    https://helpx.adobe.com/acrobat/11/using/manipulating-deleting-renumbering-pdf-pages.html#renumber_pages

    Did Adobe mis-label that image? Isn't the upper example (i, ii, 1, 2, 3, 4...) what one should call the "logical page numbering? The image instead calls the lower example (1, 2, 3,4) the "logical page numbering". Yet the preference checkbox turns on/off the upper type (i,ii,1,2,3,4).

    Else I am really confused, more than usual, in a migraine state.

    What's best practice here when creating open-pdf links, and how should I then have Adobe's preferences set? Thank you for any guidance.
  • edited May 17, 2020
    @ZenonMarko: As you already noted, you need to switch off the "use logical page numbers" setting. That's a limitation of the current solution. Currently, Zotero is using Acrobat's "go to page" keyboard shortcut, "Cmd+Shift+N", through GUI scripting. For this shortcut, Acrobat uses actual page numbers or page labels depending on the "use logical page numbers" setting.

    For Acrobat Pro, it could be possible to always use the actual page numbers ("dictionary" solution above), but it seems that this option is not available for Acrobat Reader. (It might be worth trying to use the "dictionary" AppleScript with Acrobat Reader to confirm this is still the case today. The links above are from 2012.)
    Did Adobe mis-label that image?
    I think you are right that the caption is mixed up. The correct technical terms should be "page" and "page label" (see here). To add to the confusion, there are also "named destinations" which Acrobat can call from the command-line (see here), but as far as I know Acrobat can't open page labels from the command-line. More recent versions of pdf.js, however, should have this option, see https://github.com/jlegewie/zotfile/issues/190.
  • @qqbb Thank you for all this explanation.

    So the current solution can't work with "use logical page numbers"?
    Or one has the option to either "use logical page numbers" in Acrobat, or not?

    (Of course, it seems that whichever way one chooses, one must commit to it, since one will then set the open-pdf URIs accordingly, and switching the setting later in Acrobat will then send the URIs to the wrong page, at least in PDFs with the 2 sets of page numbers).

    If one can go either of the two ways, then I am wondering which is the smarter one to adopt (since, again, if I understand correctly, it would be a rather permanent commitment as one goes forward creating URIs).
Sign In or Register to comment.