Skip to content

Add optional_rect and required_rect dictionary readers - #567

Merged
Velli20 merged 1 commit into
mainfrom
dictionary-rect-readers
Oct 13, 2026
Merged

Velli20 merged 1 commit into
mainfrom
dictionary-rect-readers

Conversation

@Velli20

@Velli20 Velli20 commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add Dictionary::optional_rect(key, objects) and Dictionary::required_rect(key, objects) to read a four-number array entry as a Rect, keeping the original coordinate order.
  • Use them for /CropBox (document and page) and /RD (annotation subtypes), and build optional_bbox, required_bbox and optional_media_box on top of them. Behavior is unchanged.
  • /Domain in function shadings stays an optional_array_of::<f32, 4> read: it is [xmin xmax ymin ymax], not a rectangle.

Testing

  • cargo clippy --all --workspace, cargo fmt --check
  • cargo test -p pdf-object-reader -p pdf-document -p pdf-annotation-core

🤖 Generated with Claude Code

Read four-number rectangle entries by key and use them for /CropBox,
/RD, /BBox and /MediaBox instead of repeating optional_array_of::<f32, 4>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Conformance reads

Documents that Safe-PDF reads differently from the base commit, compared with PDFium. A read
regresses when Safe-PDF fails to open a document it opened before, crashes or times out, or
counts a different number of pages than PDFium.

pdf.js corpus

1008 documents compared with b469ecf: 1 read worse, 0 read better.

Regressions

Document Base This pull request
issue17190_1 read, 1 page timeout: time limit exceeded (stage safe-read)

840 documents of the PDFium corpus read as on b469ecf.

Details are in the job summaries of the workflow run. Rerun a case locally with
cargo conformance run --corpus <corpus> --read-only --case <id>.

@Velli20
Velli20 merged commit 066c847 into main Oct 13, 2026
10 checks passed
@Velli20
Velli20 deleted the dictionary-rect-readers branch October 13, 2026 19:03
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.

1 participant