# API reference

Generated reference for every public component, hook, function and type.

## Components

- [PdfPageCanvas](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-page-canvas.md): Renders a single PDF page: cancellable, double-buffered, HiDPI and pixel-capped, with optional text and annotation layers.
- [PdfToolbar](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-toolbar.md): The default toolbar: zoom, page navigation, fullscreen, rotate, download and print, on one row.
- [PdfViewer](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-viewer.md): A PDF viewer: one page at a time with a toolbar for zoom, navigation, fullscreen, rotation, download and print.

## Hooks

- [useControllableState](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/use-controllable-state.md): The value / defaultValue / onValueChange pattern as a hook: the one behind every controlled prop of the viewer.
- [usePdfDocument](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/use-pdf-document.md): Loads a PDF document. Every source change aborts the previous fetch, discards its result and destroys the previous document; unmounting does the same.

## Functions

- [configurePdfJs](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/configure-pdf-js.md): Configures PDF.js for every viewer instance. Call it once at startup, before the first viewer mounts. Calls merge with previous configuration.

## Types

- [defaultLabels](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/default-labels.md): The default English labels for every user-visible string and accessible name. Override any subset with the labels prop.
- [FitOptions](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/fit-options.md): Constrains a rendered page to a box: fit its width, its height or both, and choose whether it may grow beyond its natural size.
- [FullscreenMode](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/fullscreen-mode.md): How fullscreen is presented: the browser Fullscreen API, a full-viewport overlay, or layout only while the parent presents it.
- [LabelContext](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/label-context.md): Helpers passed to label functions, such as locale-aware number formatting, so custom labels follow the viewer's locale.
- [PageHighlight](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/page-highlight.md): Search highlighting for one page's text layer: the query to mark, and which of the page's matches is the selected one.
- [PageRenderInfo](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/page-render-info.md): Details of a completed page render, passed to onPageRender and onRender: the page, the scale used, its size and the time it took.
- [PdfDocumentStatus](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-document-status.md): Lifecycle status of a document load: idle without a source, loading, ready with a document, or error with a PdfViewerError.
- [PdfJsConfig](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-js-config.md): Global PDF.js configuration shared by every viewer: how the module is loaded, the worker, and the URLs of its assets.
- [PdfJsDocumentOptions](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-js-document-options.md): Per-instance options forwarded to pdfjs-dist's getDocument (for example cMapUrl, standardFontDataUrl or verbosity). Source-related options are managed by the viewer.
- [PdfJsModule](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-js-module.md): The pdfjs-dist module namespace, as returned by the loader of configurePdfJs to supply a specific build.
- [PdfPageCanvasProps](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-page-canvas-props.md): Props for PdfPageCanvas: the document and page to render, its scale, rotation and fit, the optional layers and the render callbacks.
- [PdfRequestOptions](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-request-options.md): Controls how string and URL sources are fetched: extra fetch options, a replacement fetcher and the handling of HTTP errors.
- [PdfSource](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-source.md): A PDF document source: a URL for the viewer to fetch, or a file or bytes that are already in memory.
- [PdfToolbarProps](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-toolbar-props.md): Props for PdfToolbar: the viewer API it controls, its labels and configuration, the compact layout and the page indicator slot.
- [PdfViewerApi](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-viewer-api.md): Imperative viewer API, available through ref and passed to renderToolbar. Values are a snapshot of the render that produced the object.
- [PdfViewerError](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-viewer-error.md): A typed viewer error. Aborted loads and canceled renders are never reported as errors.
- [PdfViewerErrorCode](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-viewer-error-code.md): Machine-readable category of a PdfViewerError, for handling failures such as a missing password or an HTTP error in code.
- [PdfViewerLabels](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-viewer-labels.md): Every user-visible string and accessible name. Defaults are English; override any subset through the labels prop.
- [PdfViewerProps](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/pdf-viewer-props.md): Props for PdfViewer. Every piece of state supports the value / defaultValue / onChange trio.
- [Rotation](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/rotation.md): Clockwise rotation in degrees, relative to the page's natural orientation.
- [SetControllableState](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/set-controllable-state.md): Setter returned by useControllableState; accepts a value or an updater function.
- [ToolbarAction](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/toolbar-action.md): Identifies a toolbar control, for choosing which controls the toolbar shows and in which order through ToolbarConfig.
- [ToolbarConfig](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/toolbar-config.md): Toolbar customization: where the toolbar sits, which controls it shows and in which order, and which it hides on narrow screens.
- [UseControllableStateOptions](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/use-controllable-state-options.md): Options for useControllableState: the controlled value, the initial value while uncontrolled, and the change callback.
- [UsePdfDocumentOptions](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/use-pdf-document-options.md): Options for usePdfDocument. Changes apply on the next load, except password.
- [UsePdfDocumentResult](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/use-pdf-document-result.md): State returned by usePdfDocument: the load status, the document once ready, its page count, the error and a reload function.

## Settings

- [CSS variables](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/css-variables.md): Every custom property the stylesheet reads, with its fallback value. Set them on the viewer or any ancestor.
- [rpv-theme-auto](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/rpv-theme-auto.md): Automatic preset: add className="rpv-theme-auto" to apply the dark values only when the operating system prefers a dark color scheme.
- [rpv-theme-dark](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/rpv-theme-dark.md): Dark preset: add className="rpv-theme-dark" to the viewer to apply these values.

## Commands

- [Keyboard shortcuts](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/api/keyboard-shortcuts.md): Keys the component handles, generated from @shortcut tags next to the implementation.

