> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kiwifs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Document export

> Render markdown to PDF, HTML, slides, or a static site.

Beyond JSONL and CSV, KiwiFS can **render** markdown into deliverable formats using Pandoc, Marp, MkDocs, and Typst tooling (bundled in the Docker image). The web UI also supports in-browser PDF export via Typst without server-side dependencies.

## Endpoint

```http theme={null}
POST /api/kiwi/export/document
Content-Type: application/json
```

## Request body

<ParamField body="format" type="string" required>
  Output format: `pdf`, `html`, `slides`, `site`, or `mkdocs`.
</ParamField>

<ParamField body="path" type="string" required>
  File or directory under the knowledge root to render.
</ParamField>

<ParamField body="theme" type="string">
  Theme name for HTML/PDF output.
</ParamField>

<ParamField body="self_contained" type="boolean" default="false">
  Produce a single-file HTML with embedded assets.
</ParamField>

<ParamField body="bibliography" type="string">
  BibTeX path for citations.
</ParamField>

<ParamField body="csl_style" type="string">
  Citation style preset: `apa`, `ieee`, `chicago`, `vancouver`, or `harvard`.
</ParamField>

<ParamField body="pdf_engine" type="string">
  PDF engine: `typst` or `xelatex` (default: auto-detect).
</ParamField>

<ParamField body="slide_format" type="string">
  Slide format (Marp).
</ParamField>

<ParamField body="site_name" type="string">
  Static site title (for `site` format).
</ParamField>

<ParamField body="site_url" type="string">
  Canonical site URL.
</ParamField>

<ParamField body="repo_url" type="string">
  Edit-on-GitHub style link for the generated site.
</ParamField>

## Examples

<Tabs>
  <Tab title="CLI">
    ```bash theme={null}
    kiwifs export --format pdf --path docs/report.md --output report.pdf --theme paper
    kiwifs export --format html --path concepts/ --self-contained --output site.html
    kiwifs export --format slides --path talks/intro.md --output slides.html
    kiwifs export --format site --path docs/ --site-name "My Wiki" --output docs-site.zip
    kiwifs export --format mkdocs --path docs/ --site-name "My Wiki" --output docs-project/
    ```
  </Tab>

  <Tab title="REST">
    ```bash theme={null}
    curl -X POST 'http://localhost:3333/api/kiwi/export/document' \
      -H 'Content-Type: application/json' \
      -d '{"format":"pdf","path":"pages/report.md"}' \
      -o report.pdf
    ```

    ```bash theme={null}
    curl -X POST 'http://localhost:3333/api/kiwi/export/document' \
      -H 'Content-Type: application/json' \
      -d '{"format":"html","path":"concepts/","self_contained":true}' \
      -o site.html
    ```

    ```bash theme={null}
    curl -X POST 'http://localhost:3333/api/kiwi/export/document' \
      -H 'Content-Type: application/json' \
      -d '{"format":"slides","path":"talks/intro.md","slide_format":"marp"}' \
      -o intro.pdf
    ```
  </Tab>
</Tabs>

<Note>
  The response streams the rendered artifact with an appropriate `Content-Type`. Large exports may take up to **five minutes** server-side.
</Note>

## MCP

**`kiwi_export_document`** accepts the same options for agent-driven publishing workflows.

## Format details

<AccordionGroup>
  <Accordion title="PDF (Typst or XeLaTeX)">
    Uses Typst by default for fast compilation. Falls back to XeLaTeX via Pandoc when Typst is unavailable. The web UI also provides in-browser PDF export via a bundled Typst WASM compiler — no server-side tools required.
  </Accordion>

  <Accordion title="MkDocs project">
    The `mkdocs` format generates a complete MkDocs project directory with `mkdocs.yml`, navigation, and theme configuration. Build the static site with `mkdocs build` or preview with `mkdocs serve`.
  </Accordion>

  <Accordion title="Slides (Marp)">
    Renders Marp-formatted markdown into HTML, PDF, or PPTX slides. Use `slide_format` to control the output type.
  </Accordion>

  <Accordion title="Static site">
    The `site` format produces a ready-to-deploy static site as a ZIP archive, with navigation generated from the directory structure.
  </Accordion>
</AccordionGroup>

## Docker requirement

<Warning>
  Server-side PDF (via Pandoc/Typst CLI) and site generation depend on external tools bundled in the official Docker image. Bare-metal installs may need Pandoc and related dependencies installed separately. In-browser PDF export via the web UI works without these dependencies.
</Warning>

## Related documentation

<CardGroup cols={2}>
  <Card title="Export overview" icon="upload" href="/export/overview">
    JSONL, CSV, and Parquet export.
  </Card>

  <Card title="Import/export API" icon="arrows-rotate" href="/api/import-export">
    REST reference.
  </Card>
</CardGroup>
