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.3.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.3-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: md_to_pdf_cli-0.1.3.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","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.3.tar.gz
Algorithm Hash digest
SHA256 a8f0f785fae3c3638bff5c3c665609fe5d8cf16e073a85633fbc5e33f07240cd
MD5 a45e506fc2e7f9a68aba12792f8edc67
BLAKE2b-256 cd45783d763085c8b65f91008fb7db1f6574375d91ac2625f688c14cf61600d3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: md_to_pdf_cli-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8701bb2dee34de6b4328060693c28efa2e6747bb676be357921b224337d8eef3
MD5 72d53cc5436a4672bc50db00bcb19b6d
BLAKE2b-256 76dd2b7aae11d2c151e2d2366cc773e21e5c537c0ed307e0b51616a9ea05aaf9

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