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.1.tar.gz (4.1 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.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mkdocs_md_to_pdf-0.1.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","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.1.tar.gz
Algorithm Hash digest
SHA256 41eec9cfcb3bd95bf4f61376b11d0d6d7bc12828521a624c1d875aee8ad511ee
MD5 c869d809b468670d4152b693a68e6886
BLAKE2b-256 90f28e4b5afbaa889097051e2bd5beaa0fb0aff064a9fabf945ce9ad15f726a7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mkdocs_md_to_pdf-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0e50ccc1e6bf2e2c76dcab8fec3f696bb14252248231ed70279f9edf8078df6
MD5 2e87b4745033170927480e4ff9237d3a
BLAKE2b-256 8d0d7ce46be12fedd37e098a61abfdb1dd90a709dd9f358e206007fefc4a2e76

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