Zotero link to pdf annotation does not work

What I’m trying to do

In obsidian an annotation imported from zotero shows the text of the annotation and a link to the pdf file it is imported from. If I click on the link obsidian tells me:

Could not read file zotero://open-pdf/library/items/H4D9W3X6?page=77&annotation=KW8Q2XSM

Things I have tried

Searched the internet and obsidian help: Happened nothing

Tried to change parts of the link to find the pdf manually in my home directory. I found a directory in my Zotero storage. The link seems correct. There is the pdf in a directory “H4D9W3X6”. But I can’t locate the “KW8Q2XSM” part in my obsidian vault.

I suppose there is an entry somewhere to tell obsidian where to locate the annotations but I did not find it.

Since I use flatpak, Obsidian plugins for Zotero don’t work for me.

You could install a Zotero plugin called “better notes”, which is able to generate markdown notes (with and without highlights) and with links to your highlights in zotero

In zotero, click on the yellow note, then the plus button under the search field to generate your notes.
Then click on your note, in there click on the 3 dots to export your note.
Simple and useful. Just “wegwerf” other plugins that don’t work. :wink:

Thank you very much! I will try Better Notes and afterwards decide wether to wegwerf zotero integration in obsidian.

1 Like

Sounds like your link might be malformed.

It should look like this: [link text](zotero://open-pdf/library/items/8PYTEL4L?page=215&annotation=6KQRUZIW)

How did you have it formatted? With a file:/// prefix?

I have tried, but have not even managed to produce a simple note :frowning: Better Notes is so complex - where can I find a comprehensible guide?

My template to import zotero items has this entry:

  • pdfZoteroLink"PDF"

This part looks like your suggestion. I don’t know where the part after the “?” is added. Obviously by the Zotero Integration plugin.

What I tried: I enter ‘file:///home/username/Zotero/storage/H4D9W3X6/’ in my browser and am directed into the correct directory where my pdf is stored.

How to proceed? Is there a way to enter code into my template to direct the link to the annotation? In my example it would be “page77&KW8Q2XSM” - I suppose this is the name of the annotation stored in Zotero?

Thank you for answering!

I found the code in my template. It reads:

(p. {{annotation.page}})

Can you share the full code for the pagenumbers and annotation link? The critical part is missing. And please make sure to share it in a code block, so it can be read correctly.

Yes, it’s called desktopURI and it’s stored in the data of each annotation. When I see you current code, I can help you implement it.

Better Notes adds a yellow note icon to your right-side ribbon.

Like in Obsidian, Zotero has two sidebar buttons:

  • click on the left sidebar button to expand panels on the left (with page overview, etc)
  • click on the sidebar button on the right to expand panels on the right (tools like metadata, etc).
  1. First if all, open Zotero and a PDF (or other document) with highlights in it and enter in reading mode. Same, as when you would read and highlight your document
  2. expand the panels on your right side with the right sidebar button
  3. With the panels open, click on the yellow note icon in the right ribbon.
  4. With the Better Notes panel open, click the plus button under the search field to choose an option to generate notes from your existing highlights and confirm. This generates your note
  5. Then click on your new note, to open your note
  6. With your note open, click on the toolbar icon with 3 dots to select export and confirm: save your note to the documents folder.

This is the part of the plugin you want. There’s no need to discuss other features of Better Notes.

.

I’m just trying around to understand templates - I copied some code from this forum’s posts as a starting point - so maybe it’s from Feralflora ;-). Here is my last try:


Referenz: “{{bibliography}}”

{% persist “annotations” %}

{%- set newAnnotations = annotations | filterby(“date”, “dateafter”, lastImportDate) -%}
{% if newAnnotations.length > 0 %}
{%- set noteIndex = 1 -%}
{% for annotation in newAnnotations %}
{{annotation.annotatedText}}

{%- if annotation.desktopURI %}
:mag_right: - (p. {{annotation.pageLabel}})
{%- endif %}
{%- if annotation.comment %}
:pencil2: - {{annotation.comment | replace (“”, “”) | replace (“”, “”) | replace ("- ", ">- ")}}
{{ annotation.id }})
{%- endif %}
%%(Id: {{ annotation.id }})%%
{%- endfor %}
{%- endif %}
{%- endpersist -%}

Thanks! I will try and look …

Nope, that’s not mine. Mine has functioning annotation links :wink:


If that’s your current template, then there should be no link at all associated with each annotation, since you just output the page label, but not {{annotation.desktopURI}} as part of a markdown link, like:

[(p. {{annotation.pageLabel}})]({{annotation.desktopURI}})`

These links don’t link to the file itself, but to Zotero, which then navigates to the PDF and the correct location within it.

If you need the link to the PDF attachment, something like this works, while accounting for the possibility of having more than one PDF attached to an item:

{% for attachment in attachments | filterby("path", "endswith", ".pdf") %} | [**PDF-{{loop.index}}**](file:///{{attachment.path | replace(" ", "%20")}}){%- endfor %}

Another way to get a direct link to the first PDF attachment is to use {{pdfLink}}, or if it’s an EPUB or something like that, you need: {{firstAttachmentLink}}.

You can explore all the available template variables in the Data explorer provided by Zotero Integration with a command called the same.

Work perfectly - both your one-liner and {{pdfLink}}. Obsidian opens the pdf-file.

But howto jump to the page of the annotation. This line in my script obviously attempts to do that but fails:

(p. {{annotation.pageLabel}})

after execution it reads:

([p. 20] (zotero://open-pdf/library/items/F93DR3U9?page=20&annotation=288C2FTG)

but does not what it is intended to.

Do you have one more idea howto correct this line?

My first example above is exactly what you need. You need that code as is, no parts missing. I’m not sure your non-working code is a proper markdown link like [link text](link destination). Or is it just the formatting that’s off without the backticks needed for inline code or code blocks?

I’m working on your suggestions!

I tried some time, but did not succeed.

I put the code you suggested into my template:

{{pdfLink}}
(p. {{annotation.pageLabel}})

the first line opens up the attached pdf file.

The second ends in an error reading:

Could not read file zotero://open-pdf/library/items/7633Q3HW?page=27&annotation=QIFCGPD2.

If I look into my local zotero directory the pdf is stored in:

/home/myusername/Zotero/storage/7633Q3HW/

Zotero Data Explorer says:

  • pdfZoteroLink"PDF"

the address reading: (zotero://select/library/items/7633Q3HW)

What’s going wrong must be the transfer of the file name when my template creates the link to the pdf and to the block quote.

Do you have any idea where to look?

“Solution”: What you suggested works in windows but not in Linux (kubuntu 24.10) :frowning: