Add PDF annotation convenience APIs#224
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
PdfAnnotationwith 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::InvalidUtf8instead 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 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.