diff --git a/chrome/content/zotero/xpcom/openPDF.js b/chrome/content/zotero/xpcom/openPDF.js index 9cf0551db..440cfbe13 100644 --- a/chrome/content/zotero/xpcom/openPDF.js +++ b/chrome/content/zotero/xpcom/openPDF.js @@ -34,6 +34,9 @@ Zotero.OpenPDF = { else if (handler.includes('Skim')) { this._openWithSkim(path, page); } + else if (handler.includes('PDF Expert')) { + this._openWithPDFExpert(path, page); + } else { // Try to detect default app handler = this._getPDFHandlerName(); @@ -41,6 +44,9 @@ Zotero.OpenPDF = { if (handler && handler == 'Skim') { this._openWithSkim(path, page); } + else if (handler && handler == 'PDF Expert') { + this._openWithPDFExpert(path, page); + } // Fall back to Preview else { this._openWithPreview(path, page); @@ -153,6 +159,18 @@ Zotero.OpenPDF = { await Zotero.Utilities.Internal.exec('/usr/bin/osascript', args); }, + _openWithPDFExpert: async function (filePath, page) { + await Zotero.Utilities.Internal.exec('/usr/bin/open', ['-a', 'PDF Expert', filePath]); + // Go to page using AppleScript (same as Preview) + let args = [ + '-e', 'tell app "PDF Expert" to activate', + '-e', 'tell app "System Events" to keystroke "g" using {option down, command down}', + '-e', `tell app "System Events" to keystroke "${page}"`, + '-e', 'tell app "System Events" to keystroke return' + ]; + await Zotero.Utilities.Internal.exec('/usr/bin/osascript', args); + }, + // // Windows //