Skip to content

Commit

Permalink
Merge pull request #17 from TCPsoftware/master
Browse files Browse the repository at this point in the history
Fix @ pdf parameter handling in complex cases
  • Loading branch information
retorquere authored Jan 17, 2025
2 parents b7cd70d + f1e9ca0 commit 38d8761
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Open Pdf
Open PDF
=================

Install by downloading the [latest version](https://github.com/retorquere/zotero-open-pdf/releases/latest). Compatible with Zotero 6 and 7.
Expand All @@ -23,7 +23,13 @@ which would add an option `Open with preview` to the menu. You can set your own

If the path to the executable contains spaces, you need to enclose it in quotes, eg to use edge on windows as a PDF viewer:

`extensions.zotero.open-pdf.with.edge` = `"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" -a @pdf`
`extensions.zotero.open-pdf.with.edge` = `"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" @pdf`

A more complex example is that you can also open PDF files through extensions in Chrome, such as the Acrobat extension:

`extensions.zotero.open-pdf.with.chrome-acrobat` = `"C:\Program Files\Google\Chrome\Application\chrome.exe" "chrome-extension://efaidnbmnnnibpcajpcglclefindmkaj/file:///@pdf"`

"efaidnbmnnnibpcajpcglclefindmkaj" is the ID of the Acrobat extension. To enable the extension to read the file:/// protocol, you need to turn on "Allow access to file URLs" on the "Manage Extensions" page.

The plugin does not search the system PATH, you need to enter the full path to the executable.

Expand Down
2 changes: 1 addition & 1 deletion lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ Zotero.AltOpenPDF = Zotero.AltOpenPDF || new class ZoteroAltOpenPDF {
for (const item of items) {
const attachment = item.isAttachment() ? item : (await item.getBestAttachment())
if (attachment?.attachmentPath.match(/[.]pdf$/i)) {
exec(cmd, args.map((arg : string) => arg.toLowerCase() === '@pdf' ? attachment.getFilePath() as string : arg))
exec(cmd, args.map((arg : string) => arg.toLowerCase().includes('@pdf') ? arg.toLowerCase().replace('@pdf', attachment.getFilePath() as string) : arg))
}
}
}
Expand Down

0 comments on commit 38d8761

Please sign in to comment.