Skip to content

Add PDF annotation convenience APIs#224

Merged
messense merged 2 commits into
mainfrom
annotations
Jun 1, 2026
Merged

Add PDF annotation convenience APIs#224
messense merged 2 commits into
mainfrom
annotations

Conversation

@messense

@messense messense commented Jun 1, 2026

Copy link
Copy Markdown
Owner

No description provided.

@messense messense requested a review from Copilot June 1, 2026 13:34
@messense messense linked an issue Jun 1, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR expands the PDF annotation API surface with higher-level “convenience” constructors and additional annotation property accessors/mutators, plus redaction helpers and supporting FFI wrapper functions.

Changes:

  • Add PdfPage::*add_*_annotation() helpers (line, polygon/polyline, ink, text markup, stamp, redact) and redaction application helpers with options.
  • Extend PdfAnnotation with additional getters/setters (geometry, colors, flags, opacity, border, quad points, ink list, default appearance, etc.) and improve detached-annotation handling.
  • Harden string decoding by returning Error::InvalidUtf8 instead of panicking on invalid UTF-8.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/pdf/page.rs Adds annotation-creation convenience APIs, redaction helpers, and stricter delete_annotation validation.
src/pdf/annotation.rs Adds many annotation accessors/mutators, redaction option types, quad/area helpers, and detached-annotation checks.
src/pdf/tests_annotation.rs Adds tests covering new annotation conveniences, geometry roundtrips (incl. rotation), redaction behavior, and error cases.
src/pdf/object.rs Avoids panics by returning Error::InvalidUtf8 on invalid UTF-8 conversion.
src/pdf/mod.rs Re-exports newly introduced annotation/redaction types.
src/color.rs Adds derives to AnnotationColor to support comparisons in new tests.
mupdf-sys/wrapper/pdf_page.c Adds wrapper for redaction with options.
mupdf-sys/wrapper/pdf_annot.c Adds wrappers for new annotation APIs and improves error handling for detached annotations during filtering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/pdf/tests_annotation.rs Outdated
Comment thread src/pdf/page.rs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread src/pdf/annotation.rs
Comment on lines 21 to 24
Circle = PDF_ANNOT_CIRCLE,
Polygon = PDF_ANNOT_POLYGON,
PloyLine = PDF_ANNOT_POLY_LINE,
PolyLine = PDF_ANNOT_POLY_LINE,
Highlight = PDF_ANNOT_HIGHLIGHT,
@messense messense merged commit 7010e6e into main Jun 1, 2026
13 checks passed
@messense messense deleted the annotations branch June 1, 2026 23:52
@messense messense linked an issue Jun 2, 2026 that may be closed by this pull request
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.

ink annotation already usable? Wrap MuPDF annotations API

2 participants