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?
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?
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.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.
Beeides that: Thank you for the effort!
openToPage
code. If you clickzotero://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.)
that was the solution I was looking for! Thank you a lot for that!