# PdfPageCanvas reference

Renders a single PDF page: cancellable, double-buffered, HiDPI and pixel-capped, with optional text and annotation layers.

The building block for custom viewers, together with `usePdfDocument`.

## Used by

- [Headless](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/headless.md)

## Import

```ts
import { PdfPageCanvas } from '@kingtech/react-pdf-viewer';
```

## Props

| Name | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `document` | `PDFDocumentProxy` | — | Yes | A loaded document, e.g. from `usePdfDocument`. |
| `page` | `number` | — | Yes | 1-based page; clamped to the document. |
| `scale` | `number` | `1` | No | Scale, `1` = 100%. |
| `rotation` | `Rotation` | `0` | No | Added to the page’s intrinsic rotation. |
| `fit` | `FitOptions` | — | No | A box the page must fit into. |
| `maxCanvasPixels` | `number` | `16_777_216` | No | Canvas pixel budget. |
| `textLayer` | `boolean` | `false` | No | Selectable text layer. |
| `annotationLayer` | `boolean` | `false` | No | Clickable links. |
| `highlight` | `PageHighlight` | — | No | Search matches to highlight (requires `textLayer`). |
| `aria-label` | `string` | — | No | Accessible name, e.g. `Page 1 of 3`. With a name the page is an image (a group with `textLayer`); without one it is decorative. |
| `className` | `string` | — | No | Added to the page element. |
| `style` | `CSSProperties` | — | No | Inline styles on the page element. |
| `renderError` | `(error: PdfViewerError, actions: { retry: () => void }) => ReactNode` | — | No | Replaces the in-place error view. |

## Events

| Name | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `onLinkNavigate` | `(page: number) => void` | — | No | An internal link targets another page. |
| `onHighlight` | `(element: HTMLElement) => void` | — | No | Receives the selected match’s element, e.g. to scroll it into view. |
| `onRender` | `(info: PageRenderInfo) => void` | — | No | After each completed render. |
| `onError` | `(error: PdfViewerError) => void` | — | No | Rendering failed (cancellations are not failures). |

## Source

[packages/react-pdf-viewer/src/components/PdfPageCanvas.tsx](https://github.com/kiralygyula92/react-pdf-viewer/blob/main/packages/react-pdf-viewer/src/components/PdfPageCanvas.tsx#L115)

