A flexible Markdown to PDF converter with support for custom themes, title pages, and author management.
npm install -g markdown-to-pdf
Or use directly without installation:
npx markdown-to-pdf convert document.md
markdown-to-pdf convert document.md
markdown-to-pdf init my-docs
cd my-docs
markdown-to-pdf convert docs/example.md
Convert a Markdown file to PDF
Options:
-o, --output <file>
- Output PDF file path-t, --theme <name>
- Theme to use (default: 'default')-c, --config <file>
- Configuration file path--html
- Also output intermediate HTML file--no-title-page
- Skip title page generation
Examples:
markdown-to-pdf convert document.md
markdown-to-pdf convert document.md -o output/final.pdf
markdown-to-pdf convert document.md --theme minimal --html
Initialize a new markdown-to-pdf project with sample files
Options:
-t, --theme <name>
- Theme to use (default: 'default')
List available themes
Projects can be configured using:
markdown-to-pdf.config.json
(recommended)markdown-to-pdf.config.js
.markdown-to-pdf.json
package.json
(inmarkdown-to-pdf
section)
Example configuration:
{
"theme": "default",
"titlePage": true,
"authors": {
"directory": "data/authors",
"template": "assets/templates/author.yaml"
},
"pdfOptions": {
"displayHeaderFooter": true,
"printBackground": true,
"scale": 1.0
}
}
- Custom Themes: Built-in themes (default, minimal, academic) with support for custom themes
- Title Pages: Automatic title page generation with metadata
- Author Management: YAML-based author profiles with pictures
- Table of Contents: Automatic TOC generation with
<!-- [[toc]] -->
- Syntax Highlighting: Code blocks with highlight.js
- Custom CSS: Theme-based styling with CSS customization
- JS Preprocessing: Custom DOM manipulation with
.js
files - Markdown Extensions: Callouts, anchors, and more
- default: Professional styling with headers/footers
- minimal: Clean, minimal design without headers
- academic: Academic paper formatting (coming soon)
Create a themes/mytheme/
directory with:
theme.json
- Theme configurationmain-content.css
- Main document stylestitle-page.css
- Title page stylesheader.html
- Header templatefooter.html
- Footer template