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

# Installation

> Add @nemu-ai/pdf to a Node or Bun project

## Install

<CodeGroup>
  ```bash npm theme={null}
  npm install @nemu-ai/pdf
  ```

  ```bash pnpm theme={null}
  pnpm add @nemu-ai/pdf
  ```

  ```bash yarn theme={null}
  yarn add @nemu-ai/pdf
  ```

  ```bash bun theme={null}
  bun add @nemu-ai/pdf
  ```
</CodeGroup>

## Requirements

<CardGroup cols={2}>
  <Card title="Runtime" icon="gear">
    Node 18 or newer, or Bun. The package publishes both ESM and CommonJS builds.
  </Card>

  <Card title="No extra setup" icon="box-open">
    The six variable fonts and the harfbuzz font instancer are bundled in the package. Nothing
    else is required for fonts or weights.
  </Card>
</CardGroup>

## Importing

The package exposes named exports for both APIs and the helpers.

```ts theme={null}
import { Doc, Document, Color, Vector } from "@nemu-ai/pdf";
import type { Block, StyleProperties, ChartData } from "@nemu-ai/pdf";
```

Both ESM `import` and CommonJS `require` are supported.

<CodeGroup>
  ```ts ESM theme={null}
  import { Doc } from "@nemu-ai/pdf";
  ```

  ```js CommonJS theme={null}
  const { Doc } = require("@nemu-ai/pdf");
  ```
</CodeGroup>

## Math fonts (optional)

Formulas are typeset by MathJax. The default math font, `termes`, ships with the package, so
basic LaTeX works out of the box. The other math fonts are optional installs that you add
only if you want them.

<CodeGroup>
  ```bash newcm theme={null}
  npm install @mathjax/mathjax-newcm-font
  ```

  ```bash pagella theme={null}
  npm install @mathjax/mathjax-pagella-font
  ```

  ```bash stix2 theme={null}
  npm install @mathjax/mathjax-stix2-font
  ```
</CodeGroup>

A missing math font logs a warning and falls back to `termes`. See
[Formulas](/packages/pdf/doc/formulas) for the full list and how to select a font.

<Note>
  The heavier MathJax packages are runtime dependencies and are installed alongside the
  package. The library itself is around 2 MB packed, dominated by the bundled fonts.
</Note>

<Card title="Build your first PDF" icon="arrow-right" href="/packages/pdf/quickstart" horizontal>
  Render a document with each API in a few lines.
</Card>
