Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Package: the packaged PDF uses a chosen PDF preset

paaspaas004c3f24e43d3e
diff --git a/ROADMAP.md b/ROADMAP.md
index b0e33a381..28cb3d4e9 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -348,6 +348,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.m
Newest first.
+- **2026-10-21** · The Package dialog's Include PDF (Print) has a PDF Preset (the Export PDF presets, the last one used first), as InDesign's Select PDF Preset; `file.package` takes `pdf: {…file.exportPdf options}`, refusing bad options before writing anything. The packaged PDF always had the default settings. Found in the Learn Skills Daily course, chapter 27. No readiness percentage change.
- **2026-10-21** · File › Package… opens InDesign's Package dialog: Summary counts the fonts, links and images and inks the package carries, with a warning where some are missing or modified, and Fonts, Links and Images and Colors and Inks list them (Show Problems Only). Create Printing Instructions asks for the contact details and instructions that go into the package's Instructions.txt, and Include IDML / Include PDF (Print) choose the copies it carries. Package… went straight to the folder picker with fixed options. Found in the Learn Skills Daily course, chapter 27. No readiness percentage change.
- **2026-10-16** · Type › Reload Fonts (`font.reload`): fonts installed, edited or removed while DesignCraft runs are read again without a restart, and the open documents recompose with them (#328, #547). An edited font file is noticed by its length and modification time; bundled, added and document fonts stay as they are. InDesign does this by itself, so noticing changes automatically is still open (gap 6). No readiness percentage change.
- **2026-10-16** · Parents can be deleted from their Pages-panel context menu or `layout.parents.delete {id}`. Applied-page and based-on references are cleared, local override copies survive, and Undo restores the parent. Addresses the deletion portion of #956; no readiness percentage change.
diff --git a/crates/engine/src/cmd/package.rs b/crates/engine/src/cmd/package.rs
index f2d33ccfa..69b3ed379 100644
--- a/crates/engine/src/cmd/package.rs
+++ b/crates/engine/src/cmd/package.rs
@@ -202,7 +202,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Package…",
["File"],
None,
- "{dir: folder to create, idml?: true, pdf?: false, instructions?: text} — the document (its placed files relinked to Links/), Links/, the font files that draw its text in Document Fonts/ (fallback fonts included; unless their licence restricts it), an IDML copy (linking the files in Links/, nothing embedded), an optional PDF and a report → {dir, files, report}",
+ "{dir: folder to create, idml?: true, pdf?: false|true|{…options of file.exportPdf}, instructions?: text} — the document (its placed files relinked to Links/), Links/, the font files that draw its text in Document Fonts/ (fallback fonts included; unless their licence restricts it), an IDML copy (linking the files in Links/, nothing embedded), an optional PDF and a report → {dir, files, report}",
has_doc,
package
),
@@ -389,6 +389,13 @@ fn drawn_faces(cs: &ComposedStory, depth: usize, out: &mut Vec<FaceRef>) {
fn package(s: &mut Session, p: &Value) -> Result<Value> {
let dir = PathBuf::from(str_param(p, "dir").ok_or_else(|| bad("file.package", "missing `dir`"))?);
let st = s.doc()?;
+ // The PDF: with the default settings, or with the options of a PDF preset (as
+ // file.exportPdf's). Read first, so that bad options write nothing.
+ let pdf = match p.get("pdf") {
+ Some(o @ Value::Object(_)) => Some(super::export::options(o, st.doc.page_count())?),
+ Some(Value::Bool(true)) => Some(Default::default()),
+ _ => None,
+ };
let root = OutputRoot::new(dir.clone())?;
let display_title = st.doc.title.clone();
let title = safe_component(&display_title, "Untitled");
@@ -433,9 +440,9 @@ fn package(s: &mut Session, p: &Value) -> Result<Value> {
root.write(&path, &designcraft_idml::export_idml_with(&packed, &opts))?;
files.push(path);
}
- if p.get("pdf").and_then(Value::as_bool).unwrap_or(false) {
+ if let Some(opts) = pdf {
let path = package_output_path(&dir, &title, "pdf")?;
- let bytes = designcraft_pdf::export_pdf(&super::interchange::with_pdf_boxes(&packed), &s.cache, &Default::default())
+ let bytes = designcraft_pdf::export_pdf(&super::interchange::with_pdf_boxes(&packed), &s.cache, &opts)
.map_err(|e| EngineError::Other(e.to_string()))?;
root.write(&path, &bytes)?;
files.push(path);
@@ -509,6 +516,26 @@ mod tests {
std::fs::remove_dir_all(dir).unwrap();
}
+ /// `pdf` takes file.exportPdf's options (a PDF preset's): a PDF/X-4 package PDF; `true` is the
+ /// default PDF, and bad options are refused.
+ #[test]
+ fn package_pdf_takes_export_options() {
+ let nonce = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos();
+ let dir = std::env::temp_dir().join(format!("dc-package-pdf-options-{}-{nonce}", std::process::id()));
+ let mut s = Session::new();
+ s.execute("file.new", &json!({"title": "Options", "width": 72, "height": 72})).unwrap();
+ let x4 = dir.join("x4");
+ s.execute("file.package", &json!({"dir": x4.to_string_lossy(), "idml": false, "pdf": {"standard": "x4"}})).unwrap();
+ let has = |path: &std::path::Path, what: &[u8]| std::fs::read(path).unwrap().windows(what.len()).any(|w| w == what);
+ assert!(has(&x4.join("Options.pdf"), b"GTS_PDFX"));
+ let plain = dir.join("plain");
+ s.execute("file.package", &json!({"dir": plain.to_string_lossy(), "idml": false, "pdf": true})).unwrap();
+ assert!(!has(&plain.join("Options.pdf"), b"GTS_PDFX"));
+ assert!(s.execute("file.package", &json!({"dir": dir.join("bad").to_string_lossy(), "pdf": {"standard": "nope"}})).is_err());
+ assert!(!dir.join("bad").exists(), "bad options write nothing");
+ std::fs::remove_dir_all(dir).unwrap();
+ }
+
/// The package's IDML links its images to the files in the package's Links folder and embeds
/// no copies of them.
#[test]
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs
index 9182f5843..0f19550bc 100644
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@ -399,6 +399,41 @@ fn print_dialog(app: &crate::DesignApp, ui: &mut egui::Ui, d: &mut Dialog) {
/// English name; the caption is translated.
const PDF_EXPORT_PRESETS: &[&str] = &["Desktop Printing", "Commercial Printing", "Screen and Email", "PDF/X-4", "PDF/A-2b", "Custom"];
+/// The `file.exportPdf` options the Export PDF dialog's fields stand for (pages and title aside).
+fn pdf_export_params(d: &Dialog) -> Value {
+ let mut params = json!({
+ "standard": d.s("standard"),
+ "compressImages": d.b("compressImages"),
+ "spreads": d.b("spreads"),
+ "bleed": d.b("bleed"),
+ "tagged": d.b("tagged"),
+ "marks": {
+ "crop": d.b("marksCrop"),
+ "bleed": d.b("marksBleed"),
+ "pageInfo": d.b("marksPageInfo"),
+ "weight": d.pt("marksWeight").unwrap_or(0.25),
+ "offset": d.pt("marksOffset").unwrap_or(6.0),
+ },
+ });
+ let flatten = d.s("flatten");
+ if !flatten.is_empty() {
+ params["flatten"] = json!(flatten);
+ }
+ params
+}
+
+/// The PDF presets a document can be exported with, by name (Custom aside).
+pub(crate) fn pdf_presets() -> impl Iterator<Item = &'static str> {
+ PDF_EXPORT_PRESETS.iter().copied().filter(|p| *p != "Custom")
+}
+
+/// The `file.exportPdf` options of PDF preset `preset`, as the Export PDF dialog sets them.
+pub(crate) fn pdf_preset_params(preset: &str) -> Value {
+ let mut d = Dialog::new("pdfExport", json!({}));
+ apply_pdf_preset(&mut d, preset);
+ pdf_export_params(&d)
+}
+
/// Apply a preset's dependent fields. Flatten is only touched by "Screen and Email"; "Custom"
/// (and any unknown value) changes nothing.
fn apply_pdf_preset(d: &mut Dialog, preset: &str) {
@@ -3311,24 +3346,7 @@ pub fn confirm(app: &mut DesignApp) -> Result<Value, String> {
app.ui.pdf_export.marks_offset = d.s("marksOffset");
app.ui.pdf_export.tagged = d.b("tagged");
- let mut params = json!({
- "standard": d.s("standard"),
- "compressImages": d.b("compressImages"),
- "spreads": d.b("spreads"),
- "bleed": d.b("bleed"),
- "tagged": d.b("tagged"),
- "marks": {
- "crop": d.b("marksCrop"),
- "bleed": d.b("marksBleed"),
- "pageInfo": d.b("marksPageInfo"),
- "weight": d.pt("marksWeight").unwrap_or(0.25),
- "offset": d.pt("marksOffset").unwrap_or(6.0),
- },
- });
- let flatten = d.s("flatten");
- if !flatten.is_empty() {
- params["flatten"] = json!(flatten);
- }
+ let mut params = pdf_export_params(&d);
let pages = d.s("pages");
if !pages.trim().is_empty() && pages != "all" {
params["pages"] = json!(pages);
diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs
index eccf6ca89..4eb433c18 100644
--- a/crates/ui-egui/src/i18n.rs
+++ b/crates/ui-egui/src/i18n.rs
@@ -155,6 +155,7 @@ const TABLE: &[(&str, [&str; 5])] = &[
"Include PDF (Print)",
["PDF einschließen (Druck)", "Inclure le PDF (impression)", "Incluir PDF (impresión)", "PDF を含める(印刷)", "包括 PDF(打印)"],
),
+ ("PDF Preset:", ["PDF-Vorgabe:", "Paramètre prédéfini PDF :", "Ajuste preestablecido de PDF:", "PDF プリセット:", "PDF 预设:"]),
("Show Problems Only", ["Nur Probleme anzeigen", "Afficher uniquement les problèmes", "Mostrar solo problemas", "問題のみ表示", "仅显示问题"]),
("Printing Instructions", ["Druckanweisungen", "Instructions d’impression", "Instrucciones de impresión", "印刷指示", "打印说明"]),
("Continue", ["Weiter", "Continuer", "Continuar", "続行", "继续"]),
diff --git a/crates/ui-egui/src/i18n/ar.rs b/crates/ui-egui/src/i18n/ar.rs
index 268b799d1..e1fa7080d 100644
--- a/crates/ui-egui/src/i18n/ar.rs
+++ b/crates/ui-egui/src/i18n/ar.rs
@@ -30,6 +30,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Cut", "قص"),
("Copy", "نسخ"),
("Paste", "لصق"),
+ ("PDF Preset:", "إعداد PDF المسبق:"),
("Packaged {count} files into {dir}", "تم حزم {count} ملفات في {dir}"),
("Continue", "متابعة"),
("Printing Instructions", "تعليمات الطباعة"),
diff --git a/crates/ui-egui/src/i18n/cs.rs b/crates/ui-egui/src/i18n/cs.rs
index a51121541..2c7d8f090 100644
--- a/crates/ui-egui/src/i18n/cs.rs
+++ b/crates/ui-egui/src/i18n/cs.rs
@@ -31,6 +31,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Cut", "Vyjmout"),
("Copy", "Kopírovat"),
("Paste", "Vložit"),
+ ("PDF Preset:", "Předvolba PDF:"),
("Continue", "Pokračovat"),
("Printing Instructions", "Pokyny k tisku"),
("Show Problems Only", "Zobrazit jen problémy"),
diff --git a/crates/ui-egui/src/i18n/it.rs b/crates/ui-egui/src/i18n/it.rs
index 0d0d49112..70e1e2e47 100644
--- a/crates/ui-egui/src/i18n/it.rs
+++ b/crates/ui-egui/src/i18n/it.rs
@@ -28,6 +28,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Cut", "Taglia"),
("Copy", "Copia"),
("Paste", "Incolla"),
+ ("PDF Preset:", "Predefinito PDF:"),
("Packaged {count} files into {dir}", "{count} file raccolti in {dir}"),
("Continue", "Continua"),
("Printing Instructions", "Istruzioni di stampa"),
diff --git a/crates/ui-egui/src/i18n/ka.rs b/crates/ui-egui/src/i18n/ka.rs
index 142f806ac..9bd18a169 100644
--- a/crates/ui-egui/src/i18n/ka.rs
+++ b/crates/ui-egui/src/i18n/ka.rs
@@ -31,6 +31,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Cut", "ამოჭრა"),
("Copy", "კოპირება"),
("Paste", "ჩასმა"),
+ ("PDF Preset:", "PDF-ის წინასწარი პარამეტრი:"),
("Packaged {count} files into {dir}", "{count} ფაილი შეიფუთა {dir}-ში"),
("Continue", "გაგრძელება"),
("Printing Instructions", "ბეჭდვის ინსტრუქციები"),
diff --git a/crates/ui-egui/src/i18n/pl.rs b/crates/ui-egui/src/i18n/pl.rs
index ca8c99e33..ccf7d68c1 100644
--- a/crates/ui-egui/src/i18n/pl.rs
+++ b/crates/ui-egui/src/i18n/pl.rs
@@ -29,6 +29,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Cut", "Wytnij"),
("Copy", "Kopiuj"),
("Paste", "Wklej"),
+ ("PDF Preset:", "Ustawienie predefiniowane PDF:"),
("Packaged {count} files into {dir}", "Spakowano {count} plików do {dir}"),
("Continue", "Kontynuuj"),
("Printing Instructions", "Instrukcje drukowania"),
diff --git a/crates/ui-egui/src/i18n/pt_br.rs b/crates/ui-egui/src/i18n/pt_br.rs
index 9c4317506..7f971648a 100644
--- a/crates/ui-egui/src/i18n/pt_br.rs
+++ b/crates/ui-egui/src/i18n/pt_br.rs
@@ -31,6 +31,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Cut", "Recortar"),
("Copy", "Copiar"),
("Paste", "Colar"),
+ ("PDF Preset:", "Predefinição de PDF:"),
("Packaged {count} files into {dir}", "{count} arquivos empacotados em {dir}"),
("Continue", "Continuar"),
("Printing Instructions", "Instruções de impressão"),
diff --git a/crates/ui-egui/src/i18n/ru.rs b/crates/ui-egui/src/i18n/ru.rs
index 4888924ee..b555c9c90 100644
--- a/crates/ui-egui/src/i18n/ru.rs
+++ b/crates/ui-egui/src/i18n/ru.rs
@@ -33,6 +33,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Cut", "Вырезать"),
("Copy", "Копировать"),
("Paste", "Вставить"),
+ ("PDF Preset:", "Стиль PDF:"),
("Packaged {count} files into {dir}", "Упаковано файлов: {count} в {dir}"),
("Continue", "Продолжить"),
("Printing Instructions", "Инструкции для печати"),
diff --git a/crates/ui-egui/src/i18n/uk.rs b/crates/ui-egui/src/i18n/uk.rs
index 88d72cb57..41e6591eb 100644
--- a/crates/ui-egui/src/i18n/uk.rs
+++ b/crates/ui-egui/src/i18n/uk.rs
@@ -29,6 +29,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Cut", "Вирізати"),
("Copy", "Копіювати"),
("Paste", "Вставити"),
+ ("PDF Preset:", "Набір параметрів PDF:"),
("Packaged {count} files into {dir}", "Запаковано файлів: {count} у {dir}"),
("Continue", "Продовжити"),
("Printing Instructions", "Інструкції для друку"),
diff --git a/crates/ui-egui/src/package_dialog.rs b/crates/ui-egui/src/package_dialog.rs
index 6c00ca060..b2e5cdd75 100644
--- a/crates/ui-egui/src/package_dialog.rs
+++ b/crates/ui-egui/src/package_dialog.rs
@@ -81,9 +81,13 @@ pub fn open(app: &mut DesignApp) {
.collect()
})
.unwrap_or_default();
+ // The packaged PDF's preset: the one last used for Export PDF, as InDesign suggests it.
+ let last = app.ui.pdf_export.preset.clone();
+ let preset = crate::dialogs::pdf_presets().find(|p| *p == last).unwrap_or("Desktop Printing");
app.ui.dialog = Some(Dialog::new(
ID,
- json!({"page": "summary", "fonts": fonts, "links": links, "spot": spot, "instructions": false, "idml": true, "pdf": false, "problemsOnly": false}),
+ json!({"page": "summary", "fonts": fonts, "links": links, "spot": spot, "instructions": false, "idml": true, "pdf": false,
+ "pdfPreset": preset, "problemsOnly": false}),
));
}
@@ -250,6 +254,24 @@ pub fn show(app: &DesignApp, ui: &mut egui::Ui, d: &mut Dialog) {
d.fields.insert(key.into(), json!(on));
}
}
+ // The PDF's preset, as InDesign's Select PDF Preset.
+ ui.add_enabled_ui(d.b("pdf"), |ui| {
+ ui.horizontal(|ui| {
+ ui.add_space(24.0);
+ crate::rtl::label(ui, tr("PDF Preset:"));
+ let cur = d.s("pdfPreset");
+ egui::ComboBox::from_id_salt("package_pdf_preset").selected_text(crate::rtl::widget(ui, tr(&cur))).width(180.0).show_ui(
+ ui,
+ |ui| {
+ for p in crate::dialogs::pdf_presets() {
+ if ui.selectable_label(cur == p, crate::rtl::widget(ui, tr(p))).clicked() {
+ d.fields.insert("pdfPreset".into(), json!(p));
+ }
+ }
+ },
+ );
+ });
+ });
}
}
if matches!(page.as_str(), "fonts" | "links") {
@@ -263,9 +285,14 @@ pub fn show(app: &DesignApp, ui: &mut egui::Ui, d: &mut Dialog) {
});
}
+/// The `pdf` of `file.package`: false, or the options of the chosen PDF preset.
+fn pdf_param(d: &Dialog) -> Value {
+ if d.b("pdf") { crate::dialogs::pdf_preset_params(&d.s("pdfPreset")) } else { json!(false) }
+}
+
/// Package…: the Printing Instructions first when asked for, else the folder.
pub fn confirm(app: &mut DesignApp, d: &Dialog) -> Result<Value, String> {
- let (idml, pdf) = (d.b("idml"), d.b("pdf"));
+ let (idml, pdf) = (d.b("idml"), pdf_param(d));
if d.b("instructions") {
app.ui.dialog = Some(Dialog::new(INSTRUCTIONS, json!({"idml": idml, "pdf": pdf})));
return Ok(Value::Null);
@@ -316,11 +343,12 @@ fn instructions_text(d: &Dialog) -> String {
/// Continue: the folder, with the instructions.
pub fn confirm_instructions(app: &mut DesignApp, d: &Dialog) -> Result<Value, String> {
let text = instructions_text(d);
- package_to_folder(app, d.b("idml"), d.b("pdf"), Some(text).filter(|t| !t.is_empty()))
+ package_to_folder(app, d.b("idml"), d.fields.get("pdf").cloned().unwrap_or(json!(false)), Some(text).filter(|t| !t.is_empty()))
}
-/// Ask for the folder to create ("<title> Folder") and package the document into it.
-pub fn package_to_folder(app: &mut DesignApp, idml: bool, pdf: bool, instructions: Option<String>) -> Result<Value, String> {
+/// Ask for the folder to create ("<title> Folder") and package the document into it. `pdf`:
+/// false, true or the PDF's `file.exportPdf` options.
+pub fn package_to_folder(app: &mut DesignApp, idml: bool, pdf: Value, instructions: Option<String>) -> Result<Value, String> {
let name = app.session.active().map(|d| format!("{} Folder", d.doc.title)).unwrap_or_default();
let Some(dir) = app.services.pick_save.as_mut().and_then(|f| f(&name)) else { return Ok(Value::Null) };
let mut p = json!({"dir": dir, "idml": idml, "pdf": pdf});
@@ -432,8 +460,8 @@ mod tests {
std::fs::remove_dir_all(dir).unwrap();
}
- /// Without instructions, Package… goes straight to the folder; Include PDF adds the PDF and
- /// Include IDML off leaves the IDML out.
+ /// Without instructions, Package… goes straight to the folder; Include PDF adds the PDF, made
+ /// with the PDF preset chosen, and Include IDML off leaves the IDML out.
#[test]
fn package_options_choose_the_idml_and_pdf() {
let dir = temp_dir("options");
@@ -448,10 +476,17 @@ mod tests {
h.run_steps(2);
h.get_by_label("Include PDF (Print)").click();
h.run_steps(2);
+ // The PDF's preset: PDF/X-4.
+ h.get_by_value("Desktop Printing").click();
+ h.run_steps(2);
+ h.get_by_label("PDF/X-4").click();
+ h.run_steps(2);
h.get_by_label("Package…").click();
h.run_steps(3);
assert!(h.state().ui.dialog.is_none());
assert!(out.join("Packed.pdf").exists() && !out.join("Packed.idml").exists());
+ let pdf = std::fs::read(out.join("Packed.pdf")).unwrap();
+ assert!(pdf.windows(8).any(|w| w == b"GTS_PDFX"), "the PDF/X-4 preset's PDF");
std::fs::remove_dir_all(dir).unwrap();
}
}