use Pdf Document 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
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
password | string | — | No | Password for encrypted documents. Changing it reloads the document. |
pdfjsOptions | PdfJsDocumentOptions | — | No | Per-instance getDocument overrides. |
onLoad | (document: PDFDocumentProxy) => void | — | No | The document is ready. |
onError | (error: PdfViewerError) => void | — | No | Every load failure except aborts and handled HTTP errors. |
requestInit | RequestInit | — | No | As on PdfViewer. |
fetcher | (url: string, init: RequestInit) => Promise<Response> | — | No | As on PdfViewer. |
onHttpError | (response: Response) => boolean | void | Promise<boolean | void> | — | No | As on PdfViewer. |
getHttpErrorMessage | (response: Response) => Promise<string> | — | No | As 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.