vedang / pdf-tools

Emacs support library for PDF files.
https://pdftools.wiki
GNU General Public License v3.0
641 stars 90 forks source link

Allow creation of markup annotations without a text selection #191

Closed astoff closed 1 year ago

astoff commented 1 year ago

I would like to be able to annotate an arbitrary region of the page after selecting it with M-drag-mouse. For instance, the following selection:

image

produces this annotation

image

I would rather be able to do this:

image

Perhaps this would be better achieved with a "Square" annotation, which epdfinfo doesn't support (although apparently poppler does). Lacking that, however, a highlight annotation seem suitable.

EDIT: In the updated version of this PR, the red annotation can created by calling pdf-annot-add-highlight-markup-annotation when the region is a rectangle (if multiple rectangles are selected, only the first is used). We could add a customization option to preserve the original behavior, but I think I would rather wait and see if anyone complains.

Do you think this is a good approach, given that adding the other annotation types would be a much bigger effort?

astoff commented 1 year ago

One more thought concerning Square annotations: those appear over the text, so really serve a different purpose. One could simulate the red annotation of the screenshot above using a square annotation with transparency, but it's not quite the same thing.

ffsammak commented 1 year ago

would this nice feature be useful if I have a scanned pdf, not OCR, only old scanned pdfs as image?

astoff commented 1 year ago

Exactly, that's one of the main use-cases.

@vedang What do you think?

ffsammak commented 1 year ago

Wow! that would be a great addition to the already impressive pdf-tools. So in a scanned pdf, no text layer, I can add a rectangular highlight on the desired place inside the image PDF and then when I click on that rectangle I can add some text annotation. That is a long-awaited feature. This is in fact the only single reason I still use Foxitreader beside pdf-tools. Look forward to your great addition.

ffsammak commented 1 year ago

@astoff Hi, has this great feature been merged upstream? Just wondering why not. Take care.

vedang commented 1 year ago

Hi!

This feature has not been merged upstream because I haven't been able to make the time for it. I'm hoping to make some time next month to clean up a lot of pending work on pdf-tools. Sorry for the delay on this!

Thanks, Vedang

On Wed, Mar 22, 2023 at 7:54 PM FFS @.***> wrote:

@astoff https://github.com/astoff Hi, has this great feature been merged upstream? Just wondering. Take care.

— Reply to this email directly, view it on GitHub https://github.com/vedang/pdf-tools/pull/191#issuecomment-1479657514, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAUUHUQNZB5666CDYC4Z6LW5MDQLANCNFSM6AAAAAAUYZLW2E . You are receiving this because you were mentioned.Message ID: @.***>

-- Cheers, Vedang

https://vedang.me @vedang on Twitter

ffsammak commented 1 year ago

Hi! This feature has not been merged upstream because I haven't been able to make the time for it. I'm hoping to make some time next month to clean up a lot of pending work on pdf-tools. Sorry for the delay on this! Thanks, Vedang On Wed, Mar 22, 2023 at 7:54 PM FFS @.> wrote: @astoff https://github.com/astoff Hi, has this great feature been merged upstream? Just wondering. Take care. — Reply to this email directly, view it on GitHub <#191 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAUUHUQNZB5666CDYC4Z6LW5MDQLANCNFSM6AAAAAAUYZLW2E . You are receiving this because you were mentioned.Message ID: @.> -- Cheers, Vedang https://vedang.me @vedang on Twitter

Thanks for the reassuring reply, just can't wait. Best.

vedang commented 1 year ago

This change looks good to me and I'm merging it in. Thanks @astoff !