hayro-interpret: restore FormXObject RESOURCES presence check and Indexed image recovery in x_object.rs (#2497)

* hayro-interpret: port remaining pdfcraft resource-scope, indexed-image, and text-clip patches

* hayro-interpret: keep craft-libs resource-scope and text contracts; retain x_object.rs fixes
This commit is contained in:
Dylan M. Taylor authored and GitHub committed 2026-11-19 23:46:01 -05:00
1 parent 380a2f79f6
commit c470ed170d
1 file changed
+10 -2
+10 -2
View File
@@ -83,7 +83,10 @@ impl<'a> FormXObject<'a> {
// PdfCraft patch: see `context::MAX_PAGE_CONTENT`.
let decoded = crate::context::decode_content(stream)?;
let resources = dict.get::<Dict<'_>>(RESOURCES);
// PdfCraft patch: retain absence; present malformed dictionaries stay local-empty.
let resources = dict
.contains_key(RESOURCES)
.then(|| dict.get::<Dict<'_>>(RESOURCES).unwrap_or_default());
let matrix = Affine::new(
dict.get::<[f64; 6]>(MATRIX)
@@ -611,9 +614,14 @@ impl<'a> ImageXObject<'a> {
default_space = Some(key);
Some(space)
} else {
// PdfCraft patch (80): an Indexed space given in place whose `hival` has no
// reading cannot be built and falls back below, as upstream; it is reported.
malformed_indexed = cs_obj
.as_ref()
.is_some_and(crate::color::has_unusable_hival);
cs_obj
.clone()
.and_then(|c| ColorSpace::new(c, cache))
.and_then(|c| ColorSpace::new_allowing_tableless(c, cache))
// Inline images can also refer to color spaces by name.
.or_else(|| {
cs_obj