skillfed

md2pdf

The Markdown to PDF conversion tool with styles

md2pdf v3.1.1 204.9K downloads/30d#9,597 on PyPI439
Permissive license MIT Active released

What it is and what it does

md2pdf is a Markdown-to-PDF converter that bridges markdown source files and styled PDF output. It accepts markdown input (from files or raw strings), applies optional CSS stylesheets, and renders the result as a PDF using weasyprint as its rendering engine. The tool supports Jinja2 templating within markdown, allowing dynamic content injection via frontmatter or programmatic context variables, and integrates markdown extensions from pymdown-extensions for features like syntax highlighting and emoji support.

You can use it as a command-line tool for one-off conversions or batch processing (with parallel workers), or embed it in Python code as a library function. It's designed for developers who need to generate styled PDF documentation from markdown sources—common in technical writing, report generation, and documentation pipelines. The package supports Python 3.10 through 3.14 and is actively maintained.

Use it for:

  • Generate styled PDF documentation from markdown README files with custom CSS branding.
  • Batch convert multiple markdown files to PDF with parallel processing using the --workers option.
  • Create dynamic PDF reports by embedding Jinja2 templates and frontmatter variables in markdown source.
  • Integrate markdown-to-PDF conversion into a Python application or documentation build pipeline.
  • Render markdown with syntax-highlighted code blocks using pymdown-extensions and custom CSS.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Converts Markdown files to PDF with custom CSS styling, Jinja templating, and syntax highlighting support via a CLI tool or Python library.

Yes, if you need to convert markdown to styled PDFs. The package is actively maintained, has no known vulnerabilities, low install friction, and a permissive license. The main condition is ensuring weasyprint's system dependencies are available on your platform—check the weasyprint installation guide before installing. For markdown-to-PDF workflows, this is a solid, production-ready choice.

Install

md2pdf on PyPI

pip

pip install md2pdf

uv

uv add md2pdf

poetry

poetry add md2pdf

Installing md2pdf

Before you install

Low friction: pure Python wheel with six runtime dependencies (jinja2, markdown, pygments, pymdown-extensions, python-frontmatter, weasyprint). Active maintenance with last commit 2026-08-14. Requires weasyprint to be fully functional on your system before use, per the documentation.

License in practice

MIT license (permissive) means you can use, modify, and distribute md2pdf freely in commercial and private projects with minimal restrictions.

Quickstart

pip install md2pdf[cli]
md2pdf -i README.md

Or as a library:
from md2pdf.core import md2pdf
md2pdf('output.pdf', md='input.md', css='style.css')

Weasyprint must be fully functional on your system; see https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#installation for platform-specific setup.

Verify before relying

  • Whether weasyprint's system dependencies (e.g., Cairo, Pango) are easily available on all target platforms or represent a common installation barrier.
  • Performance characteristics when processing large markdown files or batch conversions with the --workers parameter.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 6 — jinja2, markdown, pygments, pymdown-extensions, python-frontmatter, weasyprint
Maintenance actively maintained — 136 days since the last release
Last repo commit
First released
Downloads 204,901/month — #9,597 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: md2pdf-3.1.1-py3-none-any.whl

Keywords: cli, css, html, markdown, pdf

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Office/BusinessTopic :: Utilities

Tags

markdown to pdf conversionmd to pdf cli toolmarkdown pdf generatorconvert markdown documents pdfmarkdown with css styling pdfjinja markdown templates pdfsyntax highlighting markdown pdf
markdown-to-pdfdocument-generationcli-tool

More Utilities packages