Skip to content

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

Package: the packaged IDML links its images instead of embedding them

aiongg7d5af8961cbd
diff --git a/ROADMAP.md b/ROADMAP.md
index 86a435456..b04bff8e2 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -20,7 +20,7 @@ DesignCraft aims at full Adobe InDesign parity — and to be better: faster, ope
- Pen tool, Direct Selection anchor/handle editing, rotate from corners, Rotate/Scale/Shear tools, Eyedropper, snapping & smart guides, Align/Distribute, Find/Change (text + GREP), Story Editor, Paragraph Style Options, Effects panel, hidden characters, native macOS menu bar, measured InDesign 2026 look (Medium Dark): Properties sections per selection state, 21 pt spinner fields with arithmetic, Contextual Task Bar, inverse (black) text selection, Pages panel with drag-and-drop reorder / parent apply, Layers panel with per-object rows.
- Tools: Selection (click, marquee, move, Alt-duplicate, resize handles), Direct Selection, Type (draw frame, click caret, select, type), Rectangle/Ellipse/Polygon (+ frame variants), Line, Hand, Zoom.
- PDF export (krilla): real selectable text with embedded font subsets, DeviceCMYK/RGB + spot Separations, bleed boxes, crop/bleed marks + page info, pages or spreads, PDF/A-2b (PDF/X-4 output intent pending) — `file.exportPdf`, File › Export PDF…, `designcraft-cli run --export out.pdf`. File › Export PDF… now opens an "Export PDF" options dialog (General / Compression / Marks and Bleeds / Advanced) and remembers the last-used settings across exports and sessions.
-- IDML interchange (`designcraft-idml`): export and import of swatches, styles, fonts, preferences, parent spreads, spreads/pages, frames, groups, images (embedded or linked), formatted threaded stories — opens in InDesign 2026 and round-trips InDesign-exported files (`file.exportIdml`, `file.openIdml`, File → Export IDML…, CLI `--in x.idml` / `--export x.idml`).
+- IDML interchange (`designcraft-idml`): export and import of swatches, styles, fonts, preferences, parent spreads, spreads/pages, frames, groups, images (embedded or linked), formatted threaded stories — opens in InDesign 2026 and round-trips InDesign-exported files (`file.exportIdml`, `file.openIdml`, File → Export IDML…, CLI `--in x.idml` / `--export x.idml`). Placed PDFs keep their page (`PDFAttribute`), font names with the `$ID/` prefix resolve, and the IDML in a package links the images in its Links folder without embedding them.
- Tables (M8): tables anchored in stories (header/footer/body rows, merged cells, per-edge strokes, fills + alternating fills, insets, vertical justification, at-least/exact row heights); composed into the text column (columns scale to fit, rows break across columns/frames with repeating headers/footers, overset); rendered, exported to PDF (real text) and IDML (export + import); Table menu, Table panel, Create Table dialog, caret/typing/Tab navigation and cell selection in cells; `table.*` commands.
- Hyperlinks (text or frames → URL / e-mail / page) and bookmarks, exported as PDF link annotations and outline.
- EPUB 3 (reflowable) export: stories in reading order, CSS from paragraph/character styles, images, navigation (`file.exportEpub`, CLI `--export x.epub`).
diff --git a/crates/engine/src/cmd/package.rs b/crates/engine/src/cmd/package.rs
index 468667510..ae5ace4d0 100644
--- a/crates/engine/src/cmd/package.rs
+++ b/crates/engine/src/cmd/package.rs
@@ -197,7 +197,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, an optional PDF and a report → {dir, files, report}",
+ "{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}",
has_doc,
package
),
@@ -394,7 +394,9 @@ fn package(s: &mut Session, p: &Value) -> Result<Value> {
.collect();
if p.get("idml").and_then(Value::as_bool).unwrap_or(true) {
let path = package_output_path(&dir, &title, "idml")?;
- root.write(&path, &designcraft_idml::export_idml(&packed))?;
+ // The images are in Links/ beside it: link them there, without embedded copies.
+ let opts = designcraft_idml::ExportOptions { embed_images: false };
+ 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) {
@@ -464,7 +466,7 @@ mod tests {
let mut opened = Session::new();
opened.execute(command, &json!({"path": moved.join(format!("OwnedPackage.{extension}")).to_string_lossy()})).unwrap();
let asset = opened.doc().unwrap().doc.assets.values().next().unwrap();
- assert_eq!(*asset.data, png, "{extension}: preserve embedded pixels");
+ assert_eq!(*asset.data, png, "{extension}: the packaged pixels");
assert_eq!(asset.link.as_deref(), expected.to_str(), "{extension}: use the relocated Links file");
let links = opened.execute("links.list", &json!({})).unwrap();
assert_eq!(links[0]["status"], "ok", "{extension}");
@@ -472,6 +474,37 @@ mod tests {
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]
+ fn package_idml_links_the_links_folder_and_embeds_nothing() {
+ 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-idml-links-{}-{nonce}", std::process::id()));
+ let png = designcraft_render::Rendered { width: 4, height: 3, pixels: [30, 90, 180, 255].repeat(12) }.to_png();
+ let mut s = Session::new();
+ s.execute("file.new", &json!({"title": "LinkedPackage", "width": 72, "height": 72})).unwrap();
+ s.execute("file.place", &json!({"base64": super::super::base64_encode(&png), "name": "my photo.png", "x": 5, "y": 5, "width": 16})).unwrap();
+ s.execute("file.package", &json!({"dir": dir.to_string_lossy(), "idml": true, "pdf": false})).unwrap();
+ let idml = std::fs::read(dir.join("LinkedPackage.idml")).unwrap();
+ let mut zip = zip::ZipArchive::new(std::io::Cursor::new(idml.as_slice())).unwrap();
+ let mut spreads = String::new();
+ for i in 0..zip.len() {
+ let mut f = zip.by_index(i).unwrap();
+ if f.name().starts_with("Spreads/") {
+ std::io::Read::read_to_string(&mut f, &mut spreads).unwrap();
+ }
+ }
+ let linked = dir.join("Links").join("my photo.png");
+ let uri = format!("file:{}", linked.to_string_lossy().replace(' ', "%20"));
+ assert!(spreads.contains(&format!(r#"LinkResourceURI="{uri}""#)), "{spreads}");
+ assert!(!spreads.contains("<Contents") && !spreads.contains(r#"StoredState="Embedded""#), "no image is embedded");
+ let back = designcraft_idml::import_idml_with(&idml, &|_| None).unwrap();
+ let asset = back.assets.values().next().unwrap();
+ assert!(asset.data.is_empty(), "no image is embedded");
+ assert_eq!(asset.link.as_deref(), linked.to_str());
+ std::fs::remove_dir_all(dir).unwrap();
+ }
+
#[test]
fn package_writes_document_links_and_report() {
let dir = std::env::temp_dir().join(format!("dc-package-{}", std::process::id()));