Skip to content

About

⚡ The fastest and most configurable plugin for MkDocs (ProperDocs, Zensical), allowing seamless export of individual pages and/or entire documentation as PDF documents.

Topics

Resources

Stars

131 stars

Watchers

5 watching

Forks

Repository files navigation

MkDocs Exporter

A page of this documentation and its PDF document

Exports your MkDocs, ProperDocs and Zensical documentation to PDF: a document for each page, and books combining pages into a single document.

Features

  • 📚 Books - combine pages into PDF documents with bookmarks, a table of contents and working links
  • 🎨 Customizable - full control over the resulting documents
  • ♿ Accessible - documents are tagged for screen readers, with bookmarks, their language and document information
  • 🚀 Fast - documents are rendered concurrently, and unchanged ones are reused from a cache
  • ⭐ Powerful - documents are printed by Chromium, driven by Playwright, with CSS Paged Media support

Supported tools

Tool Support
MkDocs >= 1.6, < 2 ✅ A plugin, documents are generated while building the website
ProperDocs ✅ The same plugin
Zensical 🧪 A command, run once the website is built (experimental, see the Zensical guide)
MkDocs 2.0 ⏳ Not yet (it doesn't support plugins)

Requires Python >= 3.11.5.

Installation

The package is hosted on PyPI and can be installed via pip (or your favourite package manager), along with the browser it uses:

pip install mkdocs-exporter
playwright install --with-deps --only-shell chromium

Upgrading from v6? Read the migration guide.

Usage

The following configuration (adapted from the mkdocs.yml file used by this documentation) covers the main features:

plugins:
  - exporter:
      formats:
        pdf:
          enabled: !ENV [MKDOCS_EXPORTER_PDF, true]
          concurrency: 8
          stylesheets:
            - resources/stylesheets/pdf.css
          covers:
            front: resources/templates/covers/front.html.j2
            back: resources/templates/covers/back.html.j2
          footer:
            right: "Page {page} of {pages}"
          books:
            - output: documentation.pdf
              covers: front
              toc:
                enabled: true

With MkDocs and ProperDocs, documents are generated by mkdocs build (or properdocs build). Zensical doesn't run plugins: it ignores this configuration (also accepted as [project.plugins.exporter] in zensical.toml), which the mkdocs-exporter command reads to export the website once it is built:

zensical build
mkdocs-exporter build

Check out the examples: documents generated from a small website (with cover pages, tables of contents, headers and footers...), with their configuration (examples/).

Roadmap

  • Combine all pages into a single PDF document (✅ released in v6.0.0)
  • Bookmarks, table of contents and links in books (✅ released in v7.0.0)
  • Export websites built by Zensical (🧪 experimental, released in v7.0.0)
  • Export websites built by MkDocs 2.0
  • Create a GitHub action that includes all dependencies to build the documentation and generate PDF documents

Feel free to request additional features by submitting an issue or contributing through a pull request.

Contributing

We welcome contributions from the community to enhance MkDocs Exporter.
Whether you want to report a bug, suggest a feature, improve the documentation, or contribute code, your help is appreciated! See AGENTS.md for how the project is organized, built and tested.

License

This project is licensed under the MIT License (MIT), which you can read here.

About

⚡ The fastest and most configurable plugin for MkDocs (ProperDocs, Zensical), allowing seamless export of individual pages and/or entire documentation as PDF documents.

Topics

Resources

Stars

131 stars

Watchers

5 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages