Markdown PDF (Revived)Install • What changed • Features • Settings • Requirements Converts Markdown files to PDF or HTML from within VSCode. All rendering is local; no external servers, no telemetry, Chrome required. What Changed in v2This is a fork of yzane/vscode-markdown-pdf, which had no maintainer activity since late 2023. See CHANGELOG.md for the full list of changes and MIGRATION.md for upgrade instructions. Removed: PlantUML (sent source to plantuml.com), PNG/JPEG export, Chromium auto-download, 10 settings. Added: KaTeX math, DOMPurify sanitization (CVE-2024-7739), Mermaid async render fix, TypeScript rewrite, esbuild bundling (~11MB), footnotes, GitHub-style callouts, configurable export timeout. Changed: Default margins, highlight theme (github.css), header/footer off by default.
RequirementsChrome or Chromium must be installed. The extension detects it automatically at standard installation paths on macOS, Linux, and Windows. To use a non-standard Chrome binary:
Restart VSCode after changing this setting. Getting StartedVS Code users can search for "Markdown PDF" in the Extensions panel or install from the VS Code Marketplace. VSCodium users should install from Open VSX. Manual install: Download the UsageCommand Palette
Right-click Menu
Auto-convert on Save
To exclude specific files from auto-convert, add filename patterns to Features
SettingsOutput
Styles
|
| Setting | Default | Description |
|---|---|---|
markdown-pdf.breaks |
false |
Treat newlines as <br> tags. |
markdown-pdf.emoji |
true |
Render emoji shortcodes. |
markdown-pdf.math |
true |
Enable KaTeX math rendering. |
| Setting | Default | Description |
|---|---|---|
markdown-pdf.displayHeaderFooter |
false |
Show header and footer in PDF output. |
markdown-pdf.headerTemplate |
(title + date) | HTML template for the PDF header. |
markdown-pdf.footerTemplate |
(page / total) | HTML template for the PDF footer. |
markdown-pdf.printBackground |
true |
Print background graphics. |
markdown-pdf.orientation |
"portrait" |
Page orientation: portrait or landscape. |
markdown-pdf.format |
"A4" |
Paper size: Letter, Legal, Tabloid, Ledger, A0–A6. |
markdown-pdf.margin.top |
"2cm" |
Top margin. Units: mm, cm, in, px. |
markdown-pdf.margin.bottom |
"2cm" |
Bottom margin. Units: mm, cm, in, px. |
markdown-pdf.margin.right |
"2.5cm" |
Right margin. Units: mm, cm, in, px. |
markdown-pdf.margin.left |
"2.5cm" |
Left margin. Units: mm, cm, in, px. |
markdown-pdf.timeout |
60000 |
Timeout in milliseconds for PDF export. Increase for large documents or slow machines. |
Header and footer templates support these tokens:
| Token | Value |
|---|---|
<span class='title'></span> |
Document title (frontmatter title: if set, otherwise filename) |
<span class='pageNumber'></span> |
Current page number |
<span class='totalPages'></span> |
Total pages |
%%ISO-DATE%% |
Date in YYYY-MM-DD format |
%%ISO-DATETIME%% |
Date and time in YYYY-MM-DD hh:mm:ss format |
%%ISO-TIME%% |
Time in hh:mm:ss format |
Mermaid Diagrams
Mermaid diagrams are rendered locally using the bundled mermaid.min.js. Before PDF capture, the extension waits for Mermaid's async SVG rendering to complete by polling for the data-processed attribute on each .mermaid element. This ensures diagrams appear in PDFs rather than as raw code blocks.
```mermaid
flowchart TD
A[Start] --> B{Decision}
B -->|Yes| C[Do the thing]
B -->|No| D[Skip it]
C --> E[End]
D --> E
```
PlantUML has been removed. It sent diagram source to plantuml.com on each render. For migration examples and equivalent Mermaid syntax, see MIGRATION.md.
Custom Containers
The markdown-it-container plugin wraps content in named <div> elements. Style them with a custom CSS file.
Input:
::: warning
*here be dragons*
:::
Output:
<div class="warning">
<p><em>here be dragons</em></p>
</div>
File Includes
Includes insert the contents of another Markdown file at the include site. Paths are relative to the file containing the include directive.
Syntax: :[display text](https://github.com/AUAggy/markdown-pdf-revived/blob/HEAD/relative-path-to-file.md)
Example:
:[Plugins](https://github.com/AUAggy/markdown-pdf-revived/blob/HEAD/plugins/README.md)
:[Changelog](https://github.com/AUAggy/markdown-pdf-revived/blob/HEAD/CHANGELOG.md)
The output contains the rendered content of each included file in sequence.
Security note (v2.1.0+): File includes are now processed by the built-in
inlineIncludesSecurefunction (replacing themarkdown-it-includeplugin). All included paths are validated against the workspace root, with a maximum include depth of 10 and per-branch cycle detection. Include paths that reference files outside the workspace root are blocked by default. To allow cross-workspace includes, setmarkdown-pdf.allowPathsOutsideWorkspacetotrue.
Page Breaks
Insert a page break with:
<div class="page"/>
Known Limitations
- Chrome or Chromium must be installed separately. The extension does not bundle or download a browser.
- Online CSS URLs (e.g.,
https://example.com/styles.css) do not resolve reliably in PDF output. Prefer local stylesheet paths.
License
MIT