Exports your MkDocs, ProperDocs and Zensical documentation to PDF: a document for each page, and books combining pages into a single document.
- 📚 Books - combine pages into PDF documents with bookmarks, a table of contents and working links
- 🎨 Customizable - full control over the resulting documents
- Cover pages written as Jinja templates
- Headers and footers with page numbers
- Custom stylesheets, scripts and hooks
- Per-page options in the front matter
- Buttons at the top of your pages (e.g. to download the page or the book as PDF)
- Dedicated support for the
materialandreadthedocsthemes, check out sample PDF 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
| 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.
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 chromiumUpgrading from v6? Read the migration guide.
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: trueWith 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 buildCheck out the examples: documents generated from a small website (with cover pages, tables of contents, headers and footers...), with their configuration (examples/).
- 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.
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.
This project is licensed under the MIT License (MIT), which you can read here.