Skip to content
React PDF Viewer

Search

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

Import

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

Props

NameTypeDefaultRequiredDescription
documentPDFDocumentProxy—YesA loaded document, e.g. from usePdfDocument.
pagenumber—Yes1-based page; clamped to the document.
scalenumber1NoScale, 1 = 100%.
rotationRotation0NoAdded to the page’s intrinsic rotation.
fitFitOptions—NoA box the page must fit into.
maxCanvasPixelsnumber16_777_216NoCanvas pixel budget.
textLayerbooleanfalseNoSelectable text layer.
annotationLayerbooleanfalseNoClickable links.
highlightPageHighlight—NoSearch matches to highlight (requires textLayer).
aria-labelstring—NoAccessible name, e.g. Page 1 of 3. With a name the page is an image (a group with textLayer); without one it is decorative.
classNamestring—NoAdded to the page element.
styleCSSProperties—NoInline styles on the page element.
renderError(error: PdfViewerError, actions: { retry: () => void }) => ReactNode—NoReplaces the in-place error view.

Events

NameTypeDefaultRequiredDescription
onLinkNavigate(page: number) => void—NoAn internal link targets another page.
onHighlight(element: HTMLElement) => void—NoReceives the selected match’s element, e.g. to scroll it into view.
onRender(info: PageRenderInfo) => void—NoAfter each completed render.
onError(error: PdfViewerError) => void—NoRendering failed (cancellations are not failures).

Source

packages/react-pdf-viewer/src/components/PdfPageCanvas.tsx

Generated from content/react-pdf-viewer/reference/pdf-page-canvas.schema.json. Do not edit by hand.