Skip to content

lode-braced/mkdocs-md-to-pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mkdocs-md-to-pdf

Convert Markdown files to styled PDFs using MkDocs Material theme and Playwright.

Features

  • Material Design styling via MkDocs Material theme
  • Syntax highlighting for code blocks
  • Mermaid diagram support
  • PlantUML diagram support (requires Java)
  • Admonitions and callouts
  • Automatic handling of linked images and files

Installation

# Using uv
uv add mkdocs-md-to-pdf

# Using pip
pip install mkdocs-md-to-pdf

After installation, install the Chromium browser for Playwright:

playwright install chromium

PlantUML Setup

macOS

  1. Download PlantUML JAR from GitHub releases
  2. Place JAR: mv plantuml-mit-1.2025.8.jar ~/.local/bin/plantuml.jar
  3. Make executable: chmod +x ~/.local/bin/plantuml.jar
  4. Add to shell profile (.bashrc/.zshrc):
export PATH="$PATH:~/.local/bin"
export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"

Ubuntu/Debian

sudo apt install default-jdk plantuml

Usage

Command Line

# Output to stdout (pipe to file)
md-to-pdf document.md > output.pdf

# Output to specific file
md-to-pdf document.md -o output.pdf

Python API

from mkdocs_md_to_pdf import convert

# Get PDF as bytes
pdf_bytes = convert("document.md")

# Write directly to file
convert("document.md", output_file="output.pdf")

Supported Markdown Features

  • Standard Markdown syntax
  • Fenced code blocks with syntax highlighting
  • Tables
  • Admonitions (!!! note, !!! warning, etc.)
  • Callouts (> [!NOTE], > [!WARNING])
  • Mermaid diagrams
  • PlantUML diagrams
  • Linked images (relative paths)

License

MIT

About

Convert Markdown files to styled PDFs using [MkDocs Material](https://squidfunk.github.io/mkdocs-material/) theme and [Playwright](https://playwright.dev/).

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages