# @salmonui/export/pdf API reference

> 10 exported symbols of @salmonui/export/pdf: 2 functions, 5 interfaces, 2 types and 1 constant.

Canonical: https://salmonui.dev/docs/reference/export/pdf

```ts
import { … } from '@salmonui/export/pdf';
```

## Functions

### exportPdf

Kind: function

Page: https://salmonui.dev/docs/reference/export/pdf/exportPdf

```ts
function exportPdf<Row>(source: ExportSource<Row>, options?: PdfExportOptions<Row>, handlers?: ExportHandlers<Row>): Promise<ExportFile | null>;
```

Exports a grid as PDF. Resolves to `{ fileName, mimeType, data }`, or null
when `onBeforeExport` prevents it.

### writePdf

Kind: function

Page: https://salmonui.dev/docs/reference/export/pdf/writePdf

```ts
function writePdf<Row>(model: ExportModel<Row>, options?: PdfOptions): Promise<Uint8Array>;
```

Writes an export model as PDF bytes.

## Interfaces

### PdfExportOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/export/pdf/PdfExportOptions

```ts
interface PdfExportOptions<Row> extends ExportOptions<Row>, PdfOptions {
}
```

Members (23):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `pages` | `pages?: "all" \| "current";` | optional, inherited | `all` (default): every page of the current query. `current`: the current page as shown. |
| `includeHiddenColumns` | `includeHiddenColumns?: boolean;` | optional, inherited | Include hidden columns. Default false. |
| `rows` | `rows?: readonly Row[];` | optional, inherited | Rows to export instead of the grid rows (for example the selected rows), with the grid's columns. |
| `columns` | `columns?: readonly ExportColumnOption[];` | optional, inherited | Export-only columns, in order. |
| `fileName` | `fileName?: string;` | optional, inherited | Download name; the format extension is added when missing. Default `export`. |
| `hierarchy` | `hierarchy?: "all" \| "expanded" \| "none";` | optional, inherited | Detail and child-grid rows: `expanded` (default), `all`, or `none`. |
| `tree` | `tree?: "all" \| "expanded";` | optional, inherited | Tree mode rows: `expanded` (default) exports the visible rows in pre-order; `all` exports every kept row regardless of expansion (XLSX `outlineCollapsed` then keeps the collapsed state). |
| `styles` | `styles?: ExportStyles;` | optional, inherited |  |
| `sliceMs` | `sliceMs?: number;` | optional, inherited | Time slice in ms before the writer yields to the event loop. Default 25. |
| `yield` | `yield?: YieldFn;` | optional, inherited | Awaited between slices. Default: a macrotask. |
| `pageSize` | `pageSize?: readonly [number, number] \| PdfPageSize;` | optional, inherited | Default `a4`, or `[width, height]` in points. |
| `orientation` | `orientation?: "landscape" \| "portrait";` | optional, inherited | Default `portrait`. |
| `margin` | `margin?: number;` | optional, inherited | Page margin in points. Default 36. |
| `fontSize` | `fontSize?: number;` | optional, inherited | Body font size in points. Default 8. |
| `columnOverflow` | `columnOverflow?: "fit" \| "paginate";` | optional, inherited | `fit` (default) scales columns to the page width; `paginate` continues them on extra page sets. |
| `header` | `header?: string;` | optional, inherited | Page header text; `{page}` and `{pages}` are replaced. |
| `footer` | `footer?: string;` | optional, inherited | Page footer text; default `{page} / {pages}`. Empty string for none. |
| `includeHeaders` | `includeHeaders?: boolean;` | optional, inherited | Header rows. Default true. |
| `title` | `title?: string;` | optional, inherited | Document title (`/Title`). |
| `compress` | `compress?: boolean;` | optional, inherited | Deflate content streams (when the platform has `CompressionStream`). Default true. |
| `font` | `font?: PdfFont \| PdfFontData;` | optional, inherited | TrueType font bytes (`.ttf`, or the first font of a `.ttc`) to embed for all text, required for characters outside WinAnsi (CJK, Cyrillic, Greek, Hebrew, Arabic). Only the used glyphs are embedded. `bold` defaults to a synthetic bold of `regular`. No font is bundled. |
| `mergeRepeatedValues` | `mergeRepeatedValues?: boolean;` | optional, inherited | Merge repeated values in consecutive data rows, as XLSX. Default false. |
| `appendImages` | `appendImages?: readonly ExportImage[];` | optional, inherited | Pages after the table, one PNG or JPEG image each (`width` / `height` in CSS px), scaled down to fit the page body and centered: a chart image beside the table in one PDF. An image that cannot be embedded adds no page. |

### PdfFont

Kind: interface

Page: https://salmonui.dev/docs/reference/export/pdf/PdfFont

```ts
interface PdfFont {
    readonly regular: PdfFontData;
    readonly bold?: PdfFontData;
}
```

Embedded TrueType fonts; `bold` defaults to a stroked (synthetic) bold of `regular`.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `regular` | `readonly regular: PdfFontData;` |  |  |
| `bold` | `readonly bold?: PdfFontData;` | optional |  |

### PdfOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/export/pdf/PdfOptions

```ts
interface PdfOptions extends ExportWriterOptions {
    readonly pageSize?: PdfPageSize | readonly [
        number,
        number
    ];
    readonly orientation?: 'portrait' | 'landscape';
    readonly margin?: number;
    readonly fontSize?: number;
    readonly columnOverflow?: 'fit' | 'paginate';
    readonly header?: string;
    readonly footer?: string;
    readonly includeHeaders?: boolean;
    readonly title?: string;
    readonly compress?: boolean;
    readonly font?: PdfFont | PdfFontData;
    readonly mergeRepeatedValues?: boolean;
    readonly appendImages?: readonly ExportImage[];
}
```

PDF writer options.

Members (16):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `pageSize` | `readonly pageSize?: PdfPageSize \| readonly [     number,     number ];` | optional | Default `a4`, or `[width, height]` in points. |
| `orientation` | `readonly orientation?: 'portrait' \| 'landscape';` | optional | Default `portrait`. |
| `margin` | `readonly margin?: number;` | optional | Page margin in points. Default 36. |
| `fontSize` | `readonly fontSize?: number;` | optional | Body font size in points. Default 8. |
| `columnOverflow` | `readonly columnOverflow?: 'fit' \| 'paginate';` | optional | `fit` (default) scales columns to the page width; `paginate` continues them on extra page sets. |
| `header` | `readonly header?: string;` | optional | Page header text; `{page}` and `{pages}` are replaced. |
| `footer` | `readonly footer?: string;` | optional | Page footer text; default `{page} / {pages}`. Empty string for none. |
| `includeHeaders` | `readonly includeHeaders?: boolean;` | optional | Header rows. Default true. |
| `title` | `readonly title?: string;` | optional | Document title (`/Title`). |
| `compress` | `readonly compress?: boolean;` | optional | Deflate content streams (when the platform has `CompressionStream`). Default true. |
| `font` | `readonly font?: PdfFont \| PdfFontData;` | optional | TrueType font bytes (`.ttf`, or the first font of a `.ttc`) to embed for all text, required for characters outside WinAnsi (CJK, Cyrillic, Greek, Hebrew, Arabic). Only the used glyphs are embedded. `bold` defaults to a synthetic bold of `regular`. No font is bundled. |
| `mergeRepeatedValues` | `readonly mergeRepeatedValues?: boolean;` | optional | Merge repeated values in consecutive data rows, as XLSX. Default false. |
| `appendImages` | `readonly appendImages?: readonly ExportImage[];` | optional | Pages after the table, one PNG or JPEG image each (`width` / `height` in CSS px), scaled down to fit the page body and centered: a chart image beside the table in one PDF. An image that cannot be embedded adds no page. |
| `styles` | `styles?: ExportStyles;` | optional, inherited |  |
| `sliceMs` | `sliceMs?: number;` | optional, inherited | Time slice in ms before the writer yields to the event loop. Default 25. |
| `yield` | `yield?: YieldFn;` | optional, inherited | Awaited between slices. Default: a macrotask. |

## Types

### PdfFontData

Kind: type

Page: https://salmonui.dev/docs/reference/export/pdf/PdfFontData

```ts
type PdfFontData = Uint8Array | ArrayBuffer;
```

Font file bytes.

### PdfPageSize

Kind: type

Page: https://salmonui.dev/docs/reference/export/pdf/PdfPageSize

```ts
type PdfPageSize = 'a0' | 'a1' | 'a2' | 'a3' | 'a4' | 'a5' | 'b4' | 'b5' | 'letter' | 'legal' | 'ledger' | 'tabloid' | 'half-letter' | 'note';
```

## Constants

### PDF_MIME_TYPE

Kind: const

Page: https://salmonui.dev/docs/reference/export/pdf/PDF_MIME_TYPE

```ts
const PDF_MIME_TYPE = "application/pdf";
```

## Re-exported entry points

- [@salmonui/export/xlsx](https://salmonui.dev/docs/reference/export/xlsx.md): 2 symbols: 2 interfaces
  `ExportStyles`, `ExportWriterOptions`
