From 82eb701ea75542b2266921b2de86cd88f13af43a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 15 May 2022 04:16:27 -0400 Subject: [PATCH] Try to open external PDF reader to page number for "Show on Page" PDF-handling code from `ZoteroPane.viewAttachment()` predates `Zotero.OpenPDF` and didn't handle page numbers for external PDF readers, so when called from "Show on Page" in a note (via `ZoteroPane.viewPDF()`) it just launched the file itself in the specified handler or via the OS. For now, change to use `Zotero.OpenPDF.openToPage()` when there's a page number. Later we should use `Zotero.OpenPDF` for everything, but that code is more complicated than just using `launchFile()`, so we'll need to do some testing (particularly on Linux) to see what's best. (Note that "Show on Page" with an external reader doesn't make a ton of sense, since you can't actually see the annotation, but opening the right page is better than nothing.) Fixes #2612 --- chrome/content/zotero/zoteroPane.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index b75bddd600..76361944bd 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -4273,7 +4273,19 @@ var ZoteroPane = new function() ); return; } + // Try to open external reader to page number if specified + else { + let pageIndex = extraData?.location?.position?.pageIndex; + if (pageIndex !== undefined) { + await Zotero.OpenPDF.openToPage( + item, + parseInt(pageIndex) + 1 + ); + return; + } + } // Custom PDF handler + // TODO: Remove this and unify with Zotero.OpenPDF if (pdfHandler != 'system') { try { if (await OS.File.exists(pdfHandler)) {