Convert Markdown files to PDF using MkDocs Material theme and Playwright
Project description
mkdocs-md-to-pdf
Convert Markdown files to styled PDFs using MkDocs Material theme and Playwright.
Features
- 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
Installation
# Using uv
uv add mkdocs-md-to-pdf
# Using pip
pip install mkdocs-md-to-pdf
After installation, install the Chromium browser for Playwright:
playwright install chromium
PlantUML Setup
macOS
- 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"
Ubuntu/Debian
sudo apt install default-jdk plantuml
Usage
Command Line
# Output to stdout (pipe to file)
md-to-pdf document.md > output.pdf
# Output to specific file
md-to-pdf document.md -o output.pdf
Python API
from 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")
Supported Markdown Features
- 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)
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs_md_to_pdf-0.1.0.tar.gz.
File metadata
- Download URL: mkdocs_md_to_pdf-0.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43bb1d30cb991cd623176851b0f13f47c758edf950585be9b0cd683cf48058b0
|
|
| MD5 |
2dd4ba80bc7f7da1974b7dc33098c534
|
|
| BLAKE2b-256 |
a5dc70aa85ce609433d26b1b729132d03ecb80ec1277ab071642976d261c8185
|
File details
Details for the file mkdocs_md_to_pdf-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mkdocs_md_to_pdf-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4dd206b0475fe47e94506b2f30a9d27f84a237d79761a9a111f6319e22c53a02
|
|
| MD5 |
82a782a0c1cf4cdf354c3f3c49a900d8
|
|
| BLAKE2b-256 |
1a5441598f6c93fa9c09a66d749686426f3623ff600182c47e8a8b64e02713ea
|