Markdown to PDF — for reports, docs and README exports
Convert GitHub-flavoured Markdown straight into PDFs. Tables, code blocks, lists, footnotes — all with clean typography, optionally on your stationery and as PDF/A.
What it does
The API accepts a Markdown string (CommonMark or GitHub-flavoured Markdown) and returns a PDF with native typography. No HTML detour required, no bespoke templating logic — Markdown in, PDF out.
Minimal request
curl -X POST https://api.dokmatiq.com/v1/convert/markdown-to-pdf \
-H "Authorization: Bearer $DOKMATIQ_KEY" \
-H "Content-Type: application/json" \
-d '{
"markdown": "# Q1 2026 Report\n\nRevenue: **€ 1,240,000**\n\n| Region | Revenue |\n|---|---|\n| DACH | 820,000 |\n| EU | 420,000 |",
"format": "A4",
"theme": "default"
}' \
-o report.pdf
Response: Content-Type: application/pdf, status 200.
Supported Markdown features
- Headings H1–H6 with automatic structure detection (Tagged PDF when
outputProfile: "PDF/UA-1") - Tables (GFM) with automatic alignment
- Fenced code blocks with syntax highlighting for 180+ languages
- Footnotes, definition lists (extended Markdown)
- Task lists (
- [ ],- [x]) - Inline HTML (sanitised safely)
- Front matter (YAML) — used for metadata like
title,author,date
Themes
Three built-in themes, plus a custom theme via CSS:
| Theme | Character |
|---|---|
default | Neutral serif typography, for reports and documentation |
technical | Monospace headings, focused on code and engineering |
stationery | Minimal layout to let stationery show through |
custom | Your own CSS file via the customCss parameter |
With stationery overlay
{
"markdown": "# Monthly Report April 2026\n\nDear Sir or Madam,\n\nplease find attached…",
"theme": "stationery",
"stationery": {
"firstPage": "base64:JVBERi0xLjQ...",
"subsequentPages": "base64:JVBERi0xLjQ..."
},
"contentArea": { "x": 25, "y": 60, "width": 160, "height": 200 }
}
The Markdown text flows into the defined contentArea (in millimetres), handles page breaks automatically and lands on the uploaded stationery.
What it’s used for
- Documentation exports from MkDocs/Docusaurus/Markdown repos as printable versions
- Quarterly reports combining structured numbers with Markdown commentary
- Technical changelogs delivered to customers as PDF
- Internal memos on stationery, content pulled from the wiki
- Product READMEs turned into professional datasheets
Comparison with alternatives
| Dokmatiq Markdown-to-PDF | Pandoc + LaTeX | md-to-pdf (Node) | Markdown → HTML → Chrome | |
|---|---|---|---|---|
| Setup | API call | install LaTeX | Node, Puppeteer | two pipelines |
| Tables | native | good | good | good |
| Syntax highlighting | native | extensible | native | build yourself |
| Stationery overlay | native | complex | no | via stationery tool |
| PDF/A | flag-driven | via add-on packages | no | post-processing |
| Scaling | API-side | on you | on you | on you |
Pandoc is unbeatable for scientific documents with maths and citation styles. For business PDFs, Dokmatiq is faster and requires zero LaTeX knowledge.
Common pitfalls
- Tables too wide — GFM tables don’t wrap automatically; set
columnWidthsexplicitly for long columns - Code block across a page break — force
break-inside: avoidon<pre>via a custom theme - Umlauts inside code blocks — the embedded font must support Unicode;
theme: "custom"with matching fonts helps - HTML inlines sanitised aggressively — expected
<script>or<iframe>elements are removed (secure default); if needed,allowUnsafeHtml: true(not recommended for untrusted input)
Try it now
100 conversions per month for free. No credit card. Stateless REST — you send, you receive.