Chapter PDF export
DocsLit can generate real PDF files alongside your static site — one per sidebar chapter, one per page, and a combined full documentation PDF. Readers download them from a Download PDF menu on each page.
PDF export is opt-in and disabled by default. Enable it per build with --pdf, or turn it on permanently in docslit.json.
Quick start
Install Playwright in your project (one-time setup):
Build with PDFs:
Output lands in dist/pdf/:
| File | Description |
|---|---|
pdf/{chapter-id}.pdf | One PDF per top-level sidebar group |
pdf/pages/{slug}.pdf | One PDF per page (nested slugs use --, e.g. guides--setup.pdf) |
pdf/full-manual.pdf | All chapters combined in sidebar order (full documentation) |
pdf/manifest.json | Machine-readable index of generated PDFs |
Reader experience
When PDFs are built, the page meta bar shows a Download PDF dropdown instead of a single Save as PDF button:
- This page as PDF — opens the browser print dialog (same as before)
- Download this chapter as PDF — downloads the pre-built chapter PDF for the current page's sidebar group
- Download full documentation — downloads the combined documentation PDF
If a page is not part of any chapter (for example, an orphan page or an API reference page excluded from chapters), only This page as PDF appears.
When PDFs are not built, the site keeps the original Save as PDF print button.
Configuration
Add a pdf block to docslit.json:
api/* pages in chapter and manual PDFs. Off by default for hybrid docs + OpenAPI sites.Flag precedence
CLI flags override config:
| Priority | Source |
|---|---|
| 1 (highest) | --no-pdf |
| 2 | --pdf |
| 3 | pdf.enabled in config |
| 4 (default) | Off |
Chapter strategies
sidebar-groups (default)
One PDF per top-level sidebar[].group. Pages inside nested subgroups are flattened into the parent group, in sidebar order.
A sidebar like this:
Produces a single chapter PDF titled Getting started containing introduction, installation, and quickstart in that order.
folders
Groups pages by the first path segment of their slug. guides/setup and guides/config become one guides chapter. Top-level pages like introduction go into a docs chapter.
Useful when your docs/ folder is organized by directory but the sidebar is flat or minimal.
manual
Define chapters explicitly:
Versioned sites
When using versioning, PDFs are generated per version under dist/{version}/pdf/. Each version gets its own manifest and chapter PDFs based on that version's sidebar.
CI/CD
Add Playwright to your build pipeline when generating PDFs:
Edge cases
| Situation | Behavior |
|---|---|
| Draft pages | Excluded from all PDFs |
| Empty chapter (all drafts) | Skipped — no empty PDF file |
| Single-page chapter | Still generated as a single-page PDF |
| Page not in sidebar | Per-page PDF only; no chapter item in dropdown |
api/* pages | Excluded from chapters unless include.apiReference is true |
| Missing Playwright | Build exits with install instructions |
--offline | PDF generation skipped with a warning |
Migrating from Docusaurus
If your team used Docusaurus with a PDF plugin (such as Papersaurus), DocsLit provides a similar workflow without a React site:
- Run
docslit importto convert your existing Markdown and sidebar. - Chapters map to top-level sidebar groups automatically.
- Run
docslit build --pdfto produce chapter and manual PDFs. - Deploy
dist/as usual — PDFs are static files alongside HTML.
Your writers keep editing Markdown. PDFs stay in sync with the sidebar structure they already maintain.
Related
- Static hosting — deploy
dist/including thepdf/directory - Commands — full
--pdfflag reference - Pages and navigation — how sidebar groups define site structure