commit e6dbd1ed92213b1f190b4a5de1fb3d06df1b404e
parent 5a85d1ac9eff4e7cd1b1436f285f01f6c3214846
Author: Dan Stillman <dstillman@zotero.org>
Date: Sun, 6 May 2018 14:07:23 -0400
Add PDF Expert support to zotero://open-pdf
Requested here: https://github.com/jlegewie/zotfile/issues/352#issuecomment-386896327
Diffstat:
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git 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
//