vedang / pdf-tools

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

Request for: immediately visible ``free-text'' annotations #82

Open uti5 opened 2 years ago

uti5 commented 2 years ago

Please consider adding the ability to make immediately visible ``free-text'' annotations.

https://github.com/politza/pdf-tools/issues/664

orgtre commented 2 years ago

Text annotations which are directly visible on the document are indeed preferable to those hidden behind a popup in many cases.

I looked into this a bit. As politza mentions here (and is confirmed here), the Poppler glib API, which pdf-tools uses, simply doesn't provide a function to add free-text annotations (it can read and interact with them though). Okular does have support for this, but through Popplers qt5 API.

There is an 8-year-old open issue at Poppler where someone submitted a patch which adds support for creating free-text annotations, but apparently it has never been merged! The patch is not very long, and a Poppler maintainer has indicated that if it were updated and put in merge request form it would be merged.

This means that, in order to get free-text annotations in pdf-tools, the following three things have to be done:

  1. The merge request to poppler glib has to be updated and merged (in C++). Poppler would then provide a function poppler_annot_free_text_new and some other functions related to free text annotations.

  2. Some code has to be added in the annotation_new function of server/epdfinfo.c which calls poppler_annot_free_text_new in a suitable manner (in C).

  3. cmd_addannot and pdf-info-addannot should then work, so one just needs to slightly modify pdf-annot-add-annotation to add a freetext type and create a command pdf-annot-add-freetext-annotation which calls it with that type as argument (in elisp).

I could do (3) easily. Potentially also (2). So if someone with a working knowledge of C++/C were to do (1) and preferably also (2), we'd have free-text annotations!

Alternatives:

simurgh9 commented 2 years ago

The merge request to poppler glib has to be updated and merged (in C).

I am guessing you mean someone has to apply the patch, resolve the conflicts and open a merge request?

orgtre commented 2 years ago

Exactly

simurgh9 commented 2 years ago

Well, I tried.

orgtre commented 2 years ago

Great, thanks! Hopefully someone will be able to help where you got stuck.

orgtre commented 2 years ago

@vedang Maybe it helps if we get a "help wanted" label?

vedang commented 2 years ago

Done :)