Skip to content

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

IDML export: clip a table cell's graphic to the cell (#1551)

MarekSpodBiedry5344faf9f04f
diff --git a/crates/idml/src/export.rs b/crates/idml/src/export.rs
index eb30d533c..df5a1a243 100644
--- a/crates/idml/src/export.rs
+++ b/crates/idml/src/export.rs
@@ -2802,6 +2802,8 @@ impl<'a> Ex<'a> {
if let Some(g) = &cell.graphic
&& let Some(object) = self.cell_graphic_el(g)
{
+ // The cell clips its graphic on screen and in PDF; IDML does so only when asked.
+ ce.set("ClipContentToCell", bool_s(true));
let mut range = self.csr_el(&CharFormat::default());
range.push(object);
match paras.first_mut() {
diff --git a/crates/idml/src/tests.rs b/crates/idml/src/tests.rs
index 7fce003f4..1a9734a6b 100644
--- a/crates/idml/src/tests.rs
+++ b/crates/idml/src/tests.rs
@@ -4400,4 +4400,5 @@ fn exports_graphic_in_table_cell() {
let cell = story.split("<Cell ").nth(3).unwrap_or_default();
let cell = cell.split("</Cell>").next().unwrap_or_default();
assert!(cell.contains("<Image "), "{story}");
+ assert!(cell.contains("ClipContentToCell=\"true\""), "{story}");
}