mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-09 18:56:25 +00:00
fix(render): log each page box hayro-syntax patch 38 sets aside
Review: a /MediaBox or /CropBox read as missing because it has no area is logged with the reader's other repairs (`warn!`). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7ece22b57e
commit
7edbe0cd63
Vendored
+12
-11
@@ -408,19 +408,20 @@ impl<'a> Page<'a> {
|
||||
// none in common with the media box, as a missing one (the media box, ISO 32000-2
|
||||
// §14.11.2, Table 33). Kept, the page's visible region had no area: nothing was drawn
|
||||
// and no text was extracted, where other readers show the page.
|
||||
// A page's own box without area gives way to one it inherits that has some.
|
||||
let media_box = dict
|
||||
.get::<Rect>(MEDIA_BOX)
|
||||
.filter(has_area)
|
||||
.or(ctx.media_box.filter(has_area))
|
||||
.unwrap_or(A4);
|
||||
// A page's own box without area gives way to one it inherits that has some. Each box
|
||||
// set aside is logged, as other repairs of this reader are.
|
||||
let own_media = dict.get::<Rect>(MEDIA_BOX);
|
||||
let media_box = own_media.filter(has_area).or(ctx.media_box.filter(has_area)).unwrap_or(A4);
|
||||
if own_media.or(ctx.media_box).is_some_and(|m| !has_area(&m)) {
|
||||
warn!("a /MediaBox without area was read as missing");
|
||||
}
|
||||
|
||||
let shows = |c: &Rect| has_area(&c.intersect(media_box));
|
||||
let crop_box = dict
|
||||
.get::<Rect>(CROP_BOX)
|
||||
.filter(shows)
|
||||
.or(ctx.crop_box.filter(shows))
|
||||
.unwrap_or(media_box);
|
||||
let own_crop = dict.get::<Rect>(CROP_BOX);
|
||||
let crop_box = own_crop.filter(shows).or(ctx.crop_box.filter(shows)).unwrap_or(media_box);
|
||||
if own_crop.or(ctx.crop_box).is_some_and(|c| !shows(&c)) {
|
||||
warn!("a /CropBox with no area in the media box was read as missing");
|
||||
}
|
||||
|
||||
let rotation = match dict
|
||||
.get::<i32>(ROTATE)
|
||||
|
||||
Reference in New Issue
Block a user