The Markdown to PDF conversion tool with styles
Actively maintained. Last release 10 days ago, commits in 13 of the last 26 weeks. A safe choice.
pip install md2pdf
Convert Markdown files to PDF with styles.
Installation
The easiest way to test md2pdf is to use uv:
$ uv tool install md2pdf[cli]
Nota bene: ensure, Weasyprint is fully functional before using md2pdf. You will find installation instructions in the project documentation: https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#installation
Usage
As a CLI
Usage: md2pdf [OPTIONS]
Markdown to PDF conversion tool with styles… and templates!
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --input -i <list[Path]> Markdown source file path (can │
│ be used multiple times). │
│ --output -o <path> PDF output file path (when a │
│ single md input is used). │
│ --css -c <path> Input CSS file. │
│ --extras -e <list[str]> Extra markdown extension to │
│ activate (cam be used multiple │
│ times). │
│ --config -C <str> Markdown extensions │
│ configuration (as a JSON │
│ string). │
│ --template -t <bool> Enable Jinja template rendering │
│ (sandboxed). Never use with │
│ untrusted input. │
│ --watch -w <bool> Automatically render PDF upon │
│ input file(s) changes. │
│ --workers -W <int> Number of parallel workers to │
│ start. │
│ [default: 4] │
│ --version -V <bool> Display program version. │
│ --install-completion <bool> Install completion for the │
│ current shell. │
│ --show-completion <bool> Show completion for the current │
│ shell, to copy it or customize │
│ the installation. │
│ --help <bool> Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────╯