mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-24 10:08:00 -06:00
M2: resolve an indirect annotation /Subtype before the Invisible print filter
The print filter read /Subtype with a direct-only lookup, so a standard annotation whose /Subtype is an indirect reference (ISO 32000-2 §7.3.10) looked like an unknown type and an Invisible flag dropped it from print (Table 167 applies only to non-standard types, Table 171). The subtype is now resolved through the document first. Also removes a stray cell separator in the hayro-interpret row of vendor/README.md that pushed the test references for patches (44)-(56) out of the table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a6df1d3ca5
commit
827cec3c6e
@@ -760,7 +760,9 @@ fn prints(doc: &Document, d: &Dict, content: Content) -> bool {
|
||||
if flags & PRINT == 0 || flags & HIDDEN != 0 {
|
||||
return false;
|
||||
}
|
||||
let subtype = d.name(b"Subtype").unwrap_or(b"");
|
||||
// `/Subtype` may be an indirect reference (ISO 32000-2 §7.3.10), so resolve it first.
|
||||
let subtype_obj = d.get(b"Subtype").map(|s| doc.resolve(s));
|
||||
let subtype = subtype_obj.as_deref().and_then(Object::as_name).unwrap_or(b"");
|
||||
match subtype {
|
||||
b"Widget" => true,
|
||||
b"Link" | b"Popup" => false,
|
||||
|
||||
@@ -981,4 +981,11 @@ fn invisible_annotations_of_unknown_types_do_not_print() {
|
||||
assert!(!prints(&doc, &annot(None, 5), all), "no Subtype is no standard type");
|
||||
assert!(prints(&doc, &annot(Some("Square"), 5), all), "Invisible doesn't apply to a standard type");
|
||||
assert!(prints(&doc, &annot(Some("Widget"), 5), Content::FormFieldsOnly), "nor to a field");
|
||||
|
||||
// An indirect `/Subtype` (§7.3.10) is resolved: a standard type stays standard.
|
||||
let mut doc = doc;
|
||||
let square = doc.add(Object::name("Square"));
|
||||
let mut indirect = annot(None, 5);
|
||||
indirect.set(b"Subtype".to_vec(), Object::Ref(square));
|
||||
assert!(prints(&doc, &indirect, all), "an indirect standard Subtype");
|
||||
}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user