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
  • I found this thread very useful. To contribute to the conversation, it is also possible to open PDFs within group collections. The format is this:


    Where GROUP_ID is a unique number identifier that you can retrieve by visiting your online groups at https://www.zotero.org/groups/

    As the others have mentioned, ITEM_ID is the folder name where the PDF is stored locally, which can also be found in the URL of the opened item within the online group.

    No third-party plugins are required.
  • @davelsan to make it clear the folder is named after the ITEM_ID, not the other way round! When the folder is gone, the ID is still in the database! ;-)

    You can also address the Notes you added to the PDF via select links inside the PDF.

    The user experience is a bit weird, but it works.

    1. Select some text in the PDF
    2. Create an PDF Annotation by clicking on one of the Icons above
    3. Add some Comments and Tags (I am sorry, the tags are not part of the result currently, you can only get a grip on the comment text)
    4. Go to the items list Interface in Zotero
    5. Select the PDF
    6. Right click the item. From the Context menü select: "Create Note from Annotation" or similar in english

    A Note is created inside the item containing the text of all PDF Annotations including the select item link for the sourrounding item and an open-pdf link with parameters pointing to the PDF, Page and Annotation ID.

    To get this information, you need to select the Note and Copy the Note content as Rich Text using menu `Edit -> Copy Note`(Command-Shift-C) and paste it into a rtf or html capable software. The links are behind the visible labels.

    Caveat: The note is not updated when PDF annotations change. You cannot extract single notes. You need to recreate the whole note. The citation key to the note may and the id will change! So you can replace the content of the existing note with the new note to old one and delete the new one. Beware the order of the notes is by alphabet of the first letter. Do not confuse old and new.
  • Well, it is actually possible extract single notes and use their links. You need Actions and Tags (Z7Beta) plugin or Zutilo(Z6) for it. After setting up these plugins and setting up a shortcut for copying item link, here is how it works:

    1. Create an annotation in the PDF reader.
    2. Expand the right pange and add an item note.
    3. Drag you annotation there.
    4. Add your comments below.
    5. Use the shortcut to copy link to the item.(which is a standalone note under the corresponding item)
  • Thanks @ridvanbinici for the tip.
    Link is https://github.com/windingwind/zotero-actions-tags

    I need to investigate that further.

    Today I recognized that moving an item containing a PDF and a handcrafted note like this, the IDs and links in the note listing the annotations are broken. You can recreate it, but should be aware that any citations or links pointing to the actual note are also broken becase of changes of unique IDs during the copy/move.

    This can be challenging. Therefore a nice concept to link by UUID and surviving citation keys as well needs some planning for the particular workflow.

    Panta rhei – Alles fließt (Nothing is constant except of change)
  • edited February 6, 2024
    @acsr: That's pretty important to know, and I'm glad you mentioned it. Perhaps this needs to be a new thread?

    Actually l thought I was in a different thread, so this fits just fine. Thanks! Still, very useful to know this before I break something I don't want to fix.
  • > The user experience is a bit weird, but it works.
    Your method is overly cumbersome and adding all PDF annotations as notes is usually not necessary.

    > You cannot extract single notes. You need to recreate the whole note.

    To my knowledge, it is possible to add a single PDF annotation to a note with just the shortcut keys  Ctrl+C(Copy single annotation in PDF) and Ctrl+V (Paste into notes)

    If you want to obtain the link information contained within it, please use Ctrl+shift+V
  • > `zotero://open-pdf/groups/GROUP_ID/items/ITEM_ID?page=1`

    @ davelsan

    I don't understand how this works. I tested it and it didn't work.

    I currently only know three `Zotero://`     formats available, which are




    I don't like  `zotero://select/library/items/items_ID`

    Because it locates the items in the whole library.

    I prefer it to be able to locate items under the collections that items belong to.

    But I tested

     `zotero://select/library/collections/collections_ID/items/items_ID` and `zotero://select/collections/collections_ID/items/items_ID`

    None of them can work.
    Can anyone tell me if Zotero supports this type of link with the effect I'm expecting
  • > @TJYYWXBG wrote: If you want to obtain the link information contained within it, please use Ctrl+shift+V

    Thx for the hint, I missed that.
  • @TJYYWXBG wrote:
    >> `zotero://open-pdf/groups/GROUP_ID/items/ITEM_ID?page=1`
    > @ davelsan
    > I don't understand how this works. I tested it and it didn't work.

    @TJYYWXBG you need to use the ITEM_ID of the PDF attachment item, not of the container item! This works for me.

    @TJYYWXBG wrote:
    > I currently only know three `Zotero://` formats

    1. Should be lowercase `zotero://` (but this is a typo)
    2. the `/groups/GROUP_ID`part should be able to replace `/library`everywhere when groups are involved. You missed that out in your list. It is unclear why your link to address the page fails.
    3. It is possible to drill down to a single annotation to select it from a link:
    `zotero://open-pdf/groups/[group_id]/items/[item_id]?page=1&annotation=[annotation_id]` (Link created by copying the selected PDF Annotation and pasting using `Cmd-Shift-C`like you described.

    Tip: You can filter out the needed parts using Regular Expressions directly from the clipboard using Python (everywhere) or Powershell, AutoHotkey scripting (on Windows). But my workflow is a mix of Automator and Python and not yet crossplatform.

  • @TJYYWXBG wrote:
    > I tested
    > `zotero://select/library/collections/collections_ID/items/items_ID` and
    > `zotero://select/collections/collections_ID/items/items_ID`
    > None of them can work.

    1. Omit the "can", better: …are not working currently (for me)…
    2. Write a ticket like description of your wish.

    Context of your challenge:
    We are guessing what platform/OS and exact Zotero version you are using. You use a writing style, describing effects as status. (I made the same mistake). This can limit a perspective to not finding a solution. I will try to avoid that as well.

    On select item links

    There are alternate (old and new) styles for linking PDFs. (I omit the old ones here)

    A good starting point would be to point us at the current and upcoming select link reference documentation for the audiences developer **and** end user. Waving to @dstillman et al. You already helped here.

    Then if the topic is not alreday addressed, we need to file a ticket to allow section of items in the context of a collection.

    The real issue, is that the item itself does not "belong" to a collection. It is a user perspective. You only add something to the collection and the item contains a list of the collections it is added to.

    Off-Topic: Select Related Items Eaxample

    One of my current challenges is for example to set a selection to all items currently having a relation to the selected item.

    I wrote a ticket as a feature request for the Zutilo Plugin. But it is challenging.
    I closed this by myself. I am curious how Zoter7 will improve this. I had no spare time yet to setup a non destructive evaluation for the beta7.

    If you would call "select all related" in the context of a collection, the expected result may span several collections and is "challenging" to be usefully displayed inside the current selected collection. Instead you could display the items in the root of the group and list collections in a column/pseudo_field.

    As you can see: if you have a simple setup, some simple ideas may work. But to implement them to work in every general Zotero scenario (or even recursive) can be a challenge or at the end a catch22.

    Logseq as PKM tool to expand beyond Zoteros purpose

    For these use cases I use the PKM tool from https://logseq.com to weave all the citeable resources into much more complex relations. But this a different story and has a personal smell.
  • @acsr
    Thank you for your explanation. Regarding this, I would like to state two points.
    >  you need to use the ITEM_ID of the PDF attachment item, not of the container item! This works for me.

    I may not have understood what "groups" and "GROUP-ID" refer to yet. I used "collections.ID" during testing.

    > Write a ticket like description of your wish.

    When I open PDF attachments using Zotero . Then right-click on the tab above the PDF page and select "show in library". The system can locate the item to which the attachment belongs in the library, and is able to show the item in the collection to which it belongs (if I would have already located the collection).

    I hope“ zotero://select/library/items/items_ID ”Can achieve the same effect.

    The latter currently forces positioning to the top level "my Library" (in Zotero 6)

Sign In or Register to comment.