Zotero Obsidian Integration - How to automatate paper pdf link

Hi everyone,

Have some time that I am trying to adjust my zotero-obsidian template to add a preview of the paper pdf.
The zotero pdf folder is already in the vault and would like to add the this link into the note.
Somthing like that: ![[ {{attachments.path}} ]], or ![[Myfolter/{{attachments.title}}]].
I have no idea if this is possible.

I use to have a {{pdfZoterolink}} (or something like that), but this open the pdf on Zotero, I woul like to open the pdf on Obsidian.

Any thoughts?

Thank you in advance.

What I’m trying to do

Things I have tried

Hi Rodrigo,

Since attachments is an array that may contain several attachments, you need to iterate over the array with a for loop to generate a link for each attachment. Here’s how I do it in my template:

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

{{loop.index}} is just a number for the attachment placement in the array. I use it to make the links unique, if there is more than one attachment.

But this example targets PDFs outside the vault. For files inside the vault, you don’t need the file:/// part of the link, nor the full path—you can just use the title like so:

{% for attachment in attachments | filterby("path", "endswith", ".pdf") %}
- [[{{attachment.title}}]]
{%- endfor %}

Here, I just formatted the attachments as a list, but you can change the format however you like. You can also add an alias like [[{{attachment.title}} | Open PDF]].

If you have similar questions in the future, Zotero Integration’s Data Explorer will come in handy. You can find it in the command palette. There, you can see all the data available, how the data is structured and what the variables are called. You can even right click to copy a template which captures that variable.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.