Add PDF Expert support to zotero://open-pdf

Requested here: https://github.com/jlegewie/zotfile/issues/352#issuecomment-386896327
This commit is contained in:
Dan Stillman 2018-05-06 14:07:23 -04:00
parent 5a85d1ac9e
commit e6dbd1ed92

View File

@ -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
//