PDF reader and zotero://open-pdf links

This discussion was created from comments split from: Create external link to open pdf within Zotero.
  • Are "open-pdf" links only supposed to work within Zotero now? For PDF files with bookmarks, in Zotero, I can find the following link when I select the PDF attachment. Within Zotero, if I click on the hyperlink text, Zotero shall open a PDF file with the correct page number.

    Yet, now on Windows 10, with its "Run" window, executing the "link" does nothing.

    It seems to me that the Windows OS has no problem parsing the zotero:// protocol. The "zotero://select/item" schema is still working. For an arbitrary entry in Zotero, I can still switch to the entry with "zotero://select/items/[item ID]", where [item ID] is the citation key.
  • Are you using the Zotero beta? If so, do you have the PDF reader enabled? Where are you expecting the PDFs to open? Can you provide a Debug ID for trying this?

    zotero://open-pdf links work fine for me from the Run window with the Zotero beta, but with and without the built-in PDF reader enabled.
    (Note that, while this should work, it's not the current recommended format and hasn't been for several years. This would be zotero://open-pdf/library/items/9WYPFUSR?page=9.)
  • Is there a native(No additional plug-ins are required) UI operation that can get the zotero://open-pdf/library/items... link of a pdf attachment?
    And are links similar to the above format uniformly included in official documents, or do they only exist in different forum posts?
    PS:zotero version:
  • edited March 9, 2022
    @crawlingsnail: Markdown export of annotations in Zotero 6 (the current beta) includes zotero://select and zotero://open-pdf links. There's no other way to generate those without using a third-party plugin like Zutilo (though for stored attachments you can form it using the attachment item key, which is the name of the folder containing the attachment file).
  • The zotero://open-pdf doesn't do anything for me on Zotero 6.0.2 either, nor has it worked on previous versions. It just makes Zotero active. I'd also prefer that I could call open-pdf on a web page (HTML) and have it just open in the web browser that way, but I don't know if that is how it already works.
  • Upon further experimentation, the links work if I export them using Zotero 6's new method with annotations and page numbers. But I cannot generate the same link on my own, as the item ID is incorrect if I do it this way (with, for example, BetterBibTex quick copy option for Zotero select link). I'm not sure if itemID == key in JavaScript, but the itemID is incorrect if getting it from an export translator vs getting it directly from annotations.
  • You'd have to report that to the plugin developer.

    (An itemID is a DB-local identifier that shouldn't be used anywhere outside the database. zotero:// URIs use item keys.)
  • Thanks for the clarification. However, this might apply outside of plugins - I've adapted a custom translator written in Javascript for quick-copying a markdown link to the pdf via open-pdf endpoint and it uses Zotero.nextItem().key for the unique identifier at the end of the URI, but even that 'key' attribute returns a different identifier vs. the identifier provided from exporting Markdown annotation notes from Zotero 6 itself. Is that 'key' attribute also the wrong one, and I should be using something else?
  • Note that PDFs and the parent items to which they are attached are different items with different item keys. Going by your description, I'm guessing that you're getting item keys for the top level item which won't open the PDF (since, e.g., a single item can have multiple PDF attachments).
  • Ah I see, thanks so much. I'll figure out how to get the PDF item itself in the exporter and see if that solves it.
  • edited March 28, 2022
    As I mentioned on GitHub, we could consider having zotero://open-pdf on a parent item perform the equivalent of double-clicking — i.e., automatically choosing the best attachment — but I'm not sure if there's much reason to do that (and it's a little weird to have a URL with a page number for a specific file apply to something indirect like that).
  • That would honestly be nice, but I see your point.. Can zotero://open-pdf open non-pdfs, such as web archive html pages saved with the connector extension in the default browser? With those I know there aren't page numbers or annotations anyway, but it would be really nice to be able to still have a quick way to open arbitrary documents that Zotero manages with a permanent zotero link.

    Also, let's say you have one item with an outdated pdf attachment and replace the pdf with a newer version later, yet want to keep the original item attributes since they mainly stay the same. I'd imagine the parent item's key remains the same, but would each pdf's key change since they are different? If so I'd prefer to have a single permanent link that opens the item's best attachment (however that is achieved) regardless of the pdf I currently associate with that parent item.

    I feel like the benefits of having zotero://open-pdf automatically choose the best attachment as opposed to doing nothing outweigh the weirdness, but I'm just one guy with less Zotero knowledge...
  • I'd imagine the parent item's key remains the same, but would each pdf's key change since they are different?
    If you added a new attachment item, yes. If you just replaced the attachment file on disk via right-click → Show File, no.

    Of course, if the page numbers shifted in the new PDF, a link that included page= wouldn't work properly.
  • In examining this I found a bug for the "select" link, linking it here: https://forums.zotero.org/discussion/95789/zotero-select-links-dont-work-on-app-launch?new=1.

    I also suggested a possible new API "zotero://open" that could open ANY parent item's best attachment, not just pdf, in whatever that attachments default opener is (i.e. whatever happens when you double click the parent item). Perhaps this would be a more basic, limited API without page number / annotations support, since as you mentioned, that might not work.
  • edited May 9, 2023
    > https://forums.zotero.org/discussion/comment/400806/#Comment_400806
    > Markdown export of annotations in Zotero 6 (the current beta) includes zotero://select and zotero://open-pdf links.

    @dstillman: You (maybe) missed to mention, that to create the annotations Export as Markdown, you start with PDF Annotations in the Zotero PDF Viewer (or from other apps) and then need to "Add Note from Annotations" and the exporting this Note. If you export the Note in the PDF itself (e.g. created via Zotfile) you get the old style links in the TOC created from the bookmarks via Zotfile. (As far as I can reproduce this).

    These Annotations are only added to the PDF for external use from the metadata in the Zotero Storage, when you do an explicit `file -> export PDF` of the PDF – as far as I can get it. Just syncing/copying the file from the Zotero Storage is not enough.

    I use a workflow with Logseq from logseq.com and it depends if you want to annotate as a team in a Zotero group or in Logseq assets. There is currently the challenge of creating a roundtripping workflow. Having the PDF Annotations in external metadata is good to seperate annotations from multiple authors during edit.

    Coediting of annotations is currently not possible in Logseq. Since PDF has issues with annotation from different tools as well (SKIM (critical), Preview (not so bad) and Acrobat Pro, enabled Acrobat Reader). In Acrobat Pro joining annotations from different sources is a long time feature (It started as the third party :Remark plugin in 1996 or so)
  • Is there a way to create an external link to open pdf in zotero right now? If so, could someone please explain for dummies....
  • I hope Zotero's PDF attachment can support right-click local program opening operations.
    Currently, some functions require a built-in PDF reader, but more editing operations still require external programs such as Acrobat
  • @Erfr48
    Remember this Zotero URI link
    You only need to change the last 8-bit string "9EAWYJY8", which is the name of the directory where your pdf is stored.
    The value after "page=" indicates which page to jump to after opening the PDF
Sign In or Register to comment.