Skip to content

fix: import embedded PDF annotations properly#15076

Merged
Frenzie merged 1 commit into
koreader:masterfrom
zeeyado:fix-import-embedded-annotations
Mar 8, 2026
Merged

fix: import embedded PDF annotations properly#15076
Frenzie merged 1 commit into
koreader:masterfrom
zeeyado:fix-import-embedded-annotations

Conversation

@zeeyado

@zeeyado zeeyado commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #15075. Depends on koreader/koreader-base#2287.

Problems with current import (#15040)

  1. Notes discarded -- all annotations get hardcoded note = "embedded highlight", overwriting actual /Contents
  2. No type filtering -- iterates all annotations including Links, Popups, Widgets
  3. Double rendering -- originals stay in PDF while KOReader draws its own on top
  4. No deduplication -- running import twice creates duplicates
  5. Type not preserved -- all imports become "lighten" regardless of original type

Changes

  • pdfdocument.lua: Add getEmbeddedAnnotations() wrapper for the new koreader-base function that returns type, boxes, and contents per markup annotation
  • readerhighlight.lua: Replace saveHighlightsFromBoxes() with importEmbeddedAnnotations():
    • Map annotation type to correct drawer (Highlight -> lighten, Underline -> underscore, StrikeOut -> strikeout)
    • Preserve original /Contents as KOReader note
    • Delete imported annotations from PDF (two-phase: delete first, then import)
    • Deduplicate against existing annotations by quadpoint coordinate matching
    • Respect highlight_write_into_pdf naturally (no more disable/restore hack)
  • readerbookmark.lua: Rename menu item to "Import embedded annotations", show import/skip counts

This change is Reviewable

Fix annotation import to preserve notes, filter by type, deduplicate,
map drawer, and delete originals from PDF after import.

Closes koreader#15075. Depends on koreader-base#2287.
@zeeyado zeeyado force-pushed the fix-import-embedded-annotations branch from 47fac3e to dfa9e65 Compare March 5, 2026 23:26
@hius07

hius07 commented Mar 6, 2026

Copy link
Copy Markdown
Member

Thanks, good development.

@Frenzie Frenzie added this to the 2026.02 milestone Mar 6, 2026
@Frenzie Frenzie merged commit 54de4f1 into koreader:master Mar 8, 2026
4 checks passed
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
Fix annotation import to preserve notes, filter by type, deduplicate,
map drawer, and delete originals from PDF after import.

Closes koreader#15075. Depends on 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.

Import embedded PDF annotations: notes lost, no type filtering, double rendering

3 participants