Save PDF: choosing PDF/X-3 or PDF/X-4 unsets Profile inclusion

Profile inclusion is disabled with a standard. A Don't Include Profiles
choice made before picking PDF/X-3 or PDF/X-4 stayed in the dialog and
wrote every CMYK color as DeviceCMYK, which the PDF/X note does not
describe. Choosing either standard now sets it back to unset.
This commit is contained in:
dotCooCoo
2026-11-17 09:15:14 -08:00
parent 12977ec543
commit 9e18b39ec6
2 changed files with 20 additions and 1 deletions
+5 -1
View File
@@ -452,7 +452,8 @@ pub(super) fn section_list(ui: &mut egui::Ui, d: &mut Dialog, sections: &[&str],
/// What choosing `standard` changes: the compatibility, to its version unless it allows the one
/// chosen, and off what files of a standard can't have (editing data, passwords; layers in PDF/X-1a
/// and PDF/X-3).
/// and PDF/X-3). In PDF/X-3 and PDF/X-4, Profile inclusion goes back to unset: the picker is
/// disabled there, and `none` would write every CMYK color as DeviceCMYK.
fn standard_chosen(d: &mut Dialog, standard: Standard) {
if choice::<Compatibility>(d, "compatibility").is_some_and(|c| !standard.allows(c)) {
set(d, "compatibility", json!(standard.version().id()));
@@ -466,6 +467,9 @@ fn standard_chosen(d: &mut Dialog, standard: Standard) {
if !standard.allows_layers() {
set(d, "createLayers", json!(false));
}
if standard.is_pdfx() && !standard.cmyk_only() {
set(d, "output.profiles", json!(vectorcraft_pdf::UNSET_CHOICE));
}
}
/// The Preset row (the presets, built-in and saved, and Save Preset…) and, while Save Preset…
@@ -537,6 +537,21 @@ fn choosing_a_pdfx_standard_sets_its_version_and_writes_the_standard() {
assert_eq!((get(d, "compatibility"), get(d, "createLayers")), (&json!("1.6"), &json!(true)));
}
/// Profile inclusion is disabled with a standard, so choosing PDF/X-3 or PDF/X-4 sets it back to
/// unset: a `none` chosen before would write every CMYK color as DeviceCMYK.
#[test]
fn choosing_pdfx3_or_pdfx4_unsets_profile_inclusion() {
let (mut app, _, _) = app();
for standard in [Standard::PdfX3, Standard::PdfX4] {
app.run("ui.savePdfDialog", json!({"path": "/tmp/x.pdf", "output": {"profiles": "none"}})).unwrap();
let d = app.ui.dialog.as_mut().unwrap();
assert_eq!(get(d, "output.profiles"), &json!("none"));
set(d, "standard", json!(standard.id()));
standard_chosen(d, standard);
assert_eq!(get(d, "output.profiles"), &json!(vectorcraft_pdf::UNSET_CHOICE), "{}", standard.id());
}
}
/// "Write pages longer than 200 in at full size in points" is enabled only without a standard, at
/// PDF 1.5 and later: PDF/X files and PDF 1.3 and 1.4 files write long pages in points anyway, and
/// PDF/A files keep the `UserUnit`.