# @salmonui/pdf-viewer API reference

> 37 exported symbols of @salmonui/pdf-viewer: 1 component, 2 functions, 17 interfaces, 13 types and 4 constants.

Canonical: https://salmonui.dev/docs/reference/pdf-viewer

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

## Components

### PdfViewer

Kind: component

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewer

```ts
function PdfViewer(props: PdfViewerProps): ReactNode;
```

Props: [`PdfViewerProps`](https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerProps) (its members are the props)

## Functions

### resolveScale

Kind: function

Page: https://salmonui.dev/docs/reference/pdf-viewer/resolveScale

```ts
function resolveScale(zoom: PdfViewerZoom, context: FitContext): number;
```

Resolves a zoom value to a numeric scale (fit modes measure the reference page against the viewport).

### stepScale

Kind: function

Page: https://salmonui.dev/docs/reference/pdf-viewer/stepScale

```ts
function stepScale(scale: number, direction: 1 | -1): number;
```

Next zoom step from `scale` (`direction` 1 zooms in, -1 out).

## Interfaces

### FitContext

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/FitContext

```ts
interface FitContext {
    readonly page: PdfPageSize;
    readonly viewport: {
        readonly width: number;
        readonly height: number;
    };
    readonly scrollMode?: PdfViewerScrollMode | undefined;
    readonly spreadMode?: PdfViewerSpreadMode | undefined;
}
```

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `page` | `readonly page: PdfPageSize;` |  | Size of the reference page in PDF points (displayed orientation). |
| `viewport` | `readonly viewport: {     readonly width: number;     readonly height: number; };` |  | Size of the scroll viewport in CSS px. |
| `scrollMode` | `readonly scrollMode?: PdfViewerScrollMode \| undefined;` | optional |  |
| `spreadMode` | `readonly spreadMode?: PdfViewerSpreadMode \| undefined;` | optional |  |

### PdfPageSize

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfPageSize

```ts
interface PdfPageSize {
    readonly width: number;
    readonly height: number;
}
```

Page size in PDF points (1/72 inch), in the displayed orientation.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `width` | `readonly width: number;` |  |  |
| `height` | `readonly height: number;` |  |  |

### PdfTextMarkupAnnotation

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfTextMarkupAnnotation

```ts
interface PdfTextMarkupAnnotation {
    readonly id: string;
    readonly kind: PdfTextMarkupKind;
    readonly page: number;
    readonly rects: readonly PdfRect[];
    readonly color: string;
    readonly opacity?: number | undefined;
    readonly author?: string | undefined;
    readonly comment?: string | undefined;
    readonly text?: string | undefined;
    readonly createdAt?: string | undefined;
}
```

A text markup annotation. Coordinates are zoom independent.

Members (10):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id: string;` |  |  |
| `kind` | `readonly kind: PdfTextMarkupKind;` |  |  |
| `page` | `readonly page: number;` |  | 1-based page number. |
| `rects` | `readonly rects: readonly PdfRect[];` |  | One rectangle per marked line, PDF user space. |
| `color` | `readonly color: string;` |  | CSS hex color `#rrggbb`. |
| `opacity` | `readonly opacity?: number \| undefined;` | optional | 0..1; default 1 (highlights render with a multiply blend). |
| `author` | `readonly author?: string \| undefined;` | optional |  |
| `comment` | `readonly comment?: string \| undefined;` | optional |  |
| `text` | `readonly text?: string \| undefined;` | optional | The marked text, when known. |
| `createdAt` | `readonly createdAt?: string \| undefined;` | optional | ISO 8601 creation time. |

### PdfViewerActions

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerActions

```ts
interface PdfViewerActions {
    goToPage(page: number): void;
    search(query: string, options?: PdfViewerSearchOptions): Promise<PdfViewerSearchResult>;
    findNext(): void;
    findPrevious(): void;
    clearSearch(): void;
    setZoom(zoom: PdfViewerZoom): void;
    print(): Promise<boolean>;
    save(): Promise<Blob>;
    download(fileName?: string): Promise<void>;
    addTextMarkup(kind: PdfTextMarkupKind, options?: {
        readonly color?: string;
        readonly opacity?: number;
        readonly comment?: string;
    }): readonly PdfTextMarkupAnnotation[];
    removeAnnotation(id: string): void;
    getState(): PdfViewerStateSnapshot;
    openFind(open?: boolean): void;
}
```

Commands (`actionsRef`).

Members (13):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `goToPage` | `goToPage(page: number): void;` |  | Scrolls to a page (1-based, clamped). |
| `search` | `search(query: string, options?: PdfViewerSearchOptions): Promise<PdfViewerSearchResult>;` |  | Runs a search over every page; resolves when all pages are searched. |
| `findNext` | `findNext(): void;` |  |  |
| `findPrevious` | `findPrevious(): void;` |  |  |
| `clearSearch` | `clearSearch(): void;` |  |  |
| `setZoom` | `setZoom(zoom: PdfViewerZoom): void;` |  |  |
| `print` | `print(): Promise<boolean>;` |  | Opens the print dialog; resolves `false` when `onBeforePrint` cancelled. |
| `save` | `save(): Promise<Blob>;` |  | The document with the current form values and text markup annotations written into it. |
| `download` | `download(fileName?: string): Promise<void>;` |  | Saves and downloads as `fileName` (default the `fileName` prop). |
| `addTextMarkup` | `addTextMarkup(kind: PdfTextMarkupKind, options?: {     readonly color?: string;     readonly opacity?: number;     readonly comment?: string; }): readonly PdfTextMarkupAnnotation[];` |  | Marks the current text selection; returns the new annotations (one per page). |
| `removeAnnotation` | `removeAnnotation(id: string): void;` |  |  |
| `getState` | `getState(): PdfViewerStateSnapshot;` |  | Current page, page count and scale. |
| `openFind` | `openFind(open?: boolean): void;` |  | Opens or closes the find bar. |

### PdfViewerAnnotationsChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerAnnotationsChangeEvent

```ts
interface PdfViewerAnnotationsChangeEvent {
    readonly reason: 'create' | 'remove';
    readonly annotation: PdfTextMarkupAnnotation;
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `reason` | `readonly reason: 'create' \| 'remove';` |  |  |
| `annotation` | `readonly annotation: PdfTextMarkupAnnotation;` |  |  |

### PdfViewerCancelableEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerCancelableEvent

```ts
interface PdfViewerCancelableEvent {
    preventDefault(): void;
    readonly defaultPrevented: boolean;
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `preventDefault` | `preventDefault(): void;` |  |  |
| `defaultPrevented` | `readonly defaultPrevented: boolean;` |  |  |

### PdfViewerLinkEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerLinkEvent

```ts
interface PdfViewerLinkEvent extends PdfViewerCancelableEvent {
    readonly url: string | null;
    readonly page: number | null;
}
```

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `url` | `readonly url: string \| null;` |  | External link target; `null` for an internal link. |
| `page` | `readonly page: number \| null;` |  | Target page of an internal link; `null` when external or unresolved. |
| `preventDefault` | `preventDefault: () => void;` | inherited |  |
| `defaultPrevented` | `defaultPrevented: boolean;` | inherited |  |

### PdfViewerLoadInfo

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerLoadInfo

```ts
interface PdfViewerLoadInfo {
    readonly pageCount: number;
    readonly pageSizes: readonly PdfPageSize[];
    readonly title: string | null;
    readonly outline: readonly PdfViewerOutlineItem[];
    readonly formFields: readonly string[];
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `pageCount` | `readonly pageCount: number;` |  |  |
| `pageSizes` | `readonly pageSizes: readonly PdfPageSize[];` |  |  |
| `title` | `readonly title: string \| null;` |  |  |
| `outline` | `readonly outline: readonly PdfViewerOutlineItem[];` |  |  |
| `formFields` | `readonly formFields: readonly string[];` |  | AcroForm field names in document order. |

### PdfViewerLocaleText

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerLocaleText

```ts
interface PdfViewerLocaleText {
    readonly label: string;
    readonly toolbar: string;
    readonly loading: string;
    readonly loadError: string;
    readonly empty: string;
    readonly pageLabel: string;
    readonly pageNumber: string;
    readonly pageOf: string;
    readonly previous: string;
    readonly next: string;
    readonly zoomIn: string;
    readonly zoomOut: string;
    readonly zoom: string;
    readonly zoomAuto: string;
    readonly zoomPageFit: string;
    readonly zoomPageWidth: string;
    readonly sidebar: string;
    readonly thumbnails: string;
    readonly outline: string;
    readonly noOutline: string;
    readonly thumbnailLabel: string;
    readonly search: string;
    readonly findLabel: string;
    readonly findPlaceholder: string;
    readonly findNext: string;
    readonly findPrevious: string;
    readonly matchCase: string;
    readonly wholeWord: string;
    readonly highlightAll: string;
    readonly matchCount: string;
    readonly noMatches: string;
    readonly closeFind: string;
    readonly highlight: string;
    readonly underline: string;
    readonly strikethrough: string;
    readonly print: string;
    readonly download: string;
    readonly passwordTitle: string;
    readonly passwordPrompt: string;
    readonly passwordIncorrect: string;
    readonly passwordLabel: string;
    readonly passwordSubmit: string;
    readonly passwordCancel: string;
    readonly more: string;
}
```

Members (44):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `label` | `readonly label: string;` |  |  |
| `toolbar` | `readonly toolbar: string;` |  |  |
| `loading` | `readonly loading: string;` |  |  |
| `loadError` | `readonly loadError: string;` |  |  |
| `empty` | `readonly empty: string;` |  |  |
| `pageLabel` | `readonly pageLabel: string;` |  |  |
| `pageNumber` | `readonly pageNumber: string;` |  |  |
| `pageOf` | `readonly pageOf: string;` |  |  |
| `previous` | `readonly previous: string;` |  |  |
| `next` | `readonly next: string;` |  |  |
| `zoomIn` | `readonly zoomIn: string;` |  |  |
| `zoomOut` | `readonly zoomOut: string;` |  |  |
| `zoom` | `readonly zoom: string;` |  |  |
| `zoomAuto` | `readonly zoomAuto: string;` |  |  |
| `zoomPageFit` | `readonly zoomPageFit: string;` |  |  |
| `zoomPageWidth` | `readonly zoomPageWidth: string;` |  |  |
| `sidebar` | `readonly sidebar: string;` |  |  |
| `thumbnails` | `readonly thumbnails: string;` |  |  |
| `outline` | `readonly outline: string;` |  |  |
| `noOutline` | `readonly noOutline: string;` |  |  |
| `thumbnailLabel` | `readonly thumbnailLabel: string;` |  |  |
| `search` | `readonly search: string;` |  |  |
| `findLabel` | `readonly findLabel: string;` |  |  |
| `findPlaceholder` | `readonly findPlaceholder: string;` |  |  |
| `findNext` | `readonly findNext: string;` |  |  |
| `findPrevious` | `readonly findPrevious: string;` |  |  |
| `matchCase` | `readonly matchCase: string;` |  |  |
| `wholeWord` | `readonly wholeWord: string;` |  |  |
| `highlightAll` | `readonly highlightAll: string;` |  |  |
| `matchCount` | `readonly matchCount: string;` |  |  |
| `noMatches` | `readonly noMatches: string;` |  |  |
| `closeFind` | `readonly closeFind: string;` |  |  |
| `highlight` | `readonly highlight: string;` |  |  |
| `underline` | `readonly underline: string;` |  |  |
| `strikethrough` | `readonly strikethrough: string;` |  |  |
| `print` | `readonly print: string;` |  |  |
| `download` | `readonly download: string;` |  |  |
| `passwordTitle` | `readonly passwordTitle: string;` |  |  |
| `passwordPrompt` | `readonly passwordPrompt: string;` |  |  |
| `passwordIncorrect` | `readonly passwordIncorrect: string;` |  |  |
| `passwordLabel` | `readonly passwordLabel: string;` |  |  |
| `passwordSubmit` | `readonly passwordSubmit: string;` |  |  |
| `passwordCancel` | `readonly passwordCancel: string;` |  |  |
| `more` | `readonly more: string;` |  |  |

### PdfViewerOutlineItem

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerOutlineItem

```ts
interface PdfViewerOutlineItem {
    readonly id: string;
    readonly title: string;
    readonly page: number | null;
    readonly url: string | null;
    readonly items: readonly PdfViewerOutlineItem[];
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id: string;` |  |  |
| `title` | `readonly title: string;` |  |  |
| `page` | `readonly page: number \| null;` |  | Target page (1-based) when it resolves to one. |
| `url` | `readonly url: string \| null;` |  |  |
| `items` | `readonly items: readonly PdfViewerOutlineItem[];` |  |  |

### PdfViewerPasswordRequest

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerPasswordRequest

```ts
interface PdfViewerPasswordRequest {
    readonly reason: 'required' | 'incorrect';
    submit(password: string): void;
    cancel(): void;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `reason` | `readonly reason: 'required' \| 'incorrect';` |  | `'required'` on the first prompt, `'incorrect'` after a wrong password. |
| `submit` | `submit(password: string): void;` |  |  |
| `cancel` | `cancel(): void;` |  | Gives up; `onLoadError` reports a `PasswordException`. |

### PdfViewerProps

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerProps

```ts
interface PdfViewerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onLoad' | 'onError' | 'children' | 'defaultValue'> {
    readonly src?: PdfViewerSource | null | undefined;
    readonly workerSrc?: string | URL | undefined;
    readonly documentOptions?: Readonly<Record<string, unknown>> | undefined;
    readonly password?: string | undefined;
    readonly onPasswordRequired?: ((request: PdfViewerPasswordRequest) => void) | undefined;
    readonly onLoad?: ((info: PdfViewerLoadInfo) => void) | undefined;
    readonly onLoadError?: ((error: Error) => void) | undefined;
    readonly pageSizes?: readonly PdfPageSize[] | PdfPageSize | undefined;
    readonly pageCount?: number | undefined;
    readonly page?: number | undefined;
    readonly defaultPage?: number | undefined;
    readonly onPageChange?: ((page: number, event: {
        readonly source: PdfViewerEventSource;
    }) => void) | undefined;
    readonly zoom?: PdfViewerZoom | undefined;
    readonly defaultZoom?: PdfViewerZoom | undefined;
    readonly onZoomChange?: ((zoom: PdfViewerZoom, event: {
        readonly scale: number;
        readonly source: PdfViewerEventSource;
    }) => void) | undefined;
    readonly scrollMode?: PdfViewerScrollMode | undefined;
    readonly spreadMode?: PdfViewerSpreadMode | undefined;
    readonly sidebar?: PdfViewerSidebar | null | undefined;
    readonly defaultSidebar?: PdfViewerSidebar | null | undefined;
    readonly onSidebarChange?: ((sidebar: PdfViewerSidebar | null) => void) | undefined;
    readonly toolbar?: readonly PdfViewerToolbarItem[] | false | undefined;
    readonly renderToolbar?: ((context: PdfViewerToolbarContext) => ReactNode) | undefined;
    readonly textSelection?: boolean | undefined;
    readonly linkTarget?: '_blank' | '_self' | '_parent' | '_top' | undefined;
    readonly onLinkClick?: ((event: PdfViewerLinkEvent) => void) | undefined;
    readonly onBeforePrint?: ((event: PdfViewerCancelableEvent) => void) | undefined;
    readonly printResolution?: number | undefined;
    readonly fileName?: string | undefined;
    readonly onSearchResult?: ((result: PdfViewerSearchResult) => void) | undefined;
    readonly annotations?: readonly PdfTextMarkupAnnotation[] | undefined;
    readonly defaultAnnotations?: readonly PdfTextMarkupAnnotation[] | undefined;
    readonly onAnnotationsChange?: ((annotations: readonly PdfTextMarkupAnnotation[], event: PdfViewerAnnotationsChangeEvent) => void) | undefined;
    readonly annotationAuthor?: string | undefined;
    readonly annotationColors?: Partial<Record<PdfTextMarkupKind, string>> | undefined;
    readonly formValues?: PdfFormValues | undefined;
    readonly defaultFormValues?: PdfFormValues | undefined;
    readonly onFormValuesChange?: ((values: PdfFormValues, event: {
        readonly name: string;
    }) => void) | undefined;
    readonly actionsRef?: RefObject<PdfViewerActions | null> | ((actions: PdfViewerActions | null) => void) | undefined;
    readonly localeText?: Partial<PdfViewerLocaleText> | undefined;
    readonly classNames?: Partial<Record<PdfViewerPart, string>> | undefined;
    readonly styles?: Partial<Record<PdfViewerPart, CSSProperties>> | undefined;
    readonly ref?: Ref<HTMLDivElement> | undefined;
}
```

Members (42):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `src` | `readonly src?: PdfViewerSource \| null \| undefined;` | optional | The document. Changing it loads the new document. |
| `workerSrc` | `readonly workerSrc?: string \| URL \| undefined;` | optional | URL of the pdf.js worker module; default the worker that ships with `pdfjs-dist`, bundled through `new Worker(new URL(...))`. |
| `documentOptions` | `readonly documentOptions?: Readonly<Record<string, unknown>> \| undefined;` | optional | Extra `getDocument()` options (`cMapUrl`, `standardFontDataUrl`, `wasmUrl`, `withCredentials`, `httpHeaders`). |
| `password` | `readonly password?: string \| undefined;` | optional | Password of an encrypted document. |
| `onPasswordRequired` | `readonly onPasswordRequired?: ((request: PdfViewerPasswordRequest) => void) \| undefined;` | optional | Replaces the built-in password dialog. |
| `onLoad` | `readonly onLoad?: ((info: PdfViewerLoadInfo) => void) \| undefined;` | optional |  |
| `onLoadError` | `readonly onLoadError?: ((error: Error) => void) \| undefined;` | optional |  |
| `pageSizes` | `readonly pageSizes?: readonly PdfPageSize[] \| PdfPageSize \| undefined;` | optional | Page sizes in PDF points the server can lay out before the engine loads; one size applies to every page. |
| `pageCount` | `readonly pageCount?: number \| undefined;` | optional | Number of pages for placeholders when `pageSizes` is a single size. |
| `page` | `readonly page?: number \| undefined;` | optional | Controlled 1-based page. |
| `defaultPage` | `readonly defaultPage?: number \| undefined;` | optional |  |
| `onPageChange` | `readonly onPageChange?: ((page: number, event: {     readonly source: PdfViewerEventSource; }) => void) \| undefined;` | optional |  |
| `zoom` | `readonly zoom?: PdfViewerZoom \| undefined;` | optional | Controlled zoom. Default `'auto'`. |
| `defaultZoom` | `readonly defaultZoom?: PdfViewerZoom \| undefined;` | optional |  |
| `onZoomChange` | `readonly onZoomChange?: ((zoom: PdfViewerZoom, event: {     readonly scale: number;     readonly source: PdfViewerEventSource; }) => void) \| undefined;` | optional |  |
| `scrollMode` | `readonly scrollMode?: PdfViewerScrollMode \| undefined;` | optional | Default `'vertical'`. |
| `spreadMode` | `readonly spreadMode?: PdfViewerSpreadMode \| undefined;` | optional | Default `'none'`. |
| `sidebar` | `readonly sidebar?: PdfViewerSidebar \| null \| undefined;` | optional | Open panel; `null` closes it. |
| `defaultSidebar` | `readonly defaultSidebar?: PdfViewerSidebar \| null \| undefined;` | optional |  |
| `onSidebarChange` | `readonly onSidebarChange?: ((sidebar: PdfViewerSidebar \| null) => void) \| undefined;` | optional |  |
| `toolbar` | `readonly toolbar?: readonly PdfViewerToolbarItem[] \| false \| undefined;` | optional | Toolbar items; `false` hides the toolbar. |
| `renderToolbar` | `readonly renderToolbar?: ((context: PdfViewerToolbarContext) => ReactNode) \| undefined;` | optional | Replaces the toolbar. |
| `textSelection` | `readonly textSelection?: boolean \| undefined;` | optional | Native text selection and copy over the text layer. Default true. |
| `linkTarget` | `readonly linkTarget?: '_blank' \| '_self' \| '_parent' \| '_top' \| undefined;` | optional | Where external links open. Default `'_blank'`. |
| `onLinkClick` | `readonly onLinkClick?: ((event: PdfViewerLinkEvent) => void) \| undefined;` | optional | Cancellable; `preventDefault()` keeps the viewer from following the link. |
| `onBeforePrint` | `readonly onBeforePrint?: ((event: PdfViewerCancelableEvent) => void) \| undefined;` | optional | Cancellable. |
| `printResolution` | `readonly printResolution?: number \| undefined;` | optional | Print resolution in DPI. Default 150. |
| `fileName` | `readonly fileName?: string \| undefined;` | optional | Download file name. Default `'document.pdf'`. |
| `onSearchResult` | `readonly onSearchResult?: ((result: PdfViewerSearchResult) => void) \| undefined;` | optional |  |
| `annotations` | `readonly annotations?: readonly PdfTextMarkupAnnotation[] \| undefined;` | optional | Controlled text markup annotations. |
| `defaultAnnotations` | `readonly defaultAnnotations?: readonly PdfTextMarkupAnnotation[] \| undefined;` | optional |  |
| `onAnnotationsChange` | `readonly onAnnotationsChange?: ((annotations: readonly PdfTextMarkupAnnotation[], event: PdfViewerAnnotationsChangeEvent) => void) \| undefined;` | optional |  |
| `annotationAuthor` | `readonly annotationAuthor?: string \| undefined;` | optional | Author written into new annotations. |
| `annotationColors` | `readonly annotationColors?: Partial<Record<PdfTextMarkupKind, string>> \| undefined;` | optional | Default colors of the markup kinds. |
| `formValues` | `readonly formValues?: PdfFormValues \| undefined;` | optional | Controlled AcroForm values by field name; fields not listed keep the document's values. |
| `defaultFormValues` | `readonly defaultFormValues?: PdfFormValues \| undefined;` | optional |  |
| `onFormValuesChange` | `readonly onFormValuesChange?: ((values: PdfFormValues, event: {     readonly name: string; }) => void) \| undefined;` | optional |  |
| `actionsRef` | `readonly actionsRef?: RefObject<PdfViewerActions \| null> \| ((actions: PdfViewerActions \| null) => void) \| undefined;` | optional |  |
| `localeText` | `readonly localeText?: Partial<PdfViewerLocaleText> \| undefined;` | optional |  |
| `classNames` | `readonly classNames?: Partial<Record<PdfViewerPart, string>> \| undefined;` | optional |  |
| `styles` | `readonly styles?: Partial<Record<PdfViewerPart, CSSProperties>> \| undefined;` | optional |  |
| `ref` | `readonly ref?: Ref<HTMLDivElement> \| undefined;` | optional |  |

### PdfViewerSearchOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerSearchOptions

```ts
interface PdfViewerSearchOptions {
    readonly matchCase?: boolean | undefined;
    readonly wholeWord?: boolean | undefined;
    readonly highlightAll?: boolean | undefined;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `matchCase` | `readonly matchCase?: boolean \| undefined;` | optional |  |
| `wholeWord` | `readonly wholeWord?: boolean \| undefined;` | optional |  |
| `highlightAll` | `readonly highlightAll?: boolean \| undefined;` | optional | Highlight every match, not only the current one. Default true. |

### PdfViewerSearchResult

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerSearchResult

```ts
interface PdfViewerSearchResult {
    readonly query: string;
    readonly total: number;
    readonly current: number;
    readonly page: number;
    readonly pages: Readonly<Record<number, number>>;
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `query` | `readonly query: string;` |  |  |
| `total` | `readonly total: number;` |  |  |
| `current` | `readonly current: number;` |  | 1-based index of the current match; 0 when there is none. |
| `page` | `readonly page: number;` |  | Page of the current match; 0 when there is none. |
| `pages` | `readonly pages: Readonly<Record<number, number>>;` |  | Matches per page (1-based page -> count). |

### PdfViewerStateSnapshot

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerStateSnapshot

```ts
interface PdfViewerStateSnapshot {
    readonly status: 'empty' | 'loading' | 'password' | 'ready' | 'error';
    readonly page: number;
    readonly pageCount: number;
    readonly scale: number;
    readonly zoom: PdfViewerZoom;
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `status` | `readonly status: 'empty' \| 'loading' \| 'password' \| 'ready' \| 'error';` |  |  |
| `page` | `readonly page: number;` |  |  |
| `pageCount` | `readonly pageCount: number;` |  |  |
| `scale` | `readonly scale: number;` |  | Effective scale (a fit mode resolved). |
| `zoom` | `readonly zoom: PdfViewerZoom;` |  |  |

### PdfViewerToolbarContext

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerToolbarContext

```ts
interface PdfViewerToolbarContext {
    readonly items: ReactNode;
    readonly actions: PdfViewerActions;
    readonly state: PdfViewerStateSnapshot;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `items` | `readonly items: ReactNode;` |  | The built-in toolbar content (place it in your own bar, or ignore it). |
| `actions` | `readonly actions: PdfViewerActions;` |  |  |
| `state` | `readonly state: PdfViewerStateSnapshot;` |  |  |

### PdfViewerToolbarCustomItem

Kind: interface

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerToolbarCustomItem

```ts
interface PdfViewerToolbarCustomItem {
    readonly id: string;
    readonly label: string;
    readonly icon?: ReactNode;
    readonly disabled?: boolean | undefined;
    readonly onSelect?: ((actions: PdfViewerActions) => void) | undefined;
    readonly render?: ((actions: PdfViewerActions) => ReactNode) | undefined;
}
```

A custom toolbar button, or any content through `render`.

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id: string;` |  |  |
| `label` | `readonly label: string;` |  | Accessible name, tooltip and overflow menu text. |
| `icon` | `readonly icon?: ReactNode;` | optional |  |
| `disabled` | `readonly disabled?: boolean \| undefined;` | optional |  |
| `onSelect` | `readonly onSelect?: ((actions: PdfViewerActions) => void) \| undefined;` | optional |  |
| `render` | `readonly render?: ((actions: PdfViewerActions) => ReactNode) \| undefined;` | optional | Replaces the button. |

## Types

### PdfFormValue

Kind: type

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfFormValue

```ts
type PdfFormValue = string | boolean | readonly string[];
```

AcroForm field values by field name: text and choice fields are strings, list boxes string arrays, check boxes booleans, radio groups the selected export value.

### PdfFormValues

Kind: type

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfFormValues

```ts
type PdfFormValues = Readonly<Record<string, PdfFormValue>>;
```

### PdfRect

Kind: type

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfRect

```ts
type PdfRect = readonly [
    number,
    number,
    number,
    number
];
```

A rectangle in PDF user space: `[x1, y1, x2, y2]`, origin at the bottom left of the page.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `0` | `0: number;` | inherited |  |
| `1` | `1: number;` | inherited |  |
| `2` | `2: number;` | inherited |  |
| `3` | `3: number;` | inherited |  |
| `length` | `length: 4;` | inherited |  |

### PdfTextMarkupKind

Kind: type

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfTextMarkupKind

```ts
type PdfTextMarkupKind = 'highlight' | 'underline' | 'strikethrough';
```

### PdfViewerEventSource

Kind: type

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerEventSource

```ts
type PdfViewerEventSource = 'toolbar' | 'keyboard' | 'scroll' | 'pinch' | 'wheel' | 'api' | 'link' | 'outline' | 'thumbnail' | 'search' | 'prop' | 'load';
```

### PdfViewerPart

Kind: type

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerPart

```ts
type PdfViewerPart = 'toolbar' | 'sidebar' | 'viewport' | 'findBar';
```

### PdfViewerScrollMode

Kind: type

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerScrollMode

```ts
type PdfViewerScrollMode = 'vertical' | 'horizontal' | 'wrapped' | 'page';
```

### PdfViewerSidebar

Kind: type

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerSidebar

```ts
type PdfViewerSidebar = 'thumbnails' | 'outline';
```

### PdfViewerSource

Kind: type

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerSource

```ts
type PdfViewerSource = string | URL | ArrayBuffer | Uint8Array | Blob;
```

A document: a URL (string or `URL`) or the bytes (`ArrayBuffer`, `Uint8Array`, `Blob`).

### PdfViewerSpreadMode

Kind: type

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerSpreadMode

```ts
type PdfViewerSpreadMode = 'none' | 'odd' | 'even';
```

`'odd'` starts spreads on odd pages (1-2, 3-4), `'even'` on even pages (1, 2-3).

### PdfViewerToolbarItem

Kind: type

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerToolbarItem

```ts
type PdfViewerToolbarItem = PdfViewerToolbarItemId | '|' | '-' | PdfViewerToolbarCustomItem;
```

Built-in ids, custom items, `'|'` (separator) and `'-'` (spacer).

### PdfViewerToolbarItemId

Kind: type

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerToolbarItemId

```ts
type PdfViewerToolbarItemId = 'sidebar' | 'previous' | 'next' | 'pageNumber' | 'zoomOut' | 'zoomIn' | 'zoom' | 'search' | 'highlight' | 'underline' | 'strikethrough' | 'print' | 'download';
```

### PdfViewerZoom

Kind: type

Page: https://salmonui.dev/docs/reference/pdf-viewer/PdfViewerZoom

```ts
type PdfViewerZoom = number | 'page-fit' | 'page-width' | 'auto';
```

A scale (`1` = 100 %) or a fit mode.

## Constants

### PDF_TO_CSS

Kind: const

Page: https://salmonui.dev/docs/reference/pdf-viewer/PDF_TO_CSS

```ts
const PDF_TO_CSS: number;
```

CSS pixels per PDF point at scale 1.

### PDF_VIEWER_DEFAULT_LOCALE_TEXT

Kind: const

Page: https://salmonui.dev/docs/reference/pdf-viewer/PDF_VIEWER_DEFAULT_LOCALE_TEXT

```ts
const PDF_VIEWER_DEFAULT_LOCALE_TEXT: PdfViewerLocaleText;
```

### PDF_VIEWER_DEFAULT_TOOLBAR

Kind: const

Page: https://salmonui.dev/docs/reference/pdf-viewer/PDF_VIEWER_DEFAULT_TOOLBAR

```ts
const DEFAULT_TOOLBAR: readonly PdfViewerToolbarItem[];
```

### ZOOM_STEPS

Kind: const

Page: https://salmonui.dev/docs/reference/pdf-viewer/ZOOM_STEPS

```ts
const ZOOM_STEPS: readonly number[];
```

Zoom steps of the zoom in / out commands and the zoom menu.
