> ## 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.

# Reference

> Exports, page sizes, the Vector primitive, and the type surface of @nemu-ai/pdf

This page collects the exported values, the type surface, page sizes, and the `Vector`
primitive in one place.

## Exports

The package exports the following values.

```ts theme={null}
import {
  Doc,
  DocPage,
  Document,
  Page,
  Color,
  Theme,
  create_theme,
  Vector,
  vector,
  available_formula_fonts,
  default_formula_font,
  BaseElement,
  TextElement,
  RectElement,
  ImageElement,
  ContainerElement,
  TableElement,
  HeaderContainer,
  FooterContainer,
} from "@nemu-ai/pdf";
```

`Doc` and `DocPage` are the declarative API. `Document` and `Page` are the low level API.
`Color` is the color utility, `Theme` and `create_theme` build themes, and `Vector` with
`vector` are the spatial primitive. `available_formula_fonts` and `default_formula_font`
describe the math fonts for LaTeX. The remaining names are the element classes used by the
low level API.

## Type exports

All of the following are exported as types.

```ts theme={null}
import type {
  Block,
  Inline,
  InlineContent,
  DocOptions,
  PageConfig,
  PageContext,
  HeaderFooter,
  RawDraw,
  DrawArea,
  RoleStyles,
  StyleRole,
  TableCell,
  TableRow,
  ChartKind,
  ChartData,
  ChartSeries,
  ChartSlice,
  StyleProperties,
  DocumentOptions,
  PageSize,
  PageDimensions,
  MarginValues,
  ColorLike,
  ColorInput,
  ColorValue,
  ContainerLayout,
  FlexLayoutOptions,
  FlowLayoutOptions,
  CreateTextOptions,
  CreateRectOptions,
  CreateImageOptions,
  CreateTableOptions,
  CreateContainerOptions,
} from "@nemu-ai/pdf";
```

## Page sizes

`page_size` accepts a named size or `"Custom"`. The named sizes are measured in points.

| Name   | Width (pt) | Height (pt) |
| ------ | ---------- | ----------- |
| A4     | 595.28     | 841.89      |
| Letter | 612        | 792         |
| Legal  | 612        | 1008        |

Use `custom_dimensions` for any other size.

```ts theme={null}
import { Document } from "@nemu-ai/pdf";

const pdf = new Document({ custom_dimensions: { width: 400, height: 600 } });
```

## Vector

`Vector` is the spatial primitive for positions and sizes, and `vector(x, y)` is a
convenience constructor. After `build`, elements expose `get_position()`, `get_size()`, and
`get_bbox()`.

```ts theme={null}
import { Document, vector } from "@nemu-ai/pdf";

const v = vector(100, 200);

const pdf = new Document({ page_size: "A4", margin: 50 });
const page = pdf.create_page();
const label = page.text({ content: "Hello", position: { x: v.x, y: v.y } });
page.add(label);

await pdf.build("out.pdf");

label.get_position();
label.get_size();
label.get_bbox();
```

## For LLMs

The package ships an `llms.txt` API map at its root. It is a single file that lists every
exported type and signature, intended for code generation.

<CardGroup cols={2}>
  <Card title="Color" icon="palette" href="/packages/pdf/color">
    Build a color from one input form and convert it to any other.
  </Card>

  <Card title="Introduction" icon="circle-info" href="/packages/pdf/introduction">
    How the declarative and low level APIs relate.
  </Card>
</CardGroup>
