fuxialexander / org-pdftools

A custom org link type for pdf-tools
GNU General Public License v3.0
336 stars 36 forks source link

Autosave, global write/save commands do not save PDF buffer when using org-noter/org-pdftools #68

Open workcomplete opened 3 years ago

workcomplete commented 3 years ago

I did some reading over the weekend and marked up a number of PDFs using the combined highlight-annotation and text extraction of org-pdftools by calling org-noter-insert-note. This works beautifully and I am able cruise through my compiled notes document calling 'sync next/previous note' to see the highlighted portion of the text presented in the PDF.

On reopening the PDFs to resume note-taking this morning the highlight-annotations have disappeared from the pdf document. The notes themselves are intact (i.e. the content, noter page address and ID are correct) and when I scroll through the pdf, the notes document is still synced (e.g. it scrolls in sync with the pdf).

However, when I call org-noter-sync-[next/previous/current]-note I get "no such annotation". The mini-buffer in the pdf document buffer still tells me there are "[some number of] notes invalid" on the page. pdf-tools-install does not fix this. pdf-annont-minor-mode is active in the bufffer.

Given the layers of programs being used to make this workflow happen I'm not sure if this is an org-pdftools problem but it's the most recent addition to the workflow so I figured I would start here. My config is exactly as is posted in the README for this project. If other parts of my config would be helpful I'm happy to share.

I did reinstall pdf-tools last week due to the change in maintainer (vedang), but that was before marking these documents up.

FWIW my pdfs are OCR tesseract generated from scans of books- this has been associated with some weird behavior with pdf-tools in the past but I have not encountered this specific issue before.

workcomplete commented 3 years ago

This could be a user error. Org-noter opens a new frame with vertical split, document buffer and notes buffer. Calling "write" in the notes buffer does not save the linked annotations. It appears that with my setup I have to call "write" in both the notes and PDF buffer.

igoralmeida commented 3 years ago

(Disclaimer: I haven't actually installed org-pdftools yet, but I have used pdf-tools and org-noter extensively)

It does look like user error, and I don't think it has anything to do with org-pdftools itself. For future reference:

The 'annotations' (highlights, free text, etc.) are the responsibility of pdf-tools (or any other PDF viewer). Once you've added them with pdf-tools (something like C-c C-a t or pdf-annot-add-text-annotation), you must save the PDF, because that's where the annotations live.

The 'notes' you navigate with org-noter-sync-xxxx are the responsibility of org-noter, and they live in an .org file that you chose the first time you opened an org-noter session for that PDF. You just need to save the org buffer to keep these.

There is at least a one-way method to create 'notes' for org-noter out of pdf-tools 'annotations' with org-noter-create-skeleton, but you'll have to run it every time you add a new annotation :) The good thing is that you can use the same org-noter-sync-xxxx commands to navigate through both sets (otherwise you'll need something like pdf-annot-list-annotations and then pdf-annot-list-follow-minor-mode).

There are github issues in the repos that you can read through discussing a way to keep these two in sync, but it's still very experimental as far as I know.

workcomplete commented 3 years ago

Thanks @igoralmeida for that response, the issue at hand is not keeping the .org notes and pdf annotations in sync, org-pdftools handles this very well. The issue is that autosave does not happen in the pdf buffer when annotating the PDFs using org-noter and org-pdftools. On top of this, calling ":w" or "save-all-buffers" only saves only the .org file and not the pdf annotations unless explicitly called from the PDF buffer. This only happens in org-noter mode (eg. if I annotate a pdf using pdf tools, the changes are autosaved, and ":w" will also save the pdf annotations if called from another buffer).

willis-richard commented 3 years ago

I have also been burned by this. I have annotations that are saved in the org-noter buffer but not saved in the pdf. There appear to be two problems:

Because forgetting to properly save the pdf buffer causes my highlights to be lost, it would be nice if there was a function to add the org-noter annotations to the pdf.

willis-richard commented 3 years ago

I have had some success using the 'fix' fapdash has posted in the linked issue.