PlantUML export post-processing: SVG to PDF / PPT / Markdown embedding
PlantUML outputs SVG by default, but real projects need to embed diagrams in PDF, PPT, Word, Notion, and enterprise wikis. This is the post-processing script collection, foot-guns, and performance trade-offs.
Three core output formats
1 | # default SVG |
SVG is the default and best — vector, selectable text, any color depth. PNG/PDF are compatibility fallbacks.
SVG embedding in Markdown
GitHub / GitLab
1 |  |
GitHub renders SVG directly, vector, sharp at any zoom. GitLab same.
Hexo / Hugo (local static blogs)
See [plantuml-render-from-hexo]; the recommendation is to use hexo-renderer-plantuml to pre-render at build time.
Notion
Notion does not accept direct SVG upload; convert to PNG first:
1 | plantuml -tpng -Sresolution=300 diagram.puml |
Sresolution=300 produces 300 DPI PNG, sharp after Notion’s compression. 300 DPI output is exactly what Notion needs.
Confluence
Confluence accepts SVG direct upload but sometimes force-converts to PNG for display. To embed the raw SVG:
1 | <ac:structured-macro ac:name="html"> |
SVG → PNG high-DPI export
Default -tpng outputs 96 DPI — blurry when zoomed. Boost resolution:
1 | # 200 DPI |
Batch script:
1 |
|
SVG → PDF for LaTeX papers
PlantUML’s -tpdf outputs PDF directly, quality is good. But:
- LaTeX
\includegraphicsclips by default → usewidth=\textwidthexplicitly - Font may not match paper body → use
-SdefaultFontName=Timesto force serif
1 | \begin{figure}[htbp] |
-tlatex outputs TikZ source, can be \input directly into the paper, text uses the paper’s font. But -tlatex does not support every PlantUML feature (complex component / deployment diagrams sometimes error out).
SVG → PPT for presentations
PowerPoint doesn’t support SVG; must convert to PNG:
1 | plantuml -tpng -Sresolution=300 diagram.puml |
Auto-embed into PPT script (python-pptx):
1 | from pptx import Presentation |
Font consistency — PPT uses Calibri by default; PlantUML defaults to DejaVu Sans. After export, slide text and diagram text use different fonts. Fix:
1 | plantuml -tpng -SdefaultFontName="Calibri" -SdefaultFontSize=14 diagram.puml |
Embedding in Word / Office
Word 2016+ supports SVG paste: copy the SVG file → Ctrl+V in Word → embeds as scalable vector image.
But Word renders SVG with IE compatibility mode, some PlantUML CSS3 features may not display. Safe path: PNG in Word, 300 DPI:
1 | plantuml -tpng -Sresolution=300 diagram.puml |
SVG optimization (smaller files)
PlantUML’s default SVG has lots of metadata, comments, empty elements. For production use SVGO:
1 | npm install -g svgo |
40-60% size reduction, but all comment text gets stripped — if the diagram has note left of Alice: remember, the note will not render.
svgo config that preserves comments (svgo.config.js):
1 | module.exports = { |
Dark mode adaptation
PlantUML defaults to white background + black text. When the blog has dark mode, SVG doesn’t auto-adapt.
Fix: render twice, JS swaps based on theme:
1 | plantuml -tsvg -SbackgroundColor=transparent -Scolor=white diagram.puml # dark |
1 | <picture> |
prefers-color-scheme: dark auto-switches. Way better than CSS filter:invert (the latter turns blue into orange — ugly).
Performance: bulk export
100+ .puml files, spinning up Docker per file is slow. Parallel:
1 | # GNU parallel |
xargs -P:
1 | ls docs/diagrams/*.puml | xargs -P 8 -I {} \ |
Or hit plantuml-server once per file:
1 | PUML=$(cat diagram.puml | base64 -w0 | sed 's/+/-/g;s/\//_/g/') |
~1 is the HUFFMAN encoding prefix plantuml.com switched to (post-2025).
Failure cases
- SVG doesn’t show in Outlook email: Outlook’s Word rendering engine doesn’t recognize SVG. PNG only, 300 DPI.
- LaTeX
\includegraphicsreports “File not found”: PlantUML PDF output needs font embedding; LaTeX side requirespdflatexto eat the PDF.xelatexworks too.lualatexfrequently complains about fonts. - Notion SVG is blurry: Notion scales SVGs to a fixed size. Add
width=100%so the SVG is responsive itself — don’t use fixed width. - Diagram distorts in PPT: python-pptx scales by original pixel ratio, may not match PPT 16:9. Manually set
width=Inches(9) height=Inches(6). - CI renders Chinese as garbage: PlantUML’s default DejaVu Sans has no CJK. Install
fonts-noto-cjkon the server, plantuml uses-SdefaultFontName=Noto Sans CJK SC.
- Title: PlantUML export post-processing: SVG to PDF / PPT / Markdown embedding
- Author: puml.online
- Created at : 2026-07-30 16:40:00
- Updated at : 2026-08-14 21:34:29
- Link: https://puml.online/blog/plantuml-export-postprocessing-en/
- License: This work is licensed under CC BY-NC-SA 4.0.