API reference: @salmonui/pdf-viewer
PdfViewerPropsinterface
import type { PdfViewerProps } from '@salmonui/pdf-viewer';interface PdfViewerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onLoad' | 'onError' | 'children' | 'defaultValue'> {
readonly src?: PdfViewerSource | null | undefined;
readonly workerSrc?: string | URL | undefined;
readonly documentOptions?: Readonly<Record<string, unknown>> | undefined;
readonly password?: string | undefined;
readonly onPasswordRequired?: ((request: PdfViewerPasswordRequest) => void) | undefined;
readonly onLoad?: ((info: PdfViewerLoadInfo) => void) | undefined;
readonly onLoadError?: ((error: Error) => void) | undefined;
readonly pageSizes?: readonly PdfPageSize[] | PdfPageSize | undefined;
readonly pageCount?: number | undefined;
readonly page?: number | undefined;
readonly defaultPage?: number | undefined;
readonly onPageChange?: ((page: number, event: {
readonly source: PdfViewerEventSource;
}) => void) | undefined;
readonly zoom?: PdfViewerZoom | undefined;
readonly defaultZoom?: PdfViewerZoom | undefined;
readonly onZoomChange?: ((zoom: PdfViewerZoom, event: {
readonly scale: number;
readonly source: PdfViewerEventSource;
}) => void) | undefined;
readonly scrollMode?: PdfViewerScrollMode | undefined;
readonly spreadMode?: PdfViewerSpreadMode | undefined;
readonly sidebar?: PdfViewerSidebar | null | undefined;
readonly defaultSidebar?: PdfViewerSidebar | null | undefined;
readonly onSidebarChange?: ((sidebar: PdfViewerSidebar | null) => void) | undefined;
readonly toolbar?: readonly PdfViewerToolbarItem[] | false | undefined;
readonly renderToolbar?: ((context: PdfViewerToolbarContext) => ReactNode) | undefined;
readonly textSelection?: boolean | undefined;
readonly linkTarget?: '_blank' | '_self' | '_parent' | '_top' | undefined;
readonly onLinkClick?: ((event: PdfViewerLinkEvent) => void) | undefined;
readonly onBeforePrint?: ((event: PdfViewerCancelableEvent) => void) | undefined;
readonly printResolution?: number | undefined;
readonly fileName?: string | undefined;
readonly onSearchResult?: ((result: PdfViewerSearchResult) => void) | undefined;
readonly annotations?: readonly PdfTextMarkupAnnotation[] | undefined;
readonly defaultAnnotations?: readonly PdfTextMarkupAnnotation[] | undefined;
readonly onAnnotationsChange?: ((annotations: readonly PdfTextMarkupAnnotation[], event: PdfViewerAnnotationsChangeEvent) => void) | undefined;
readonly annotationAuthor?: string | undefined;
readonly annotationColors?: Partial<Record<PdfTextMarkupKind, string>> | undefined;
readonly formValues?: PdfFormValues | undefined;
readonly defaultFormValues?: PdfFormValues | undefined;
readonly onFormValuesChange?: ((values: PdfFormValues, event: {
readonly name: string;
}) => void) | undefined;
readonly actionsRef?: RefObject<PdfViewerActions | null> | ((actions: PdfViewerActions | null) => void) | undefined;
readonly localeText?: Partial<PdfViewerLocaleText> | undefined;
readonly classNames?: Partial<Record<PdfViewerPart, string>> | undefined;
readonly styles?: Partial<Record<PdfViewerPart, CSSProperties>> | undefined;
readonly ref?: Ref<HTMLDivElement> | undefined;
}
| Name | Signature | Description |
|---|---|---|
srcoptional | readonly src?: PdfViewerSource | null | undefined; | The document. Changing it loads the new document. |
workerSrcoptional | readonly workerSrc?: string | URL | undefined; | URL of the pdf.js worker module; default the worker that ships with |
documentOptionsoptional | readonly documentOptions?: Readonly<Record<string, unknown>> | undefined; | Extra |
passwordoptional | readonly password?: string | undefined; | Password of an encrypted document. |
onPasswordRequiredoptional | readonly onPasswordRequired?: ((request: PdfViewerPasswordRequest) => void) | undefined; | Replaces the built-in password dialog. |
onLoadoptional | readonly onLoad?: ((info: PdfViewerLoadInfo) => void) | undefined; | |
onLoadErroroptional | readonly onLoadError?: ((error: Error) => void) | undefined; | |
pageSizesoptional | readonly pageSizes?: readonly PdfPageSize[] | PdfPageSize | undefined; | Page sizes in PDF points the server can lay out before the engine loads; one size applies to every page. |
pageCountoptional | readonly pageCount?: number | undefined; | Number of pages for placeholders when |
pageoptional | readonly page?: number | undefined; | Controlled 1-based page. |
defaultPageoptional | readonly defaultPage?: number | undefined; | |
onPageChangeoptional | readonly onPageChange?: ((page: number, event: {
readonly source: PdfViewerEventSource;
}) => void) | undefined; | |
zoomoptional | readonly zoom?: PdfViewerZoom | undefined; | Controlled zoom. Default |
defaultZoomoptional | readonly defaultZoom?: PdfViewerZoom | undefined; | |
onZoomChangeoptional | readonly onZoomChange?: ((zoom: PdfViewerZoom, event: {
readonly scale: number;
readonly source: PdfViewerEventSource;
}) => void) | undefined; | |
scrollModeoptional | readonly scrollMode?: PdfViewerScrollMode | undefined; | Default |
spreadModeoptional | readonly spreadMode?: PdfViewerSpreadMode | undefined; | Default |
sidebaroptional | readonly sidebar?: PdfViewerSidebar | null | undefined; | Open panel; |
defaultSidebaroptional | readonly defaultSidebar?: PdfViewerSidebar | null | undefined; | |
onSidebarChangeoptional | readonly onSidebarChange?: ((sidebar: PdfViewerSidebar | null) => void) | undefined; | |
toolbaroptional | readonly toolbar?: readonly PdfViewerToolbarItem[] | false | undefined; | Toolbar items; |
renderToolbaroptional | readonly renderToolbar?: ((context: PdfViewerToolbarContext) => ReactNode) | undefined; | Replaces the toolbar. |
textSelectionoptional | readonly textSelection?: boolean | undefined; | Native text selection and copy over the text layer. Default true. |
linkTargetoptional | readonly linkTarget?: '_blank' | '_self' | '_parent' | '_top' | undefined; | Where external links open. Default |
onLinkClickoptional | readonly onLinkClick?: ((event: PdfViewerLinkEvent) => void) | undefined; | Cancellable; |
onBeforePrintoptional | readonly onBeforePrint?: ((event: PdfViewerCancelableEvent) => void) | undefined; | Cancellable. |
printResolutionoptional | readonly printResolution?: number | undefined; | Print resolution in DPI. Default 150. |
fileNameoptional | readonly fileName?: string | undefined; | Download file name. Default |
onSearchResultoptional | readonly onSearchResult?: ((result: PdfViewerSearchResult) => void) | undefined; | |
annotationsoptional | readonly annotations?: readonly PdfTextMarkupAnnotation[] | undefined; | Controlled text markup annotations. |
defaultAnnotationsoptional | readonly defaultAnnotations?: readonly PdfTextMarkupAnnotation[] | undefined; | |
onAnnotationsChangeoptional | readonly onAnnotationsChange?: ((annotations: readonly PdfTextMarkupAnnotation[], event: PdfViewerAnnotationsChangeEvent) => void) | undefined; | |
annotationAuthoroptional | readonly annotationAuthor?: string | undefined; | Author written into new annotations. |
annotationColorsoptional | readonly annotationColors?: Partial<Record<PdfTextMarkupKind, string>> | undefined; | Default colors of the markup kinds. |
formValuesoptional | readonly formValues?: PdfFormValues | undefined; | Controlled AcroForm values by field name; fields not listed keep the document's values. |
defaultFormValuesoptional | readonly defaultFormValues?: PdfFormValues | undefined; | |
onFormValuesChangeoptional | readonly onFormValuesChange?: ((values: PdfFormValues, event: {
readonly name: string;
}) => void) | undefined; | |
actionsRefoptional | readonly actionsRef?: RefObject<PdfViewerActions | null> | ((actions: PdfViewerActions | null) => void) | undefined; | |
localeTextoptional | readonly localeText?: Partial<PdfViewerLocaleText> | undefined; | |
classNamesoptional | readonly classNames?: Partial<Record<PdfViewerPart, string>> | undefined; | |
stylesoptional | readonly styles?: Partial<Record<PdfViewerPart, CSSProperties>> | undefined; | |
refoptional | readonly ref?: Ref<HTMLDivElement> | undefined; |