From 7edbe0cd6369479a7a57a8bbf05f8a09abd040f5 Mon Sep 17 00:00:00 2001 From: mtlcl410 Date: Fri, 6 Nov 2026 07:29:11 +0800 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn --- vendor/hayro-syntax/src/page.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/vendor/hayro-syntax/src/page.rs b/vendor/hayro-syntax/src/page.rs index 26b1ad140c..10be01446c 100644 --- a/vendor/hayro-syntax/src/page.rs +++ b/vendor/hayro-syntax/src/page.rs @@ -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::(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::(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::(CROP_BOX) - .filter(shows) - .or(ctx.crop_box.filter(shows)) - .unwrap_or(media_box); + let own_crop = dict.get::(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::(ROTATE)