Zotero 6.0.7: "Viewing an Annotation in Context" not using page number under Linux

edited May 12, 2022
Dear All,

I am using Zotero under Linux, and I use external pdf readers (Emacs with pdf-tools, okular), to open and annotate my pdfs. Things work fine when opening the PDFs. But, when using "Add Note from Annotations" and then "Show on Page" the PDF is always opened in the first page; this is the case both for annotations that were originally made with external tools (emacs, okular, pdf editors in android tablet, etc) or made with Zotero's new PDF editor.

By forcing the xdg-open script to show me how it is being called, it seems that on clicking on "Show on Page", only the filename (not the page number) is being passed to the underlying program.

But it is my understanding from https://www.zotero.org/support/pdf_reader#viewing_an_annotation_in_contextthat and a forum thread (https://forums.zotero.org/discussion/96449/citation-links-opening-in-a-different-pdf-reader)
that page numbers should work with external readers.

Interestingly, if I export the annotations (from Zotero 6) as Markdown, I can see the page number (and it is correct). And if I use the default PDF editor things work OK (with Annotations made with both Zotero or external readers).

This happens in all the PDFs I've tried, so I guess I am misunderstanding something. (I am using version 6.0.7 of Zotero).
  • Can you provide a Debug ID for this?

    Do you have Zotero set to open PDFs in the System Default, or have you selected a reader explicitly in the preferences?

    Evince and Okular should work. If it's just using xdg-open it won't work.
  • edited May 12, 2022
    Degug ID: I've sent three Debug ID's:

    - D2001455355: opening PDFs using "custom" and then selecting /usr/bin/okular

    - D497154655: opening PDFs using "custom" and then selecting /usr/bin/evince

    - D790832732: opening PDFs with "System Default", where System Default is org.kde.okular.desktop (so this goes through xdg-open).

    -----------

    "Do you have Zotero set to open PDFs in the System Default, or have you selected a reader explicitly in the preferences?"
    I've tried both ways.

    -----------

    "using xdg-open it won't work." So this means using Emacs' pdf-tools will not work? If I use "custom" and call a script that takes arguments (page number, file name) in the right order, shouldn't it work? (I tried intercepting the call to xdg-open to try to figure out the way the arguments were passed, precisely to call a custom script).

    I'd had assumed that the call would be:
    name_of_program -p page_number file_name_with_full_path
  • OK, that's a bug. It's not using the correct code to open to a specific page when launched that way. We'll fix — thanks.
    So this means using Emacs' pdf-tools will not work?
    Correct. But we can add support for other standard tools that have command-line arguments for opening a specific page.

    https://github.com/zotero/zotero/blob/a11c5987adea5e7187685226a32a31f4934f7d5c/chrome/content/zotero/xpcom/openPDF.js#L95-L120

    https://github.com/zotero/zotero/blob/a11c5987adea5e7187685226a32a31f4934f7d5c/chrome/content/zotero/xpcom/openPDF.js#L326-L352
  • Thanks a lot for your reply and for looking into it.

    Seeing the code, I guess I could hack a solution to suit my needs, since the call is "/usr/bin/evince [or okular] -p page filePath". For example, have /usr/bin/evince (or an evince elsewhere, and before, in $PATH) call a custom script like

    ##############################
    #!/bin/bash
    FILEPAGE=$3::$2

    /usr/bin/emacsclient --create-frame --alternate-editor "" --eval "(progn (org-pdftools-open \"$FILEPAGE\") (delete-other-windows) (pdf-view-fit-page-to-window))" > /dev/null
    ##############################

    This is an ugly kludge, but I think my use case is limited to so few people that more generic mechanisms (like allowing for a generic pdf handler, in
    if (handler && (handler.includes('evince') || handler.includes('okular')))
    that the interested user then writes as needed) are not worth it.
Sign In or Register to comment.