Skip to content
React PDF Viewer

Search

usePdfDocument reference

Loads a PDF document. Every source change aborts the previous fetch, discards its result and destroys the previous document; unmounting does the same.

Used by

Import

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

Signature: usePdfDocument(source: PdfSource | null, options?: UsePdfDocumentOptions): UsePdfDocumentResult → UsePdfDocumentResult

Options

NameTypeDefaultRequiredDescription
passwordstring—NoPassword for encrypted documents. Changing it reloads the document.
pdfjsOptionsPdfJsDocumentOptions—NoPer-instance getDocument overrides.
onLoad(document: PDFDocumentProxy) => void—NoThe document is ready.
onError(error: PdfViewerError) => void—NoEvery load failure except aborts and handled HTTP errors.
requestInitRequestInit—NoAs on PdfViewer.
fetcher(url: string, init: RequestInit) => Promise<Response>—NoAs on PdfViewer.
onHttpError(response: Response) => boolean | void | Promise<boolean | void>—NoAs on PdfViewer.
getHttpErrorMessage(response: Response) => Promise<string>—NoAs on PdfViewer.

Source

packages/react-pdf-viewer/src/hooks/usePdfDocument.ts

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