skillfed

markdown-pdf

Markdown to pdf renderer

markdown-pdf v1.13.2 557.0K downloads/30d#6,016 on PyPI154
AGPL license AGPL-3.0-only Active released

What it is and what it does

markdown-pdf is a Python library that transforms markdown text into PDF documents. It uses markdown-it-py to parse markdown into HTML and PyMuPDF to render that HTML as PDF. The package handles UTF-8 text in any language, embeds images referenced in markdown, generates a table of contents from headings, supports custom CSS styling, and allows multiple page sizes within a single document. It also provides a plugin system for rendering code blocks like plantuml diagrams into images.

The typical workflow is to create a MarkdownPdf instance, add one or more Section objects containing markdown text, optionally configure CSS and metadata, and then save to a file or bytes buffer. Each section starts on a new page, and you can control which heading levels appear in the table of contents. The package is designed for programmatic PDF generation from markdown content rather than as a command-line tool, though the description includes an example CLI script.

Use it for:

  • Generate user guides or technical documentation from markdown source files with automatic table of contents and consistent styling.
  • Create multi-section reports where each section can have different page sizes, margins, or styling rules.
  • Embed images and diagrams (via plantuml plugin) directly into PDFs generated from markdown templates.
  • Batch-convert markdown files to PDFs with custom branding via CSS and document metadata.
  • Build documentation pipelines that render markdown to PDF with internal cross-references and clickable hyperlinks.

Worth the install?

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

Converts markdown text to PDF files, with support for tables, images, hyperlinks, table of contents, custom CSS styling, and optional diagram rendering via plugins.

Yes, if you need to generate PDFs from markdown programmatically and can accept the AGPL-3.0-only license. The package is actively maintained, has low install friction, carries no known vulnerabilities, and offers a straightforward API with useful features like TOC generation, image embedding, and plugin support. The AGPL license is the main constraint: verify it aligns with your project's licensing model before committing.

Install

markdown-pdf on PyPI

pip

pip install markdown-pdf

uv

uv add markdown-pdf

poetry

poetry add markdown-pdf

Installing markdown-pdf

Before you install

Low install friction with a pure Python wheel. Actively maintained as of 2026-05-28 with 154 repository stars. Five runtime dependencies (PyMuPDF, markdown-it-py, requests, plantuml, six) are all established packages.

License in practice

Licensed under AGPL-3.0-only. This copyleft license requires that any derivative work or modification must also be released under AGPL-3.0-only and that source code be made available to users. Consider this constraint if you plan to integrate it into proprietary or differently-licensed software.

Quickstart

pip install markdown-pdf

from markdown_pdf import MarkdownPdf, Section

pdf = MarkdownPdf(toc_level=2)
pdf.add_section(Section("# Title\n\nContent here"))
pdf.save("output.pdf")

Requires Python 3.8 or later. PyMuPDF may require system libraries; see PyMuPDF documentation for platform-specific setup.

Verify before relying

  • Whether plantuml and mermaid diagram rendering requires external services or local installations beyond what the package provides.
  • Performance characteristics and file size limits for large markdown documents or many embedded images.
  • Exact CSS subset supported for styling; whether all standard CSS properties work as expected.

Package facts

License AGPL-3.0-only (agpl)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 5 — PyMuPDF, markdown-it-py, requests, plantuml, six
Maintenance actively maintained — 78 days since the last release
Last repo commit
First released
Downloads 557,003/month — #6,016 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: markdown_pdf-1.13.2-py3-none-any.whl

Operating System :: OS IndependentProgramming Language :: Python :: 3

Tags

markdown to pdf convertergenerate pdf from markdownmarkdown pdf renderercreate pdf documents from markdownmarkdown document to pdfmarkdown pdf generationconvert markdown files to pdf
pdf-generationmarkdown-processingdocument-rendering

More Markup packages