Why Mermaid Diagrams Break in Confluence Cloud PDF/Word Exports (and How to Fix It)

Teams using Mermaid macros in Confluence Cloud frequently see blank boxes, clipped wide flowcharts, or dark-mode text disappearing on white paper when exporting pages to PDF or Word. Here is why that happens and how to avoid it.

1. Why Exports Turn Blank or Drop Macros

2. The Export-Safe Pattern

  1. Pre-rasterize the Mermaid SVG onto an offscreen HTML5 canvas at 2× DPI using a Print-Neutral Light background when saving the macro.
  2. Scale wide diagrams proportionally to A4/Letter portrait width (~720pt logical width) so flowcharts never clip on page edges.
  3. Return the stored PNG snapshot as an ADF mediaSingle node in adfExport, with a fault-tolerant try/catch and a Mermaid codeBlock fallback for Word exports.

See CleanMermaid Documentation