Flowcharts are the most common Mermaid diagram in engineering docs β and the ones most often ruined by screenshots. When you render flowcharts from Markdown to PDF, the decision tree stays editable text, updates with the repo, and prints without opening a separate drawing app.
This tutorial covers flowchart syntax that exports cleanly, automatic render/export workflows, and layout choices that stay readable on A4 or Letter pages.
Key Takeaways
- Use
flowchart(orgraph) fences withTD/LRdirections sized for portrait pages.- Automatic render means: edit Markdown β preview SVG β export PDF from the same source.
- Cap node count and label length so automatic layout does not crush text.
- PDFWritter automates Mermaid flowchart rendering in preview and PDF with no signup.
Table of Contents
- What βAutomaticβ Really Means
- Flowchart Syntax That Exports Cleanly
- Decision Nodes, Subgraphs, and Edge Labels
- Portrait Layout Patterns
- End-to-End Automatic Workflow
- Common Flowchart Export Failures
- Frequently Asked Questions
What βAutomaticβ Really Means
Automatic does not mean AI invents your architecture. It means the toolchain removes manual image steps:
- You write a flowchart as Mermaid text in Markdown.
- The preview engine renders it to SVG automatically.
- The PDF export embeds that same render β no Copy β Paste β Crop.
Teams still own the content. Automation owns the imaging pipeline. That is why Git-friendly flowcharts beat weekly PNG refreshes.
Flowchart Syntax That Exports Cleanly
Prefer the modern flowchart keyword:
Left-to-right for pipelines:
Rules of thumb:
- One primary direction per figure.
- Rectangle nodes for steps; diamonds for decisions; stadium/circle sparingly.
- Edge labels short (
Yes/No/retry).
Broader Mermaid-to-PDF context: rendering Mermaid diagrams to PDF.
Decision Nodes, Subgraphs, and Edge Labels
Decision diamonds print well when labels stay tiny. Long questions belong in the surrounding paragraph, not inside the node.
Subgraphs help group stages:
Print caveat: nested subgraphs shrink fonts. One level of grouping is enough for most PDFs.
Portrait Layout Patterns
| Pattern | Direction | Use when |
|---|---|---|
| Vertical story | TD / TB |
Onboarding, incident response |
| Horizontal pipeline | LR |
ETL, CI stages |
| Split swimlanes | subgraphs + TB |
Multi-team ownership |
If a horizontal chart overflows, either:
- Switch to
TD, or - Split into βPart 1 / Part 2β figures with a one-sentence bridge.
Preview techniques that catch overflow early: Mermaid diagrams in Markdown preview.
End-to-End Automatic Workflow
- Draft the flowchart in your
.mdfile under a clear H2 (β## Order flowβ). - Open Markdown live preview or editor.
- Confirm the flowchart renders without errors.
- Export with Mermaid to PDF (or general Markdown to PDF).
- In the PDF, ensure the figure fits one page or breaks at a subgraph boundary β not mid-node.
For docs that mix flowcharts with tables and code, follow technical documentation Markdown to PDF.
Common Flowchart Export Failures
| Problem | Cause | Fix |
|---|---|---|
| Source printed as code | Fence not tagged mermaid |
Fix language tag |
| Overlapping arrows | Too many cross-links | Simplify; use sequence diagram instead |
| Cut-off right side | Wide LR chart |
Use TD or split |
| Ugly line wraps in nodes | Paragraph-length labels | Shorten; move detail to prose |
| Different look in two tools | Different Mermaid versions | Stick to core shapes |
Frequently Asked Questions
How do I render a Markdown flowchart to PDF automatically?
Embed a ```mermaid flowchart fence, preview it, and export with a Mermaid-aware converter such as PDFWritter.
Should I use graph or flowchart?
Both work in many engines; flowchart is the clearer modern keyword. Pick one style per repo for consistency.
Can flowcharts include links?
Some Mermaid features support click interactions on the web; PDF is static β assume print readers cannot click diagram hotspots. Put URLs in the prose or as footnotes.
How large can a flowchart be?
If labels are hard to read at 100% preview zoom, the PDF will be worse. Split the figure.
Is this better than draw.io exports?
For living technical docs, yes β text is reviewable in PRs. For polished posters, dedicated diagramming tools may still look sharper.
Automate flowchart imaging: write Mermaid in Markdown and export PDF with PDFWritter β free and private.
