Skip to main content

Convert Markdown files to PDF using MkDocs Material theme and Playwright

Project description

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

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

mkdocs_md_to_pdf-0.1.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocs_md_to_pdf-0.1.2-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mkdocs_md_to_pdf-0.1.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","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 mkdocs_md_to_pdf-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a71c5a4bd1d4f11cd681802b5d03920aef91300e2dd4b131aec355baafe47772
MD5 0d857f8e333a0686aebe42ee8587b922
BLAKE2b-256 ed6c7e84c3130e0f6b435461f85dbac357759d4e118d8ee17978ccfccbdce6fc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mkdocs_md_to_pdf-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","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 mkdocs_md_to_pdf-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9ac919522d14b503275a51061e2370ae9d236246c1dc71c33ab94597047b3ee4
MD5 268aa48e0471eabe9308521a21cac9ea
BLAKE2b-256 314d5ea425e540e02e0353064155f923e9efaba5ab816810e49b9e22d2d5a642

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