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
uv tool run --from md-to-pdf-cli playwright install chromium   # one-time browser download

# or with pip
pip install md-to-pdf-cli
playwright install chromium                                    # one-time browser download

Chromium is not a pip dependency — it's a browser binary Playwright downloads once into a shared cache. If it's missing, md2pdf tells you the exact command to run.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: md_to_pdf_cli-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 15dca6bf80aca63781ba06fbb2b4594fb66003f75a92067e312c347bd558202e
MD5 6cca790af43bfad692633cb509337965
BLAKE2b-256 246800b35beb36c46eba090989b67ea9b397d00c64233db78723e66b44e6fed1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: md_to_pdf_cli-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 232f7ded60a9bd4b0499e976a8bb32cba3046c3a106e5287af02856daa74404b
MD5 10fb110b86eaf86d8f485c0211d7b456
BLAKE2b-256 476088b92efb63ac539d6103509b977750e7cfbf4c0b2692482007f650a6b25b

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