> ## 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 pages or folders to PDF, HTML, slide decks, and static sites.

Document export turns markdown into files you can hand to people: a PDF report, a standalone HTML page, a slide deck, or a documentation site. Export one page, or a whole folder compiled into a book.

There are two ways to export:

* **From the web UI**, any page can be saved as a PDF in the browser, with nothing installed on the server.
* **From the CLI, REST API, or MCP**, KiwiFS runs Pandoc, Marp, or MkDocs on the server for every format and option.

## Export a page from the web UI

Open a page, click the page actions menu, and choose **Export as PDF**. The web UI compiles the PDF in your browser with Typst. Wiki links print as their link text, and embeds such as `![[diagram.png]]` are left out.

The same menu has **Export as Markdown**, which downloads the page's source file.

> [!NOTE]
>
> The browser loads the Typst compiler from the jsDelivr CDN the first time you export, so the browser needs internet access.

## Server-side export

> [tab] CLI
>
> ```bash Terminal theme={null}
> kiwifs export --format pdf --path docs/report.md --theme paper -o report.pdf
> kiwifs export --format pdf --path handbook/ -o handbook.pdf
> kiwifs export --format html --path concepts/auth.md --self-contained -o auth.html
> kiwifs export --format slides --path talks/intro.md --slide-format pdf -o intro.pdf
> kiwifs export --format site --path docs/ --site-name "My Wiki" -o docs-site.zip
> ```
>
> Without `-o`, the file is named after the input, such as `report.pdf`. The CLI shares its `--root`, `--path`, and `--output` flags with [data export](https://docs.kiwifs.com/export/overview.md).

> [tab] REST
>
> ```bash Terminal theme={null}
> curl -X POST http://localhost:3333/api/kiwi/export/document \
>   -H "Content-Type: application/json" \
>   -d '{"format": "pdf", "path": "docs/report.md", "theme": "paper"}' \
>   -o report.pdf
> ```
>
> The response is the rendered file, with a matching `Content-Type` and a `Content-Disposition: attachment` file name.

> [tab] MCP
>
> ```json kiwi_export_document theme={null}
> { "format": "pdf", "path": "docs/report.md", "theme": "paper" }
> ```
>
> The tool writes the file to a temporary path on the server and returns that path. Small HTML results come back inline. It works in local mode (`kiwifs mcp --root`) only.

Rendering stops after five minutes.

## Formats and required tools

| Format | Output | Needs on the server |
| - | - | - |
| `pdf` | PDF | Pandoc, plus Typst or XeLaTeX |
| `html` | HTML page | Pandoc |
| `slides` | HTML, PDF, or PPTX deck from [Marp](https://marp.app) markdown | Marp CLI. PDF and PPTX also need Chromium. |
| `site` | ZIP of a built MkDocs site | MkDocs |
| `mkdocs` (CLI only) | An MkDocs project folder with `mkdocs.yml` | Nothing |

For PDF, KiwiFS uses Typst when it's installed and falls back to XeLaTeX. Over REST and MCP, `mkdocs` and `docs` are aliases for `site`.

> [!WARNING]
>
> The KiwiFS Docker image includes Pandoc, Marp CLI, Chromium, and MkDocs, but not Typst or XeLaTeX. Server-side PDF export in the container fails with `no PDF engine available` until you add one, for example in a derived image. In-browser PDF export from the web UI works either way.

## Options

| CLI flag | REST and MCP field | Description |
| - | - | - |
| `--path` | `path` | Page or folder to export (required) |
| `--theme` | `theme` | `paper`, `modern`, `minimal`, `dark`, or `presentation` |
| `--self-contained` | `self_contained` | Embed images, CSS, and fonts in the HTML |
| `--bibliography` | `bibliography` | `.bib` or CSL JSON file for citations |
| `--csl` | `csl_style` | Citation style name |
| `--crossref` | `crossref` | Number figures, tables, and equations. Needs `pandoc-crossref`. |
| `--pdf-engine` | `pdf_engine` | `typst` or `xelatex` |
| `--slide-format` | `slide_format` | `html` (default), `pdf`, or `pptx` |
| `--site-name` | `site_name` | Site title for `site` and `mkdocs` |
| `--site-url` | `site_url` | Canonical site URL |
| `--repo-url` | `repo_url` | Repository link shown on the site |
| | `metadata` | Extra Pandoc metadata as string key-value pairs (REST only) |

KiwiFS looks for the citation style as `.kiwi/references/<name>.csl`, then `<name>.csl` at the knowledge root. Put the CSL file for `apa`, `ieee`, or any other style in one of those places. Without a matching file, Pandoc uses its default style.

## Export a folder as a book

When `path` is a folder, KiwiFS stitches its pages into one document with a table of contents. It orders pages by:

1. The `parts` list in a `_book.yaml` file in the folder, if there is one.
2. Otherwise, an `order` or `nav_order` frontmatter field, then a numeric file name prefix such as `01-intro.md`, then the file name.

```yaml handbook/_book.yaml theme={null}
title: Engineering handbook
author: Platform team
parts:
  - intro.md
  - onboarding.md
  - on-call.md
```

`_book.yaml` can also set `date`, `lang`, `theme`, and `template`.

## Related

> [card] [Data export](https://docs.kiwifs.com/export/overview.md)
>
> JSONL, CSV, and Parquet.

> [card] [Publishing](https://docs.kiwifs.com/concepts/publishing.md)
>
> Share pages on the web without exporting.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.