Files
vectorcraft/crates/pdf/src/tests_presets.rs
T
bflatasticandClaude Opus 5.5 a825aed763 M4.84: PDF/X-1a, PDF/X-3 and PDF/X-4 files written as their standards say
document.exportPdf {standard: pdfX1a|pdfX3|pdfX4} and the PDF/X presets now
write conforming files instead of being refused:

- every PDF/X file gets a /GTS_PDFX output intent (by default the CMYK
  profile in effect, embedded), TrimBox, Trapped, GTS_PDFXVersion (and
  GTS_PDFXConformance for X-1a), a title and dates; editing data,
  passwords and, in X-1a/X-3, PDF layers are refused
- PDF/X-1a converts every colour and image to a CMYK destination,
  untagged, with CMYK spot alternates; X-3 and X-4 tag colours with ICC
  profiles
- X-1a and X-3 are written as PDF 1.3 and their transparency is flattened
  first (High Resolution preset; images with see-through pixels count,
  rasters stay opaque); X-4 keeps transparency, is PDF 1.6 at most and
  names the standard in its XMP metadata
- the written file is checked against its standard (soft masks,
  transparency groups, opacity, blend modes, RGB in X-1a, fonts not
  embedded) and refused rather than mislabelled
- choosing a standard sets the latest compatibility it allows and turns
  off what it forbids (engine and Save PDF dialog)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 17:19:11 +07:00

25 lines
1018 B
Rust

//! The built-in PDF presets: generated in code, valid, described, and round-tripping as JSON.
use crate::*;
#[test]
fn built_in_presets() {
let all = builtin_presets();
assert_eq!(all[0].name, DEFAULT_PRESET);
assert!(all[0].settings.preserve_editing, "the app default keeps the document editable");
assert_eq!(all.len(), 7);
for p in &all {
assert_eq!(p.settings.check_values(), Ok(()), "{}", p.name);
assert!(!p.description.is_empty());
let back: PdfPreset = serde_json::from_value(serde_json::to_value(p).unwrap()).unwrap();
assert_eq!(&back, p, "round-trips");
}
// The PDF/X presets are written as their standards say.
for name in ["pdf/x-1a:2001", "PDF/X-3:2002", "pdf/x-4:2010"] {
let x = builtin_preset(name).unwrap();
assert!(x.settings.standard.is_pdfx() && x.settings.check().is_ok(), "{name}");
}
assert_eq!(builtin_preset("default").unwrap().name, DEFAULT_PRESET);
assert!(builtin_preset("Nope").is_none());
}