import { type ReactNode } from 'react'; export type PDFZoomPreset = 'fit-width' | 'fit-page' | 'actual-size' | number; export type PDFPageRotation = 0 | 90 | 180 | 270; /** * Arguments passed to `renderPageOverlay` for each rendered page. * * `pageWidthCss` and `pageHeightCss` are post-zoom, post-rotation CSS * pixel dimensions — exactly the rendered box the consumer is * positioning content over. They update on resize, zoom, and rotation * changes; the render-prop re-runs on every change so positioned * children stay in sync with the page geometry without the consumer * touching a `ResizeObserver`. */ export interface PDFPageOverlayArgs { /** 1-based page number. */ pageNumber: number; /** CSS-pixel width of the rendered page (post-zoom, post-rotation). */ pageWidthCss: number; /** CSS-pixel height of the rendered page. */ pageHeightCss: number; /** * Effective rotation of the rendered viewport in degrees. Reflects * `pageRotation` (if set) overriding the page's intrinsic `/Rotate`, * otherwise the intrinsic rotation. */ rotation: PDFPageRotation; } export interface PDFViewerProps { /** Opaque instance id — emitted as `data-component-id` for the agent registry. */ id?: string; /** PDF source — URL string, ArrayBuffer, or Uint8Array. */ src: string | ArrayBuffer | Uint8Array; /** Initial page (1-based). Default 1. */ initialPage?: number; /** Initial zoom preset. Default 'fit-width'. */ initialZoom?: PDFZoomPreset; /** * Force every page to render at this rotation, overriding the page's * intrinsic `/Rotate` metadata. Useful for scanned PDFs that opened * sideways, and for the signing-flow consumer that lets users * straighten misrotated pages before placing signature fields. * `undefined` (default) honours each page's intrinsic rotation. */ pageRotation?: PDFPageRotation; /** * Render a layer of arbitrary React content positioned over each * rendered PDF page — signature fields, redaction boxes, annotation * pins, anything that needs to live in PDF coordinate space. * * The render-prop is invoked **only for pages currently inside the * IntersectionObserver buffer** (visible ±1), and the returned tree * unmounts when the page leaves the buffer. Consumer-held timers / * fetches / subscriptions in overlay children therefore tear down * automatically with the page. The overlay container is absolutely * positioned, sized to the rendered page, and has * `pointer-events: auto` so consumer children can be interactive. * Consumers position children themselves (typically * `position: absolute; inset-inline-start: %; inset-block-start: %`). * * The render-prop re-runs on resize, zoom, and rotation changes so * positioned children stay aligned without the consumer wiring a * `ResizeObserver`. Pages already declare `data-page-number` on the * `
` ancestor; consumer-rendered children should be * keyboard-reachable per the kit's a11y contract. * * Composition note: PDF.js's `AnnotationLayer` (for native form * fields and link annotations) is not yet wired in — see the file * header TODO. When it lands, `renderPageOverlay` will compose * **above** the AnnotationLayer in z-order, since interactive * consumer content should sit on top of intrinsic page widgets. */ renderPageOverlay?: (args: PDFPageOverlayArgs) => ReactNode; /** Emits when the currently-most-visible page changes. */ onPageChange?: (page: number) => void; /** Emits once the PDF document has loaded. */ onLoadComplete?: (info: { numPages: number; title?: string; }) => void; /** Emits on any load / render error. */ onError?: (error: Error) => void; /** Show the toolbar. Default `true`. */ toolbar?: boolean; /** * Toolbar control set. `'full'` (default) is the editor toolbar (page nav, * page input, zoom, fit-width, search, print). `'minimal'` is a lean, * read-only control set — zoom out / in / preset only — for surfaces like * signing where a signer just reads, scrolls, and occasionally zooms. */ toolbarVariant?: 'full' | 'minimal'; /** Accessible label for the viewer region. */ ariaLabel?: string; /** Extra class names on the wrapper. */ className?: string; } export interface PDFViewerHandle { goToPage: (page: number) => void; setZoom: (zoom: PDFZoomPreset) => void; search: (query: string) => void; print: () => void; /** 1-indexed page currently in view. */ getCurrentPage: () => number; /** Pages in the loaded document, or `0` before it loads. */ getPageCount: () => number; /** Zoom preset or numeric scale currently applied. */ getZoom: () => PDFZoomPreset; /** * Whether the document has loaded. Every action is a silent no-op * while this is `'loading'` or `'error'`. */ getStatus: () => 'loading' | 'ready' | 'error'; /** Number of matches for the active search query. */ getSearchMatchCount: () => number; } declare const wrapperVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string; declare const toolbarVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string; declare const toolbarButtonVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string; export declare const PDFViewer: import("react").ForwardRefExoticComponent>; export { toolbarButtonVariants, toolbarVariants, wrapperVariants }; //# sourceMappingURL=pdf-viewer.d.ts.map