Skip to main content

doom export

Export documentation to PDF format. Automatically excludes API routes and generates PDFs for each language and configured export scope.

Usage

doom export [root] [options]

Arguments

root
string
Root directory of the documentation. Defaults to current working directory.

Options

-H, --host
string
default:"localhost"
Server host name for the temporary preview serverExample:
doom export --host 0.0.0.0
-P, --port
string
default:"4173"
Server port number for the temporary preview serverExample:
doom export --port 8080
See Global Options for additional options.

Prerequisites

You must build your documentation before exporting:
doom build
doom export

Behavior

Export Process

  1. Validation - Checks that built files exist in outDir
  2. Server Start - Starts a temporary preview server
  3. Auto-Sidebar - Generates sidebar if not configured
  4. Page Collection - Collects pages from sidebar
  5. PDF Generation - Generates PDFs using headless browser
  6. Cleanup - Removes temporary files and closes server

Auto-Exclusions

These routes are automatically excluded from export:
  • apis/** (unless in apis export scope)
  • */apis/** for multi-language setups

Output Files

PDFs are generated with naming:
  • Full documentation: {title}-{lang}.pdf
  • Scoped exports: {scope-name}-{lang}.pdf

Multi-Language Support

If themeConfig.locales is configured, exports are generated for each language.

PDF Configuration

Default PDF settings:
{
  margin: {
    top: 40,
    right: 40,
    bottom: 40,
    left: 40
  },
  printBackground: true,
  headerTemplate: '<div>...</div>',  // Page title
  footerTemplate: '<div>...</div>'   // Empty footer
}

Export Scopes

Configure export scopes in doom.config.yaml:
export:
  - name: user-guide
    scope:
      - guides/**
      - tutorials/**
  
  - name: api-reference
    scope:
      - apis/**
Each scope generates a separate PDF.

Scope Format

name
string
Optional name for the PDF file. If omitted, uses the first sidebar item text.
scope
string | string[]
Glob patterns matching files to include. Can be:
  • Single pattern: "guides/**"
  • Multiple patterns: ["guides/**", "tutorials/**"]

API Scopes

Scopes starting with apis/ or */apis/ are treated specially:
  • API pages are included in the export
  • Processed after non-API scopes

Examples

Basic export

doom build
doom export

Export with custom port

doom export --port 3000

Export from specific directory

doom export ./my-docs

Full workflow

# Build with export mode
doom build --export

# Export to PDF
doom export

Export specific version

doom build --v 2.0
doom export

Configuration Example

Complete export configuration:
# doom.config.yaml
title: My Documentation
themeConfig:
  locales:
    - lang: en
      label: English
    - lang: zh
      label: 中文

export:
  # Main documentation (excludes APIs)
  - name: user-guide
    scope:
      - getting-started/**
      - guides/**
      - tutorials/**
  
  # API documentation
  - name: api-reference  
    scope:
      - apis/**
  
  # Developer guide
  - scope:
      - development/**
    # Name will be first sidebar item
This generates:
  • user-guide-en.pdf
  • user-guide-zh.pdf
  • api-reference-en.pdf
  • api-reference-zh.pdf
  • Development-en.pdf
  • Development-zh.pdf
  • My Documentation-en.pdf (full docs)
  • My Documentation-zh.pdf (full docs)

Output

During export:
info  Serving...
start Exporting en language documents with 45 pages into user-guide-en.pdf...
ready PDF generated successfully
start Exporting zh language documents with 45 pages into user-guide-zh.pdf...
ready PDF generated successfully
ready Closing the server

PDF Features

Included Elements

  • Full documentation content
  • Images and diagrams
  • Code blocks with syntax highlighting
  • Tables and lists
  • Custom MDX components

Excluded Elements

  • Navigation sidebar
  • Table of contents sidebar
  • Header search
  • Interactive elements (buttons, forms)

Bookmarks

PDF bookmarks are automatically generated from:
  • Sidebar structure
  • Page headings
  • Nested sections
Pages are loaded with ?print query parameter that:
  • Applies print-specific styles
  • Hides interactive elements
  • Optimizes for PDF rendering

Advanced Options

Custom Printer Options

// In source code - printerOptions
{
  ignoreHTTPSErrors: true,
  initScripts: [
    async () => {
      // Set light theme
      localStorage.setItem('rspress-theme-appearance', 'light')
    }
  ],
  outlineContainerSelector: '.rp-doc',
  outlineExcludeSelector: '.rp-toc-exclude *'
}

Custom Outlines

Bookmarks are generated from sidebar structure, overriding default heading-based outlines.

Troubleshooting

”Please build the documentation first”

Run build before export:
doom build
doom export

Port already in use

Specify different port:
doom export --port 4174

PDF is incomplete

Ensure sidebar is properly configured:
themeConfig:
  sidebar:
    /:
      - text: Guide
        items:
          - text: Introduction
            link: /intro

Images not rendering

Check that:
  • Images exist in public/ directory
  • Image paths are correct
  • Build included all assets

Large file size

  • Optimize images before building
  • Use appropriate image formats (WebP, optimized PNG)
  • Consider splitting into multiple PDFs via export scopes

Export hangs

  • Check console for errors
  • Verify all pages are accessible
  • Increase timeout (requires code modification)
  • Check for JavaScript errors in pages

Performance Tips

  1. Pre-optimize Assets - Compress images before building
  2. Use Scopes - Generate smaller, focused PDFs
  3. Exclude APIs - API docs often don’t need PDF export
  4. Clean Build - Ensure clean build before export

Build docs developers (and LLMs) love