Does anyone have a workflow for associating notes with a Zotero-stored PDF?

Sorry for all the questions. I am still using Zotero to store citations, in part because I am sharing my references with students through a shared bibliography. Zotero grabs PDF’s for me from the web, and I then take notes in pdf-view. I’d like to be able ot link to that PDF. Any idea how I can do that easily? can I capture via zotero somehow (seems like I’m missing a lot of infrastructure here but am hoping someone can help anyway). thanks again!

1 Like

You want to install ZotFile.

See also this, which maybe should be updated to include ZotFile?

I actually don’t use ZotFile. I know it’s mostly for sending things to tablets and other pdf folders, but I use Zoo for syncing with my Android devices…

I may have missed this in thelink you posted, but is the idea that I store pdfs with zotfile, export zotero db with better bibtex, create a new note with org-roam-bibtex capture template, and then open the PDF with org-ref and start editing?

Seems… a little convoluted.i was kind of hoping I would somehow write a bookmarklet that first called some zotero function, then ran org protocol in a way they harvested the citekey somehow and linked to the pdf if it existed… But maybe that’s asking quite a lot, actually.

But also maybe I didn’t really understand fully what you meant. Are you using zotero ATM?

There are several ways to do it. Imagine that I have an article item in Zotero with an attached pdf also shown in Zotero. I highlight and annotate the pdf, then use Zotfile’s function ‘Extract Annotations’, which creates a note in Zotero under the item that has the pdf as an attachment, and the note has the highlighted text, my comments, and links to their location in the pdf. If you want to put that note text in O-R, you can copy/paste the note content.

I don’t know of any method that will let you do it in fewer steps. Maybe a pdf annotation/highlighting package in Emacs like org-noter will, but I haven’t figured that one out yet.

hmm, interesting. But in terms of the note creation, you have to enter the TITLE, ROAM_KEY, ROAM<REF manually? That is part of what I’d like to solve.

In terms of extracting the pdf notes, I use this code and pdfview links to extract the text from pdf highlights and add org-mode links directly. Might be helpful for you? (written several years ago, is probably ugly):

  (defun pdf-annot-markups-as-org-text (pdfpath &optional title level)
    "Acquire highligh annotations as text, and return as org-heading"

    (interactive "fPath to PDF: ")  
    (let* ((outputstring "") ;; the text to be returned
           (title (or title (replace-regexp-in-string "-" " " (file-name-base pdfpath ))))
           (level (or level (1+ (org-current-level)))) ;; I guess if we're not in an org-buffer this will fail
           (levelstring (make-string level ?*)) ;; set headline to proper level
           (annots (sort (pdf-info-getannots nil pdfpath)  ;; get and sort all annots
                         'pdf-annot-compare-annotations))
           )
      ;; create the header
      (setq outputstring (concat levelstring " Quotes From " title "\n\n")) ;; create heading

      ;; extract text
      (mapc
       (lambda (annot) ;; traverse all annotations
         (if (eq 'highlight (assoc-default 'type annot))
             (let* ((page (assoc-default 'page annot))
                    ;; use pdf-annot-edges-to-region to get correct boundaries of highlight
                    (real-edges (pdf-annot-edges-to-region
                                 (pdf-annot-get annot 'markup-edges)))
                    (text (or (assoc-default 'subject annot) (assoc-default 'content annot)
                              (replace-regexp-in-string "\n" " " (pdf-info-gettext page real-edges nil pdfpath)
                                                        ) ))
                  
                    (height (nth 1 real-edges)) ;; distance down the page
                    ;; use pdfview link directly to page number
                    (linktext (concat "[[pdfview:" pdfpath "::" (number-to-string page) 
                                      "++" (number-to-string height) "][" title  "]]" ))
                    )
               (setq outputstring (concat outputstring text " ("
                                          linktext ", " (number-to-string page) ")\n\n"))
               )))
       annots)
      outputstring ;; return the header
      )
    )
1 Like

Truthfully, I am still figuring out how to set up O-R and get it into my workflow, so I can’t answer your question. I suspect that org-roam-bibtext will help solve the issue you mention. Thanks for your code!

1 Like

ZotFile simply has the ability to move and rename PDFs. So you could set it to use the BBT-derived citekey as file name, in the directory of your choosing.

And you can set BBT to auto regenerate a bibtex/biblatex file when your db changes.

I was doing this awhile back, but now use Zotero less.

I’m not sure how best to address the last part.

1 Like

Just noting here that org-noter has similar functionality under the org-noter-create-skeleton command.

thx @bruce. I think this comes close. I find that it takes BBT a short but appreciable time to regenerate the bibtex file, and org-ref an unpredictable length of time to read that file and find the reference. This slows down the process enough for me to ADHD out while I’m waiting :slight_smile:
What I’ve done for now is set zotfile to store PDF in a directory with author-title-year.pdf as the filename pattern. I start the note with an org-protocol bookmarklet. Then I use company-files to complete the filename manually when I want to import the actual notes. It feels pretty close, if not completely smooth. Here’s my current capture template (w thanks to @edumerco for help over on Reddit):

(setq org-roam-capture-ref-templates
        '(("r" "ref" plain (function org-roam-capture--get-point)
           ""
           :file-name "${slug}"
           :head "#+TITLE: ${title}
#+ROAM_KEY: ${ref}
#+ROAM_ALIAS:
:PROPERTIES:
:TYPE: cite, article, reference, idea, task, book
:END:

Entered on %u\n

%i

#+begin_src emacs-lisp :var thispdf=\"/home/matt/Dropbox/Zotero/\"
(pdf-annot-markups-as-org-text thispdf nil 1 )
#+end_src"
           :unnarrowed t
           :immediate-finish t)))
)

the ${ref} is I guess sort of misplaced with the current method, but I’d like to somehow find a way to capture it in future, so leaving in for now.

1 Like

Not sure if this is helpful, but I wrote a short description of linking Zotero with RMarkdown files in Emacs. The main point is setting up Zotero to create a bibtex mirror of your bibliography, which for me happens basically instantly at this point. Maybe it will slow down as you observe when I have more of my database transferred into Zotero?

Anyways, the cite-as-you-write features of Markdown mode and Org-mode use the same functions, and the citation links are ‘hot’: clicking on them opens the stored pdf. That is all pretty handy, and I expect will work more-or-less unchanged between Markdown and Orgmode.

https://plantarum.ca/2020/07/20/blogdown-citations/

1 Like

Very useful. Thanks.