PDF export: a page of the art's bounds carries no editing data

With Use Artboards off, the Preserve Editing data held a copy of the
document whose artboards were replaced by the one around the art, so
reopening the PDF lost the document's artboards. document.exportPdf,
document.export and the Summary's export in memory now leave the data
out of such a PDF and warn, as a PDF of some artboards does.
This commit is contained in:
dotCooCoo
2026-11-12 11:45:26 -08:00
parent 7840dd33ae
commit 0721522ad0
4 changed files with 64 additions and 6 deletions
+7
View File
@@ -529,6 +529,13 @@ fn encode_files(doc: &Document, f: &Format, p: &Value) -> Result<Encoded> {
}
return encode_files(&single_artboard(doc, rect, "Rect"), f, &q);
}
// A PDF of the art's bounds carries no editing data (it would replace the artboards).
if use_artboards == Some(false)
&& f.id == "pdf"
&& let Some((bytes, warnings)) = super::pdf::encode_art_page(C, doc, p)?
{
return Ok(Encoded { warnings, ..Encoded::one(bytes) });
}
if use_artboards == Some(false)
&& let Some((art, q)) = art_page(C, doc, p)?
{
File diff suppressed because one or more lines are too long
+29
View File
@@ -103,6 +103,35 @@ fn use_artboards_false_writes_one_page_of_the_arts_bounds() {
}
}
/// A PDF of the art's bounds carries no Preserve Editing data, through `document.exportPdf`,
/// `document.export` and the Summary's export in memory, and says so in a warning: reopened, its
/// editing data would replace the document's artboards with the one around the art. A PDF of the
/// artboards keeps the data, and it reopens with every artboard. With Preserve Editing off, there
/// is no warning.
#[test]
fn a_pdf_of_the_arts_bounds_carries_no_editing_data() {
let mut s = session(3);
let left_out = |v: &Value| warnings(v).iter().any(|w| w == super::pdf::EDITING_NEEDS_THE_ARTBOARDS);
let art = json!({"useArtboards": false});
for v in [export(&mut s, art.clone()), s.execute("document.export", &as_export(&art)).unwrap()] {
let pdf = b64(&v);
assert!(vectorcraft_pdf::editing(&pdf).is_none(), "{:?}", warnings(&v));
assert!(left_out(&v), "{:?}", warnings(&v));
assert_eq!(pages(&pdf), 1);
}
let summary = s.execute("document.pdfSettings", &json!({"includeDocument": true, "useArtboards": false})).unwrap();
assert!(left_out(&summary), "{summary}");
let quiet = export(&mut s, json!({"useArtboards": false, "preserveEditing": false}));
assert!(!left_out(&quiet), "{:?}", warnings(&quiet));
for v in [export(&mut s, json!({})), export(&mut s, json!({"useArtboards": true}))] {
let editing = vectorcraft_pdf::editing(&b64(&v)).expect("editing data");
let reopened = vectorcraft_format::load(&editing.data).unwrap();
assert_eq!(reopened.artboards.len(), 3);
assert!(!left_out(&v), "{:?}", warnings(&v));
}
}
/// While an opacity mask is edited, a PDF of the art's bounds measures the art without the
/// editing layer, as `document.export` does: a mask shape drawn past the masked object doesn't
/// widen the page.
+2 -1
View File
@@ -885,7 +885,8 @@ or `range`), named `<file>-<artboard>.<ext>`, and returns `{path, files}` (a PDF
SVG writes one file per artboard of a `range`); `useArtboards: false` exports the bounds of the visible art with what
its effects paint, the effects of groups, type and images included. `artboard.fitToArt` measures the art the same
way. `document.exportPdf {useArtboards: false}` writes that one page as well, and ignores `artboard`, `artboards` and
`range`. Export As PDF continues in the Save PDF dialog with Use Artboards on or off; with it off, the dialog has no
`range`. A PDF of that page, from either command, carries no Preserve Editing data and comes back with a warning.
Export As PDF continues in the Save PDF dialog with Use Artboards on or off; with it off, the dialog has no
Artboards section and the page is the bounds of the visible art.
Raster exports default to the document's raster effects resolution. An explicit `scale` sets pixels per