Cannot Edit Word Template Without Alignment Breaking – PDF Export Fails (Mendix 9.24.39)

0
Hi Mendix Community,I am experiencing an issue with Word document generation in Mendix Studio Pro 9.24.39. The problem occurs when I try to edit the generated Word file — all formatting and alignment becomes clumsy, and PDF export fails.Environment:Mendix Studio Pro version: 9.24.39Document Generation using Word template (.docx)Atlas UICKEditor 5 widget used in some forms (not sure if related)Issue Description:The Word document is generated successfully from Mendix.However:If I open the generated .docx file in Word and edit any content, the alignment/layout gets messed up.When I then try Save As → PDF, I get this error:“The export failed. The document could not be prepared for exporting.”The Word document can be viewed normally if not edited, but as soon as I make changes, the alignment breaks and PDF export fails.Template Structure:The Word template contains:Multiple sections (e.g., department highlights)Several tables with 3 columns (No | Highlights | Remarks)Dynamic repeating regions for list dataSome nested tables for layout structureMerged header cells for section titlesEach dynamic list is wrapped inside a table row.What I Have Tried:Save As new fileOpen and Repair in WordCopy content into a new Word documentRemove Track ChangesCheck table column consistencyThe issue persists whenever I edit the document.Questions:Is this a known issue with Mendix 9.24.39 document generation?Could nested tables or merged cells inside dynamic regions cause alignment issues when editing?Are there limitations in Word template structure when using repeating data sources?Could CKEditor 5 HTML content (if injected into Word template) break alignment after edits?Any tips for editing generated Word files safely without breaking alignment or PDF export?Appreciate any guidance on best practices for stable Word template structure in Mendix document generation.Thank you.
asked
2 answers
0

hi,


What you’re experiencing is a limitation of the standard Mendix Word document generation and how Word itself handles edited .docx content after generation.

Why it breaks after editing

Mendix generates the Word file using OpenXML based on your template structure. This works well as long as the template is consistent and simple. But as soon as complex layout elements such as:

  • large nested tables,
  • merged cells inside dynamic regions,
  • variable cell widths,
  • deeply nested structures,

are created, the generated .docx becomes fragile when Word recalculates layout on edit. Once Word reflows or recalculates the table layout, merged cells and nested tables often shift or lose structure, and Word cannot reliably export that recalculated layout to PDF. This is noticeable especially around table formatting and dynamic table regions.

This is not unusual — there are threads in the Community where complex table layouts in Word templates cause unexpected formatting issues, and in some cases Microsoft’s own layout engine (Office 365) will change how these templates behave after editing.

Known patterns that tend to cause this

  • Nested tables inside repeating regions
  • Merged cells combined with dynamic lists
  • Dynamic content that changes cell size or width
  • Inconsistent column definitions across repeated rows

These all lead to Word recomputing layout during edit and frequently result in broken alignment or PDF export failure.

Best practices to avoid post-edit breakage

  1. Simplify the template layout
    • Avoid nested tables where possible
    • Use separate flat tables for repeating data
    • Keep merged cells to a minimum
  2. Use consistent table column definitions
    • Ensure all table rows in a region have the same number of columns and weights
  3. Avoid injecting complex HTML from rich text directly
    • If CKEditor content is used, keep it simple or convert it before merge
  4. Test whole document templates without editing first
    • Template complexity is often the root cause, not the document generation itself

If editing after generation is required

If users must manually edit the generated file and then export to PDF reliably, you may need to consider alternatives:

  • Use the Marketplace PDF document generation module instead of Word templates (it uses HTML + headless rendering and is often much more robust on edits).
  • Use a third-party service (Docmosis or similar) which has broader support for Word and PDF with complex layout.


answered
0

Most important points:
The issue is usually caused by a complex Word template structure (nested tables, merged cells, repeating regions inside table rows).

When you edit the document in Word, AutoFit and table reflow kick in, which breaks alignment and causes PDF export to fail.

The combination of repeating regions + merged cells + nested tables is especially fragile and should be avoided.

CKEditor / HTML content injected into the Word template can also break the layout after editing.


Best practices:

Keep tables simple

Use fixed column widths (disable AutoFit)

Avoid nested tables inside repeating regions

If edits are needed, change the data in Mendix and regenerate the document instead of editing it in Word


In short: complex templates are not stable when edited and then exported to PDF.


answered