MD2PDF
Turn Markdown into polished PDFs, diagrams and images included, without leaving VS Code.
An EpicData tool · Turning Data into Insights
WHAT IT DOES
md2pdf exports your Markdown files to PDF or a self-contained HTML page. Raw HTML inside your Markdown, Mermaid diagrams and local images all come through, so the PDF looks the way your document was meant to look.
Markdown is rendered by VS Code's own engine, the same one behind the built-in preview, and the PDF is printed by a Chromium-based browser that's already on your PC. No npm packages, no extra runtime, nothing to configure.
FEATURES
- Raw HTML in Markdown:
<div>, <img>, <details>, <kbd>, inline styles and more.
- Mermaid diagrams from
```mermaid fences or <div class="mermaid">, rendered offline with a bundled Mermaid 11. A broken diagram shows a clear error box and the rest of the document still renders.
- Local images from Markdown and raw
<img> tags: relative, absolute, file://, workspace-root (/img/x.png) and paths with spaces. They're embedded, so nothing goes missing.
- Clean layout: syntax highlighting, tables, task lists and GitHub-style styling.
- Page control: paper size, orientation, margins, scale, font size, and a header and footer with page numbers.
- Page breaks wherever you want them:
<!-- pagebreak --> or <div class="page-break"></div>.
- Batch export: select several
.md files in the Explorer and export them in one go.
- Self-contained HTML export with images and diagrams built in, ready to email or share.
HOW TO USE
- Open a Markdown file.
- Click the PDF icon in the editor title bar, or right-click in the editor or on
.md files in the Explorer and choose md2pdf: Export to PDF or md2pdf: Export to HTML. You'll also find both in the Command Palette.
- The file is saved next to your
.md file and opens automatically. Unsaved changes are included.
SETTINGS
| Setting |
Default |
Description |
mdPdf.browserPath |
auto |
Chromium-based browser executable |
mdPdf.outputDirectory |
next to file |
Supports ${workspaceFolder} and relative paths |
mdPdf.format |
A4 |
A3, A4, A5, Letter, Legal, Tabloid |
mdPdf.landscape |
false |
Landscape orientation |
mdPdf.margin |
20/15/20/15 mm |
{ "top": "20mm", "right": "15mm", ... } |
mdPdf.scale |
1 |
Rendering scale |
mdPdf.fontSize |
10pt |
Base font size; headings and code scale with it |
mdPdf.displayHeaderFooter |
true |
Show the header and footer |
mdPdf.headerText |
{title} |
Top-left text; placeholders {title}, {date}, {page}, {pages} |
mdPdf.footerText |
{page} / {pages} |
Bottom-right text; same placeholders |
mdPdf.styles |
[] |
Extra CSS files |
mdPdf.includeDefaultStyles |
true |
Include the built-in stylesheet |
mdPdf.mermaidScale |
0.7 |
Diagram size relative to natural size |
mdPdf.mermaidTheme |
default |
default, neutral, dark, forest, base |
mdPdf.embedImages |
true |
Embed local images in the output |
mdPdf.renderTimeout |
30000 |
Maximum render time in ms |
mdPdf.openAfterExport |
true |
Open the file when done |
The header and footer are printed in the page margins and need a recent browser (Chromium 131 or later).
Custom styling: point mdPdf.styles at your own CSS file, for example:
.markdown-body { font-family: "Georgia", serif; }
.markdown-body h1 { color: #204fdd; border: 0; }
Troubleshooting: open Output → md2pdf for the log: browser used, warnings and errors.
INSTALLATION
Install the packaged .vsix:
- UI: Extensions panel →
… menu → Install from VSIX… → select the file.
- CLI:
code --install-extension epicdata-md2pdf-<version>.vsix
Then reload VS Code and open a Markdown file.
CHANGELOG
1.0.0
- First release. Export Markdown to PDF or self-contained HTML, with raw HTML, offline Mermaid diagrams, embedded local images, syntax highlighting, task lists, page breaks, configurable paper size, margins, font size, header and footer, and batch export from the Explorer. Zero runtime dependencies.
ABOUT EPICDATA
EpicData is a Belgian data consultancy helping organisations build a data-driven culture, from strategy and governance to platforms, engineering and visualisation.
epicdata.be · Data doet dat.
LICENSE
© 2026 EpicData. Free to download and use (personal or commercial) under the
EpicData End-User Licence Agreement. EpicData retains ownership; modifying,
reverse-engineering, reselling, or redistributing the Software outside the
official channels is not permitted. See LICENSE.txt.
The bundled Mermaid library is licensed separately under the MIT License; see
THIRD-PARTY-NOTICES.