Zotfile change absolute page number in link

Although there are some related Discussions I can not figure out how to edit the extracted link of annotations. My goal is that the page number in the open-pdf link skips the introduction pages with and jumps directly to the right position. Currently an example would be this extraction: [Hoffmann und Engelkamp, 2013, p. 6](zotero://select/library/items/TENSI7B3)) ([pdf](zotero://open-pdf/library/items/5RTYM25B?page=22&annotation=LAXL52J3)). Although it includes the right pages (p. 6) In the citation it includes the content in the link (page=22). Is there a workaround for this?
  • That doesn't have anything to do with ZotFile — ZotFile doesn't extract annotations anymore.

    But it sounds like the annotation's page label is set to 6 here, and it's page 22 of the actual PDF. The link (22) should take you back to the PDF page where you added the annotation.

    If you're seeing something different, can you say more?
  • Thanks for the information about ZotFile, I didn't know. The problem I guess is that my PDF Editors all use the "go to page" functionality with the relative page (6) and not the absolute page (22). So instead of going to page 22, I am landing on page 40. That is why I was wondering if there is a possibility to use the 6 automatically in the link.
  • I'm not sure what you mean here. If you're clicking a link with page=22, it's going to go to take you to the 22nd page of the PDF. "p. 6" is just text in the citation.
  • Hm - Theoretically you are right. But my PDF Editor - PDF Expert on Mac does not have the option to include the introduction pages in its "go to page" function. So it jumps to page 22 starting from the actual content.
    Maybe these two links help you understand my problem:
    https://support.apple.com/guide/preview/if-go-to-page-shows-the-wrong-page-of-a-pdf-prvw18524/mac
    - This option in Preview sadly doesn't exist in PDF Expert so I am trying to solve it from the Zotero side

    https://forums-zotero-org.translate.goog/discussion/68632/zotfile-extract-annotations-and-getting-the-right-page-number?_x_tr_sl=en&_x_tr_tl=de&_x_tr_hl=de&_x_tr_pto=op,sc - The described Methods here are unortunately not helping me.

  • No, I still don’t know what you mean. Can you provide a link to a PDF — or email it to support@zotero.org with a link to this thread — and provide the exact steps in Zotero to reproduce the problem you’re describing?
  • I tried to demonstrate my problem with a video. You can see it here. (https://drive.google.com/file/d/1hF5y_NVXJXbB2JI7zFrHswGxwkEJKjGs/view?usp=sharing). I could not find an open source PDF to show that. Due to the introduction pages with the romic letters (IV, V, VI etc.) my PDF Editor PDF Expert skips them when going to a specific page over the link.

    Beeides that: Thank you for the effort!
  • @dstillman: I think the issue arises on macOS with an external PDF viewer which is called using AppleScript in Zotero's openToPage code. If you click zotero://open-pdf/library/items/5RTYM25B?page=22 to open the "physical" page 22 which corresponds to the "logical" page 1, Zotero calls page 22 but PDF Expert expects page 1.

    It seems that there's a workaround for Acrobat (here) and Preview (here), which provide a "Use logical page numbers" option that can be switched off. But this might not be possible in PDF Expert.

    A solution could be to replace this code with something like the following:
    _openWithPDFExpert: async function (appPath, filePath, page) {
    await Zotero.Utilities.Internal.exec('/usr/bin/open', ['-a', appPath, filePath]);
    let pageNumber;
    // New Boolean preference to call viewer with logical page numbers
    if (Zotero.Prefs.get('useLogicalPageNumbersInExternalViewer')) {
    pageNumber = Zotero.getLogicalPageNumber(page);
    } else {
    pageNumber = page;
    }
    // Go to page using AppleScript (same as Preview)
    let args = [
    '-e', `tell app "${appPath}" to activate`,
    '-e', 'tell app "System Events" to keystroke "g" using {option down, command down}',
    '-e', `tell app "System Events" to keystroke "${pageNumber}"`,
    '-e', 'tell app "System Events" to keystroke return'
    ];
    await Zotero.Utilities.Internal.exec('/usr/bin/osascript', args);
    },


    The function getLogicalPageNumber should check whether page labels are defined in the PDF file itself or in Zotero's PDF reader. This modification could also be applied to the Acrobat and Preview handlers on macOS.

    (Note that "page" in the PDF specification always refers to the "physical" page. You can define a "dictionary" that maps "page" to a "page label", which is sometimes referred to as a "logical" page. In principle, you could have multiple pages with the same page label, but in normal usage that's not the case.)
  • Hey,

    that was the solution I was looking for! Thank you a lot for that!
Sign In or Register to comment.