joplin icon indicating copy to clipboard operation
joplin copied to clipboard

PDF Viewer: Annotation Editing

Open asrient opened this issue 1 year ago • 16 comments

Introduces a new feature to add and remove text based annotations.

Screen Shot 2022-09-13 at 9 02 08 PM

f0e9596903bed61f1430a5af81d568c092e58897_2_690x441

https://user-images.githubusercontent.com/44570278/189943146-9b5b8f9f-2a09-4f45-b701-2231915d4850.mov

f0e9596903bed61f1430a5af81d568c092e58897_2_690x441

https://user-images.githubusercontent.com/44570278/189943133-f700ba77-9ed1-4d39-9f98-619eba60f4aa.mp4

Markup options

  • Highlight
  • Strike Out
  • Underline
  • Erase

Viewer

Full-screen

How to use

First enable the tool (disabled by default) then select text to apply or erase annotation according to the selected tool.

Limitations

The library used under the hood https://github.com/highkite/pdfAnnotate does not seem to work well with some kind of pdfs (compressed specially). For all the cases that the library fails, we show a message to the user indicating the action has failed. The library does not provide any way to determine from beforehand if a pdf is compatible or not.

pdfAnnotate and pdf.js being different projects does not provide any easy way to work well together. After adding an annotation we need to extract the updated pdf blob and feed it back to pdf.js and re-render the page. All this cause a performance penalty. Discussion: https://github.com/highkite/pdfAnnotate/issues/12.

During first annotation addition, there is a known lag that happens when the file has more than 100 pages, but for subsequent addition the lag does not occur.

I would not recommend using this feature with big pdfs over 300 pages since for each annotation change we are extracting the new pdf blob from pdfAnnotate library each time this might even cause the app to crash in certain cases.

Related pdfAnnotate issues

https://github.com/highkite/pdfAnnotate/issues/63 https://github.com/highkite/pdfAnnotate/issues/52 https://github.com/highkite/pdfAnnotate/issues/12

asrient avatar Sep 13 '22 15:09 asrient

How are the annotations saved?

laurent22 avatar Sep 13 '22 22:09 laurent22

How are the annotations saved?

They are saved in the pdf file itself. Annotations are a part of the pdf specification and the pdfAnnotate library provides us the updated pdf file after adding annotations and we when closing the viewer, we write the updated file to disk

asrient avatar Sep 14 '22 13:09 asrient

How are the annotations saved?

They are saved in the pdf file itself. Annotations are a part of the pdf specification and the pdfAnnotate library provides us the updated pdf file after adding annotations and we when closing the viewer, we write the updated file to disk

Will the updated PDF be synced?

roman-r-m avatar Sep 14 '22 15:09 roman-r-m

Will the updated PDF be synced?

Syncing should work fine with this feature but I haven't checked that usecase yet. Will check and let you know, also make changes if necessary.

asrient avatar Sep 15 '22 15:09 asrient

Syncing should work fine with this feature but I haven't checked that usecase yet. Will check and let you know, also make changes if necessary.

@asrient, did you check?

laurent22 avatar Sep 30 '22 16:09 laurent22

@asrient, did you check?

It doesn’t seem to work properly in certain cases, currently working on a fix.

asrient avatar Oct 04 '22 16:10 asrient

@asrient, did you check?

It doesn’t seem to work properly in certain cases, currently working on a fix.

In which cases does it not work?

laurent22 avatar Oct 15 '22 21:10 laurent22

In which cases does it not work?

Hi, Last time I checked, I did a mistake of comparing my dev build with the prod app on my phone. I used oneDrive and later on, on further inspection I observed there's a separate folder for dev on oneDrive and that's why it didn't sync to my phone but was syncing with another dev build on my computer. Now I think it works well as expected, sorry for the confusion.

asrient avatar Oct 16 '22 07:10 asrient

@asrient, are you still interested in completing this PR? There's a minor issue that still needs to be solved

laurent22 avatar Nov 01 '22 14:11 laurent22

@asrient, are you still interested in completing this PR? There's a minor issue that still needs to be solved

Hi, yeah I’m still interested. I’m bit busy with some work right now but will get it done.

asrient avatar Nov 01 '22 16:11 asrient

recheck

laurent22 avatar Dec 21 '22 17:12 laurent22

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

github-actions[bot] avatar Dec 21 '22 17:12 github-actions[bot]

@asrient, thanks for the update. Would you mind signing the CLA, as described here? There are also some minors conflicts. Once it's fixed we can merge

laurent22 avatar Dec 27 '22 14:12 laurent22

I have read the CLA Document and I hereby sign the CLA

asrient avatar Dec 27 '22 17:12 asrient

recheck

asrient avatar Dec 27 '22 17:12 asrient

fixing the conflicts in some time.

asrient avatar Dec 27 '22 17:12 asrient

I just gave it a try but it doesn't work so well - many pdf files don't have the text in a nice layout, so underlining or highlighting doesn't work well (and in some cases, as you mentioned, it doesn't work at all).

It would be more useful to have annotation tools like what macOS Preview provide - a way to draw on top of the PDF, add text, etc. That way all can be done regardless of the PDF. In fact, for now it's much better to open the PDF as an external resource, make the annotations in Preview and close it.

So with this in mind I don't think we'll merge this for now. It could be used as a starting point if someone else wants to add proper annotation tools later on.

laurent22 avatar Jan 05 '23 18:01 laurent22

In fact I wonder what are the benefits of the new PDF viewer compared to the built-in one? Is it just that the new one memorises the current page?

laurent22 avatar Jan 05 '23 18:01 laurent22