Skip to main content

Convert MkDocs sites to PDF, Word, HTML, and ODT documents with branding

Project description

LeafPress

Docs PyPI License: MIT CI

Convert MkDocs sites to PDF, Word, HTML, and ODT documents with branding.

Documentation · GitHub · PyPI

Features

  • Generate PDF, DOCX, HTML, and ODT output from any MkDocs project
  • Cover page, table of contents, and branded footer
  • Logo, colors, and metadata via a simple leafpress.yml config
  • Git version info (tag, branch, commit) embedded in output
  • Convert from local paths or remote git URLs
  • Desktop UI — macOS/Linux/Windows menu bar app
  • CI-friendly — configure entirely via LEAFPRESS_* environment variables

Installation

# uv
uv add leafpress

# pip
pip install leafpress

# With desktop UI (PyQt6)
uv add 'leafpress[ui]'
pip install 'leafpress[ui]'

WeasyPrint requires system libraries on Linux — see Installation docs for details.

Quick Start

# Generate a starter branding config
leafpress init

# Convert to PDF
leafpress convert /path/to/mkdocs/project

# Convert to PDF + DOCX with branding
leafpress convert /path/to/project -f both -c leafpress.yml

# Convert to HTML or ODT
leafpress convert /path/to/project -f html
leafpress convert /path/to/project -f odt

# Convert to all formats (PDF, DOCX, HTML, ODT)
leafpress convert /path/to/project -f all -c leafpress.yml

# Convert from a remote git repo
leafpress convert https://github.com/org/repo -b main -f pdf

# Show site info (pages, nav, git status)
leafpress info /path/to/project

Desktop UI

# Launch menu bar / system tray app
leafpress ui

# Open the window immediately on launch
leafpress ui --show

On macOS, LeafPress lives in the menu bar (not the Dock). Click the icon to open the conversion window. Supports all the same options as the CLI, including "Open after conversion".

Requires the [ui] extra: pip install 'leafpress[ui]'

CI / GitHub Actions

LeafPress can be configured entirely via environment variables — no leafpress.yml needed.

jobs:
  docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install WeasyPrint system dependencies
        run: sudo apt-get install -y libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0

      - name: Install leafpress
        run: pip install leafpress

      - name: Convert docs to PDF
        env:
          LEAFPRESS_COMPANY_NAME: ${{ vars.COMPANY_NAME }}
          LEAFPRESS_PROJECT_NAME: My Project
          LEAFPRESS_PRIMARY_COLOR: "#1a73e8"
        run: leafpress convert . -f pdf -o dist/

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: documentation
          path: dist/*.pdf

You can also place a .env file in your project root — LeafPress loads it automatically. Shell environment variables always take priority over .env values.

See CI / GitHub Actions docs for the full environment variable reference.

Branding Configuration

Create leafpress.yml in your project root (or run leafpress init):

company_name: "Acme Corp"
project_name: "Platform Docs"
logo_path: "./logo.png"         # local path or https:// URL
subtitle: "Internal Documentation"
author: "Engineering Team"
primary_color: "#1a73e8"        # 6-digit hex
accent_color: "#ffffff"

footer:
  include_tag: true
  include_date: true
  include_commit: true
  include_branch: false
  custom_text: "Confidential"

pdf:
  page_size: "A4"
  margin_top: "25mm"
  margin_bottom: "25mm"
  margin_left: "20mm"
  margin_right: "20mm"

Development

uv sync --group dev
uv run pytest tests/ -v
uv run ruff check src/

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

leafpress-0.1.3.tar.gz (39.8 kB view details)

Uploaded Source

Built Distribution

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

leafpress-0.1.3-py3-none-any.whl (51.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: leafpress-0.1.3.tar.gz
  • Upload date:
  • Size: 39.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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 leafpress-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5d6b721030dc62c7aa2a1870030ce8d3979caab7ae236fd7f61c2c8c194a97ba
MD5 e0d59d659f83f733ecc78e6a991f8c3f
BLAKE2b-256 ccbbf5a4c5eb810e2a500edda1d434b38f2f23385f50b859fd0c4a1ceb2d61d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: leafpress-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 51.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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 leafpress-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9d4550a71927bfa4b157654de9823fce408b753a76b05e27e019a13c6c7b1749
MD5 89743a0a219021322cd491cd2857a1fc
BLAKE2b-256 9de93af8060e0243b82ff808fba8200c0b43b32d2f049dd2a2adaa90c3f78ba5

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