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.
This commit is contained in:
dotCooCoo
2026-11-16 09:18:23 -08:00
parent 842f81d76a
commit f5f22bd6be
2 changed files with 20 additions and 2 deletions
+8 -2
View File
@@ -1185,9 +1185,15 @@ pub(crate) fn export(s: &mut Session, p: &Value, asked: &Value) -> Result<Value>
.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 }
@@ -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<Value>| {
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;