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.3.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.3-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mkdocs_md_to_pdf-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 4e88dc7989f1f9f3583bd4b8058296cea33cf92b92090d684e536c958a9652b0
MD5 3b348a4be571b1acdc385aada670830b
BLAKE2b-256 e4eb2f8d0b64e4f5a4998d7cfc3ac1f146840997f4ecd5b5bd6f361bbaa8ddd8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mkdocs_md_to_pdf-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 52907372ed1fa1ac08e3e0193b237a5ce71a7d34786323b86ba34f2dca67f854
MD5 0a2d274ea223f411ef6c4e1907b09e6e
BLAKE2b-256 3d9d2ebb8ecec5778ccb85731674d02e1c3da3a12f25bfe5de529e966d8f5b45

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