PDF reader, new note editor - Automatically generate zotero:// url to currently selected annotation

Dear Zotero developers,

First of all, you've done a super amazing job with the new PDF reader and annotation system. Congratulations and thanks for all the hard work that went into this!

I've been using Paperpile for a while now, but think that the new Zotero beta version is much better - with all the benefits of open source software. For a while now I've been looking for ways to link to annotations from my external notetaking software Obsidian.

I saw that you've recently allowed direct access to annotations via zotero:// urls (Github issue #2125). To test this I went to the Zotero folder, and pasted the url together manually. I got the item ID from the 'storage' folder and the ID of an image annotation in the same PDF from the 'cache' folder. The format
zotero://open-pdf/?annotation=
works perfectly fine. It opens Zotero, the PDF and jumps right to the annotation.

Now I'm looking for a way to automatically generate such a link for the currently selected annotation, and copy it to the clipboard to use in my notetaking application. I was thinking that I could write a translator, similar to the 'Zotero Select Item' translator written by Scott Campbell and Avram Lyon. This would allow to use Zotero's quick copy feature to get the annotation's url with a simple keyboard shortcut. Here's the key part of the original code (credits to the original creators):

function doExport() {
var item;
while(item = Zotero.nextItem()) {
Zotero.write("zotero://select/items/");
var library_id = item.libraryID ? item.libraryID : 0;
Zotero.write(library_id+"_"+item.key);
}
}

Is there any way to iterate through the currently selected annotations in a similar manner? Or could one get the currently selected annotations for item? Or maybe there's a much easier way to solve the problem that I have overlooked?

Thank you very much for your time. I'd greatly appreciate your help.


All the best,
Paul
  • Sorry, an example url is:
    zotero://open-pdf/1_9KNFMBA6?annotation=7BNFVF4R
    where 9KNFMBA6 is the item ID and 7BNFVF4R is the annotation ID
Sign In or Register to comment.