Skip to main content

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.

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

md_to_pdf_cli-0.1.5.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

md_to_pdf_cli-0.1.5-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file md_to_pdf_cli-0.1.5.tar.gz.

File metadata

  • Download URL: md_to_pdf_cli-0.1.5.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

Hashes for md_to_pdf_cli-0.1.5.tar.gz
Algorithm Hash digest
SHA256 445635f48b55df04ef20feca14d1c3f3fe396acc598d51876b004120134feb52
MD5 bfd6e6b06ce5508b19850071538ff5d3
BLAKE2b-256 3ddd236e0073370a8748ea70911b71326bbd064500b9f2b9f0b66e621012dc8f

See more details on using hashes here.

File details

Details for the file md_to_pdf_cli-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: md_to_pdf_cli-0.1.5-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

Hashes for md_to_pdf_cli-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0be266539073acff5c46f6d721b9b7f81156317d0a1935768193c35e4f573d76
MD5 eb89f7eabad5b78fdf8e50d7743c7d17
BLAKE2b-256 f44cca8adb6d853bcfb62d70b88a6163c5e0f23cec90478fab9f777ed9671523

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page