Files
vectorcraft/crates/pdf/src/tests_presets.rs
T
bflatasticandClaude Opus 5.5 9aa29aa0fd M4.44: PDF presets: built-ins in code, saved presets, Edit > PDF Presets
Built-in presets are generated in code (VectorCraft Default, High
Quality Print, Press Quality, Smallest File Size and PDF/X-1a, X-3,
X-4, the latter listed as not supported yet) and read-only. Saved
presets live with the preferences (Prefs.pdf_presets) and work as
`preset` wherever PDF options are taken: document.exportPdf,
pdfSettings, export/serialize as PDF and .ai saves.

pdf.preset.list / save / delete / export / import manage them
(.vcpdfpresets files; opening one imports it). The Save PDF dialog's
Save Preset… saves its settings under a name; Edit > PDF Presets…
(ui.pdfPresetsDialog) lists the presets with each one's description and
differences from the default, with New…, Edit… (the Save PDF dialog as
a preset editor, ui.pdfPresetDialog), Delete, Import… and Export….
document.pdfSettings now lists what differs from the chosen preset.

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

23 lines
945 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");
}
// PDF/X presets name standards the writer doesn't produce yet.
let x4 = builtin_preset("pdf/x-4:2010").unwrap();
assert!(matches!(x4.settings.check(), Err(PdfError::Unsupported(_))));
assert_eq!(builtin_preset("default").unwrap().name, DEFAULT_PRESET);
assert!(builtin_preset("Nope").is_none());
}