Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

Tests: read the PDF/X output intent's profile with the crate's own xref reader (#1962)

bflatastice6b28f0e8028
diff --git a/crates/pdf/src/tests_pdfx.rs b/crates/pdf/src/tests_pdfx.rs
index 8149839c6..400662b76 100644
--- a/crates/pdf/src/tests_pdfx.rs
+++ b/crates/pdf/src/tests_pdfx.rs
@@ -59,9 +59,8 @@ fn each_standard_writes_its_header_output_intent_boxes_and_identification() {
}
// (PDF/X-3 and PDF/X-4 share the stream of the profile that tags the colours.)
let oi: u32 = t.split("/DestOutputProfile ").nth(1).unwrap().split(' ').next().unwrap().parse().unwrap();
- let file = hayro_syntax::Pdf::new(std::sync::Arc::new(r.bytes.clone())).unwrap();
- let profile = file.xref().get::<hayro_syntax::object::Stream<'_>>(hayro_syntax::object::ObjectIdentifier::new(oi as i32, 0)).unwrap();
- assert_eq!(profile.dict().get::<i32>(b"N"), Some(4), "{standard:?}: a CMYK profile");
+ let (start, end) = crate::patch::Xref::read(&r.bytes).unwrap().dict(&r.bytes, oi).unwrap();
+ assert!(text(&r.bytes[start..end]).contains("/N 4"), "{standard:?}: a CMYK profile");
// Every page is trimmed to its artboard; the file is untrapped, titled and dated.
for want in ["/TrimBox[0 0 200 100]", "/Trapped/False", "/Title(Untitled)", "/CreationDate", "/ModDate"] {
assert!(t.contains(want), "{standard:?}: {want}");