Convert Markdown files to styled PDFs using MkDocs Material theme and Playwright.
- Material Design styling via MkDocs Material theme
- Syntax highlighting for code blocks
- Mermaid diagram support
- PlantUML diagram support (requires Java)
- Admonitions and callouts
- Automatic handling of linked images and files
# Using uv
uv add mkdocs-md-to-pdf
# Using pip
pip install mkdocs-md-to-pdfAfter installation, install the Chromium browser for Playwright:
playwright install chromium- Download PlantUML JAR from GitHub releases
- Place JAR:
mv plantuml-mit-1.2025.8.jar ~/.local/bin/plantuml.jar - Make executable:
chmod +x ~/.local/bin/plantuml.jar - Add to shell profile (.bashrc/.zshrc):
export PATH="$PATH:~/.local/bin"
export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"sudo apt install default-jdk plantuml# Output to stdout (pipe to file)
md-to-pdf document.md > output.pdf
# Output to specific file
md-to-pdf document.md -o output.pdffrom mkdocs_md_to_pdf import convert
# Get PDF as bytes
pdf_bytes = convert("document.md")
# Write directly to file
convert("document.md", output_file="output.pdf")- Standard Markdown syntax
- Fenced code blocks with syntax highlighting
- Tables
- Admonitions (
!!! note,!!! warning, etc.) - Callouts (
> [!NOTE],> [!WARNING]) - Mermaid diagrams
- PlantUML diagrams
- Linked images (relative paths)
MIT