Convert local Markdown files to PDF via headless Chromium (CJK-friendly, mermaid + math + code highlighting).
Project description
md-to-pdf-cli
Convert local Markdown files to PDF using headless Chromium — the same engine your editor preview uses, so what you see is what you get.
- 📦 Source & full docs: https://github.com/Suyw-0123/md-to-pdf-cli
- 📖 Developer wiki: https://github.com/Suyw-0123/md-to-pdf-cli/tree/main/docs/wiki
The CLI command is md2pdf (the PyPI package is md-to-pdf-cli).
Install
Requires Python 3.12+.
# with uv (recommended): installs the `md2pdf` command, isolated
uv tool install md-to-pdf-cli
# or with pip
pip install md-to-pdf-cli
That's it. Chromium is not a pip dependency — it's a browser binary Playwright
downloads once into a shared cache. The first time you run md2pdf it detects the
missing browser and downloads it automatically (~150 MB, one time only). To do it
up front instead, run playwright install chromium (or, for a uv-tool install,
uv tool run --from md-to-pdf-cli playwright install chromium).
Quick start
md2pdf report.md # writes report.pdf next to the input
md2pdf report.md -o out/doc.pdf # choose the output path
md2pdf init # scaffold md2pdf.toml + theme.css
md2pdf <file> is shorthand for md2pdf convert <file>. Run md2pdf --help for
all options.
Configuration
md2pdf auto-loads md2pdf.toml from the current directory. Precedence:
CLI flags > config file > defaults.
[output]
page_size = "A4"
margin = { top = "2cm", bottom = "2cm", left = "1.8cm", right = "1.8cm" }
[theme]
css = ["theme.css"] # extra CSS, applied after the default theme
code_style = "default" # any Pygments style
# font_family = '"Noto Sans CJK TC", "Microsoft JhengHei", sans-serif'
[features]
math = true
mermaid = true
toc = false
embed_images = false
[footer]
enabled = true
template = '<span class="pageNumber"></span> / <span class="totalPages"></span>'
See the full README and wiki on GitHub for the complete options table, theming guide, troubleshooting, and architecture.
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 md_to_pdf_cli-0.1.4.tar.gz.
File metadata
- Download URL: md_to_pdf_cli-0.1.4.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","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 |
8b36d743d6191d912d07b3d9bb66d046e206b92983a7225d7cc095516c2a7275
|
|
| MD5 |
322a398c34eefdcd498cf829af0800c8
|
|
| BLAKE2b-256 |
b80e8d462be7de5ea4ad8bea097ea832b83bdc4fc235f7ff9f17c807103ac18d
|
File details
Details for the file md_to_pdf_cli-0.1.4-py3-none-any.whl.
File metadata
- Download URL: md_to_pdf_cli-0.1.4-py3-none-any.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","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 |
a291fd7b2efc23a83aab989ff61cb884050517b51c62256fc5e103523309efea
|
|
| MD5 |
8fd04b66e9483fe37eb449cf349c5351
|
|
| BLAKE2b-256 |
e255a385d2781ac52b1402d1338430442d550dc488a9463e5cfa003c78402372
|