Getting started¶
Introduction¶
MkDocs Exporter exports the pages of your MkDocs or ProperDocs website to PDF documents, and combines them into books: single documents with bookmarks, a table of contents and working links. Websites built by Zensical can be exported too (experimental).
Documents are printed by a headless Chromium browser driven by Playwright, which supports CSS Paged Media: page sizes, margins, headers and footers, page counters...
Examples¶
- Read this documentation in the PDF format
- View this page in the PDF format
- Browse the examples: documents generated from a small website, with their configuration
Prerequisites¶
- Python
>= 3.11.5, on Linux, macOS or Windows - MkDocs
>= 1.6, < 2or ProperDocs - Chromium
>= 138, installed with Playwright (see below), or Chrome / Edge withbrowser.channel - A theme:
material( used by this documentation) andreadthedocshave dedicated support, other themes are supported on a best-effort basis.
What about MkDocs 2.0 and Zensical?
MkDocs 2.0 no longer supports plugins and Zensical ignores MkDocs plugins it doesn't know about, so this plugin can't run there. Websites built by Zensical can be exported by a command run once they are built (experimental), see Zensical.
Installation¶
Install the plugin with the package manager of your choice:
pip install mkdocs-exporter
Then install the browser used to print documents:
playwright install --with-deps --only-shell chromium
On Linux, --with-deps also installs the system libraries the browser needs, which requires administrator rights (leave it out when they're installed already).
If the playwright command isn't found, run python -m playwright install --with-deps --only-shell chromium with the Python that runs MkDocs.
Generating documents¶
Register the plugin in your configuration file:
plugins:
- exporter
That's it: mkdocs build (or properdocs build -f mkdocs.yml) now generates a PDF document next to each page (e.g. site/guide/index.pdf for site/guide/index.html).
Documents are not generated by mkdocs serve (to keep the preview fast), unless you ask for it.
Unchanged documents are reused from a cache, in .cache/plugin/exporter next to mkdocs.yml: add .cache/ to your .gitignore.
Adding a download button¶
Readers can download the document of a page with a button at the top of the page:
plugins:
- exporter:
buttons:
- preset: download
See Adding buttons to pages for other buttons (e.g. opening the document, downloading a book).
Making a book¶
A book combines the pages of your website into a single document, following the navigation:
plugins:
- exporter:
formats:
pdf:
books:
- output: documentation.pdf
toc:
enabled: true
See Books for cover pages, several books, and pages starting on the right.
Next steps¶
- Give documents cover pages and headers and footers (e.g. page numbers).
- Style them with stylesheets of their own.
- Browse the examples: documents generated from a small website, with their configuration.
- Build documents on CI with the continuous integration guide, and check Troubleshooting if something goes wrong.



