Skip to content

mupdf: add annotation type and contents getters#2287

Merged
Frenzie merged 1 commit into
koreader:masterfrom
zeeyado:mupdf-annot-getters
Mar 8, 2026
Merged

mupdf: add annotation type and contents getters#2287
Frenzie merged 1 commit into
koreader:masterfrom
zeeyado:mupdf-annot-getters

Conversation

@zeeyado

@zeeyado zeeyado commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Expose pdf_annot_type() and pdf_annot_contents() from MuPDF as FFI-accessible getters.

koreader-base currently wraps setter functions for annotation properties (pdf_set_annot_contents, pdf_create_annot with type) but not the corresponding getters. This means code that imports embedded PDF annotations can read quadpoint coordinates but cannot read the annotation type (Highlight vs Underline vs StrikeOut) or the /Contents field (user notes).

Changes

  • wrap-mupdf.h: Add mupdf_pdf_annot_type and mupdf_pdf_annot_contents wrappers
  • ffi-cdecl/wrap-mupdf_cdecl.c: Export the two new functions
  • ffi/mupdf_h.lua: Add FFI declarations
  • ffi/mupdf.lua: Add getEmbeddedAnnotations() -- returns type, quadpoint boxes, and contents for each markup annotation (Highlight, Underline, Squiggly, StrikeOut), filtering out Links, Popups, Widgets, etc.

Context

Needed by koreader/koreader#15075 to fix the embedded annotation import feature.


This change is Reviewable

Comment thread ffi-cdecl/wrap-mupdf_cdecl.c Outdated
cdecl_func(mupdf_pdf_next_annot)
cdecl_func(mupdf_pdf_annot_quad_point_count)
cdecl_func(mupdf_pdf_annot_quad_point)
cdecl_func(mupdf_pdf_annot_type)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The annotations header puts pdf_annot_type at the start. I think I'd rather keep the original order unless there's a good reason to deviate.

@benoit-pierre

Copy link
Copy Markdown
Member

So getMarkupAnnotationBoxesFromPage is not longer used, according to zeeyado/koreader@47fac3e (since PdfDocument:getEmbeddedAnnotationsBoxe is no longer used)?

@zeeyado zeeyado force-pushed the mupdf-annot-getters branch from cbdf3e5 to 6ccc40b Compare March 5, 2026 23:19
@zeeyado

zeeyado commented Mar 5, 2026

Copy link
Copy Markdown
Contributor Author

Correct. Removed both getMarkupAnnotationBoxesFromPage() and getEmbeddedAnnotationsBoxes()` since they're no longer used.

@zeeyado zeeyado closed this Mar 6, 2026
@zeeyado zeeyado deleted the mupdf-annot-getters branch March 6, 2026 10:13
@Frenzie

Frenzie commented Mar 6, 2026

Copy link
Copy Markdown
Member

Isn't this still a prerequisite for koreader/koreader#15075?

@zeeyado zeeyado restored the mupdf-annot-getters branch March 6, 2026 17:12
@zeeyado zeeyado reopened this Mar 6, 2026
@zeeyado

zeeyado commented Mar 6, 2026

Copy link
Copy Markdown
Contributor Author

Yes, still needed. Accidentally deleted the branch while cleaning up

@Frenzie Frenzie merged commit 7b5013e into koreader:master Mar 8, 2026
5 checks passed
Frenzie added a commit to Frenzie/koreader that referenced this pull request Mar 8, 2026
* cmake: cleanup some glibc version conditionals koreader/koreader-base@17b401c
* xz: avoid pulling __sched_cpucount@GLIBC_2.6 on older glibc versions koreader/koreader-base@af4e241
* mupdf: add annotation type and contents getters koreader/koreader-base#2287
Frenzie added a commit to Frenzie/koreader that referenced this pull request Mar 8, 2026
* cmake: cleanup some glibc version conditionals koreader/koreader-base@17b401c
* xz: avoid pulling __sched_cpucount@GLIBC_2.6 on older glibc versions koreader/koreader-base@af4e241
* mupdf: add annotation type and contents getters koreader/koreader-base#2287
Frenzie added a commit to koreader/koreader that referenced this pull request Mar 8, 2026
* cmake: cleanup some glibc version conditionals koreader/koreader-base@17b401c
* xz: avoid pulling __sched_cpucount@GLIBC_2.6 on older glibc versions koreader/koreader-base@af4e241
* mupdf: add annotation type and contents getters koreader/koreader-base#2287
benoit-pierre pushed a commit to benoit-pierre/koreader that referenced this pull request Mar 16, 2026
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
…er#15092)

* cmake: cleanup some glibc version conditionals koreader/koreader-base@17b401c
* xz: avoid pulling __sched_cpucount@GLIBC_2.6 on older glibc versions koreader/koreader-base@af4e241
* mupdf: add annotation type and contents getters koreader/koreader-base#2287
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants