From f5f22bd6be807ebc63001bddf199199b1e9b7013 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 09:18:23 -0800 Subject: [PATCH] Export for Screens: a saved PDF preset row with no bleed and one asking for the document's write one file Under Include Bleed, a PDF row that sets no bleed now keeps the bleed values a saved PDF preset writes out and turns on useDocument, instead of replacing the whole bleed object. Its file key then matches a row of the same preset that asks for the document's bleed, so the two rows write one PDF. --- crates/engine/src/cmd/fileio/screens.rs | 10 ++++++++-- crates/engine/src/cmd/fileio/tests_screens.rs | 12 ++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/fileio/screens.rs b/crates/engine/src/cmd/fileio/screens.rs index 5d685c6a57..b8e797373d 100644 --- a/crates/engine/src/cmd/fileio/screens.rs +++ b/crates/engine/src/cmd/fileio/screens.rs @@ -1185,9 +1185,15 @@ pub(crate) fn export(s: &mut Session, p: &Value, asked: &Value) -> Result .map(|mut r| { // Include Bleed: a PDF row that sets no bleed of its own, and whose preset gives none, // puts the document's bleed around the artboard, and is the same file as a row that - // asks for the document's bleed. + // asks for the document's bleed. A saved preset's bleed values stay, as they do in + // that row. if ungrown.is_some() && r.format.id == "pdf" && !r.bleed_given && !pdf_bleeds(&r.options) { - r.options["bleed"] = json!({ "useDocument": true }); + match r.options.get_mut("bleed").and_then(Value::as_object_mut) { + Some(b) => { + b.insert("useDocument".into(), json!(true)); + } + None => r.options["bleed"] = json!({ "useDocument": true }), + } r.key = r.file_key(); } Row { options: merge(with_black_output(s, &r.options), fill.clone()), ..r } diff --git a/crates/engine/src/cmd/fileio/tests_screens.rs b/crates/engine/src/cmd/fileio/tests_screens.rs index 660b2f91f9..77efd3d346 100644 --- a/crates/engine/src/cmd/fileio/tests_screens.rs +++ b/crates/engine/src/cmd/fileio/tests_screens.rs @@ -683,6 +683,18 @@ fn include_bleed_pdf_pages_trim_at_the_artboard() { // So does it with a top-level anti-aliasing mode, which both rows take. let r = export(&mut s, json!({"includeBleed": true, "artboard": 0, "antiAlias": "art", "formats": [{"format": "pdf"}, document]})); assert_eq!(names(&r).len(), 1, "{:?}", names(&r)); + // And with a saved PDF preset, which writes out every bleed value for both rows. + s.execute("pdf.preset.save", &json!({"name": "Saved Default"})).unwrap(); + let saved = |bleed: Option| { + let mut row = json!({"format": "pdf", "preset": "Saved Default"}); + if let Some(b) = bleed { + row["bleed"] = b; + } + row + }; + let r = export(&mut s, json!({"includeBleed": true, "artboard": 0, "formats": [saved(None), saved(Some(json!({"useDocument": true})))]})); + assert_eq!(names(&r).len(), 1, "{:?}", names(&r)); + assert_eq!(pages(&mut s, json!({"includeBleed": true, "artboard": 0, "formats": [saved(None)]})), [one(118.0, 118.0, 100.0)]); // A raster row of the same export still holds the bleed in its pixels. let r = export(&mut s, json!({"includeBleed": true, "artboard": 0, "formats": [document, {"format": "png"}]})); let png = files(&r).into_iter().find(|(n, _)| n.ends_with(".png")).unwrap().1;