emacs-eaf / emacs-application-framework

EAF, an extensible framework that revolutionizes the graphical capabilities of Emacs
GNU General Public License v3.0
3.07k stars 233 forks source link

PDF Viewer: function to get the ID/Name of an annotation and jump to an annotation based on ID/Name #521

Closed fuxialexander closed 3 years ago

fuxialexander commented 3 years ago

Is your feature request related to a problem? Please describe. I'm considering making org-pdftools and org-noter-pdftools compatible with the EAF PDF viewer, however, a few API is still missing. Namely: the functions to:

Describe the solution you'd like PyMuPDF actually has support for all these. But they need to be used by EAF to be used from Emacs. Just like what has been done for the function to add an annotation.

manateelazycat commented 3 years ago

@luhuaei Above is right direction?

luhuaei commented 3 years ago

@luhuaei Above is right direction?

Great! org-noter and org-pdftools provide many useful feature. :smiley_cat:

manateelazycat commented 3 years ago

@luhuaei Can you help add those APIs ? Thanks

luhuaei commented 3 years ago

OK, I will try to add those api on pdf-viewer

luhuaei commented 3 years ago

532

(eaf-pdf-get-annots PAGE) will return a map about the annot on PAGE. if the PAGE has annot will return

{
  "annot-id": {
    "type_int": "annot type enum, see https://pymupdf.readthedocs.io/en/latest/vars.html#annotation-types",
    "type_name": "annot type name",
    "rect": "the annot internal position on pymupdf page",
    "page": "the page index on pdf"
  }
}

if the PAGE no annot will return {}

use the (eaf-pdf-jump-to-annot ANNOT) jump to annotation position on pdf-viewer

example: if the page 66 has an annotation, and it id is fitzannot-0

(eaf-pdf-jump-to-annot (gethash "fitzannot-0" (json-parse-string (eaf-pdf-get-annots 66))))

@fuxialexander Those API can satisfy compatible org-pdftools and org-noter-pdftools ?

manateelazycat commented 3 years ago

great