PDF Export
Doom provides powerful PDF export capabilities that transform your documentation into professional, print-ready PDF files. The feature includes automatic table of contents generation, custom styling, multi-language support, and selective content export.Quick Start
Export your entire documentation to PDF:dist/).
How It Works
The export process:- Builds your documentation (if not already built)
- Serves the built site locally
- Crawls pages based on sidebar configuration
- Renders each page using Puppeteer
- Combines pages into PDF with outlines
- Generates separate PDFs per language and scope
The export command uses the
@alauda/doom-export package internally, which provides advanced PDF generation features.Configuration
Configure PDF export in yourdoom.config.yml:
Export Items
Name for the output PDF file (e.g., “user-guide” → “user-guide-en.pdf”)
Glob patterns or paths to include in the export.Supports wildcards:
*matches the language directory (e.g.,en,zh)**matches any nested directories- Specific paths can be provided as an array
Scope Patterns
Command Options
Thedoom export command accepts several options:
Root directory of the documentation (default: current directory)
Server host name for the preview server
Server port number for the preview server
Ignore internal routes during export
Example Commands
Automatic Exclusions
The export automatically excludes:- API routes:
apis/**and*/apis/**(unless explicitly included) - Internal routes: Routes defined in
internalRoutesconfig - Hidden pages: Pages with
hidden: truein frontmatter
PDF Generation Options
The export uses sophisticated PDF generation with these built-in settings:Page Margins
Headers & Footers
Custom HTML templates for headers and footers:Printer Options
Multi-Language Export
Doom automatically generates separate PDFs for each language:doom export produces:
Documentation-en.pdfDocumentation-zh.pdfDocumentation-ru.pdf
Custom Export Names
When using theexport config, files are named based on the export item:
installation-guide-en.pdfinstallation-guide-zh.pdfinstallation-guide-ru.pdf
Table of Contents
The export automatically generates a hierarchical table of contents based on:- Sidebar structure from
_meta.jsonfiles - Page headings within each document
- Nested sections and subsections
Custom Outlines
The export includes intelligent outline generation:Advanced Configuration
Including API Routes
By default, API routes are excluded. To include them:- Routes starting with
apis/ - Routes matching
*/apis/**pattern
Version-Specific Exports
Export specific versions:Scoped Exports
Create targeted exports for different audiences:Page Collection
The export collects pages by:- Reading the sidebar configuration
- Extracting all page links
- Filtering based on scope patterns
- Removing duplicates
- Ordering based on sidebar structure
Example Collection Process
Customization
Custom Naming
The default PDF naming uses:getPdfName utility from ~/workspace/source/packages/doom/src/cli/export.ts:23.
Print Styling
Add print-specific styles to your documentation:Query Parameters
Pages are loaded with?print query parameter for print-specific rendering:
Troubleshooting
Build Required
Error: “Please build the documentation first”Solution
Solution
Run Or use a npm script to chain commands:
doom build before doom export:No Pages Found
Warning: “Cannot find matched scope”Solution
Solution
- Check that your scope patterns match actual routes
- Verify the sidebar configuration includes the pages
- Ensure the language directory exists
- Use glob pattern testing to validate your patterns
Memory Issues
For very large documentation:Solution
Solution
Increase Node.js memory limit:Or export in smaller chunks:
Timeout Errors
If pages timeout during rendering:Solution
Solution
- Check for JavaScript errors in the built documentation
- Ensure all resources (images, scripts) load correctly
- Test the built site locally:
doom preview - Look for infinite loops or heavy computations
Best Practices
Test Build First
Always test
doom preview before exporting to catch rendering issues early.Use Descriptive Names
Choose clear export names that describe the content (e.g., “api-reference”, “user-guide”).
Optimize Images
Compress images to reduce PDF file size without sacrificing quality.
Test PDF Output
Review generated PDFs to ensure formatting, links, and layout are correct.
Integration Examples
CI/CD Pipeline
NPM Scripts
Related Features
Auto Sidebar
Configure sidebar structure that controls PDF export organization
Translation
Export documentation PDFs for multiple languages automatically