import * as _angular_core from '@angular/core'; import { AfterViewInit, ElementRef, TemplateRef, InjectionToken, Provider, DestroyRef } from '@angular/core'; /** A single entry in a PDF document outline (recursive tree) */ interface PDFOutlineItem { title: string; bold?: boolean; italic?: boolean; url?: string; dest?: unknown; items: PDFOutlineItem[]; } interface PDFPageViewport { width: number; height: number; scale: number; rotation: number; } interface PDFPageProxy { pageNumber: number; rotate: number; view: [number, number, number, number]; getViewport(params: { scale: number; rotation?: number; }): PDFPageViewport; render(params: unknown): { promise: Promise; cancel: () => void; }; getTextContent(): Promise; cleanup(): void; } interface PDFDocumentProxy { numPages: number; fingerprints: [string, string | null]; getPage(pageNumber: number): Promise; getMetadata(): Promise; getData(): Promise; getOutline(): Promise; /** * Releases document resources. There is no `destroy()` on PDFDocumentProxy — * tearing a document down means destroying its `PDFDocumentLoadingTask`. */ cleanup(keepLoadedFonts?: boolean): Promise; } interface PDFDocumentMetadata { info: Record; metadata: unknown; } interface PDFDocumentLoadingTask { readonly promise: Promise; readonly destroyed: boolean; onPassword?: (callback: (password: string) => void, reason: number) => void; onProgress?: (progressData: PDFProgressData) => void; destroy(): Promise; } interface PDFProgressData { loaded: number; total: number; } interface PDFDataRangeTransport { length: number; initialData: Uint8Array; abort(): void; requestDataRange(begin: number, end: number): void; } type PDFSource = string | URL | Uint8Array | ArrayBuffer | PDFDocumentParameters | PDFDataRangeTransport; interface DocumentParamsInput { src: string | Uint8Array | PDFSource | undefined; cMapsUrl?: string | null; standardFontDataUrl?: string | null; wasmUrl?: string | null; iccUrl?: string | null; enableXfa?: boolean; } interface PDFDocumentParameters { url?: string | URL; data?: Uint8Array | ArrayBuffer | number[]; httpHeaders?: Record; withCredentials?: boolean; password?: string; length?: number; range?: PDFDataRangeTransport; rangeChunkSize?: number; worker?: unknown; verbosity?: number; docBaseUrl?: string; cMapUrl?: string; cMapPacked?: boolean; CMapReaderFactory?: unknown; useSystemFonts?: boolean; standardFontDataUrl?: string; StandardFontDataFactory?: unknown; wasmUrl?: string; iccUrl?: string; useWorkerFetch?: boolean; isEvalSupported?: boolean; isOffscreenCanvasSupported?: boolean; canvasMaxAreaInBytes?: number; disableFontFace?: boolean; fontExtraProperties?: boolean; enableXfa?: boolean; ownerDocument?: Document; disableRange?: boolean; disableStream?: boolean; disableAutoFetch?: boolean; pdfBug?: boolean; } type PdfViewerErrorCode = 'LOAD_FAILED' | 'PASSWORD_REQUIRED' | 'PASSWORD_CANCELLED' | 'INVALID_SOURCE' | 'INVALID_STATE' | 'RENDER_FAILED'; declare class PdfViewerError extends Error { readonly code: PdfViewerErrorCode; readonly cause?: unknown | undefined; name: string; constructor(code: PdfViewerErrorCode, message: string, cause?: unknown | undefined); } declare function toPdfViewerError(err: unknown): PdfViewerError; interface GlobalWorkerOptions { workerPort?: unknown; workerSrc?: string; } interface PDFJsLib { version: string; build: string; getDocument(params: string | Uint8Array | PDFDocumentParameters): PDFDocumentLoadingTask; GlobalWorkerOptions: GlobalWorkerOptions; PDFWorker: new (params?: { name?: string; port?: unknown; verbosity?: number; }) => unknown; PDFDataRangeTransport: new (length: number, initialData: Uint8Array) => unknown; PasswordResponses: { NEED_PASSWORD: number; INCORRECT_PASSWORD: number; }; InvalidPDFException: new (message: string) => Error; /** * pdf.js 6 collapsed `MissingPDFException` and `UnexpectedResponseException` * into this single class; neither of the old names exists on the module any * more. `missing` is true for a 404-style absent document. */ ResponseException: new (message: string, status: number, missing: boolean) => Error & { status: number; missing: boolean; }; } interface LinkTarget { NONE: number; SELF: number; BLANK: number; PARENT: number; TOP: number; } /** * pdf.js's EventBus — not an EventTarget: it keeps its own listener map and * hands listeners the raw payload, so keys like `type` are ordinary data. */ interface EventBus { on(eventName: string, listener: (event: any) => void): void; off(eventName: string, listener: (event: any) => void): void; dispatch(eventName: string, data?: unknown): void; } interface PDFLinkService { eventBus: EventBus; externalLinkTarget: number | null; externalLinkRel: string; externalLinkEnabled: boolean; setDocument(pdfDocument: unknown, baseUrl?: string | null): void; setViewer(pdfViewer: unknown): void; setHistory(pdfHistory: unknown): void; navigateTo(dest: unknown): void; getDestinationHash(dest: unknown): string; getAnchorUrl(hash: string): string; setHash(hash: string): void; executeNamedAction(action: string): void; cachePageRef(pageNum: number, pageRef: unknown): void; isPageVisible(pageNumber: number): boolean; } interface PDFFindController { executeCommand(command: string, state: unknown): void; setDocument(pdfDocument: unknown): void; } interface PDFViewer { container: HTMLDivElement; eventBus: EventBus; linkService: PDFLinkService; findController?: PDFFindController; currentPageNumber: number; currentScale: number | string; pagesRotation: number; firstPagePromise: Promise; _pages: unknown[]; _currentPageNumber: number; setDocument(pdfDocument: unknown): void; scrollPageIntoView(params: { pageNumber: number; destArray?: unknown; allowNegativeOffset?: boolean; ignoreDestinationZoom?: boolean; }): void; forceRendering(currentlyVisiblePages?: unknown): boolean; cleanup(): void; update(): void; } interface PDFJsViewer { EventBus: new () => EventBus; PDFLinkService: new (config: { eventBus: EventBus; externalLinkTarget?: number; externalLinkRel?: string; externalLinkEnabled?: boolean; }) => PDFLinkService; PDFFindController: new (config: { eventBus: EventBus; linkService: PDFLinkService; }) => PDFFindController; PDFViewer: new (config: PDFViewerConstructorOptions) => PDFViewer; PDFSinglePageViewer: new (config: PDFViewerConstructorOptions) => PDFViewer; GenericL10n: new (locale: string) => unknown; LinkTarget?: LinkTarget; } interface PDFViewerConstructorOptions { container: HTMLDivElement; viewer?: HTMLDivElement; eventBus: EventBus; linkService?: PDFLinkService; findController?: PDFFindController; renderer?: string; textLayerMode?: number; annotationMode?: number; annotationEditorMode?: number; enableAutoLinking?: boolean; annotationEditorHighlightColors?: unknown; enablePrintAutoRotate?: boolean; imageResourcesPath?: string; removePageBorders?: boolean; useOnlyCssZoom?: boolean; maxCanvasPixels?: number; l10n?: unknown; } interface PDFJsBundle { lib: PDFJsLib; viewer: PDFJsViewer; AnnotationMode?: { DISABLE: number; ENABLE: number; ENABLE_FORMS: number; ENABLE_STORAGE: number; }; AnnotationEditorType?: { DISABLE: number; }; } type ZoomScale = 'page-height' | 'page-fit' | 'page-width'; type ExternalLinkTarget = 'blank' | 'none' | 'self' | 'parent' | 'top'; declare enum RenderTextMode { DISABLED = 0, ENABLED = 1, ENHANCED = 2 } type AnnotationDisplayMode = 'none' | 'enabled' | 'forms' | 'storage'; interface PdfViewerOptions { src?: string | Uint8Array | Record; page?: number; renderText?: boolean; renderTextMode?: RenderTextMode; originalSize?: boolean; stickToPage?: boolean; zoom?: number; zoomScale?: ZoomScale; rotation?: number; autoresize?: boolean; fitToPage?: boolean; showBorders?: boolean; cMapsUrl?: string | null; externalLinkTarget?: ExternalLinkTarget; locale?: string; annotationMode?: number; } interface ScaleCalculationParams { viewportWidth: number; viewportHeight: number; containerWidth: number; containerHeight: number; zoom: number; zoomScale: ZoomScale; showBorders: boolean; } /** Configuration for PDF.js loading and viewer behavior. pdf.js loads from a CDN by default — see Getting Started. */ interface PdfViewerConfig { /** Overrides the default CDN base URL (e.g. cdnjs, unpkg, or a self-hosted mirror). */ cdnBaseUrl?: string; /** Override the PDF.js worker URL (rarely needed; defaults to the CDN's). */ workerSrc?: string; /** Override the CMap URL for CJK text rendering (rarely needed; defaults to the CDN's). */ cMapsUrl?: string | null; /** Override the standard-fonts URL (rarely needed; defaults to the CDN's). */ standardFontDataUrl?: string | null; /** * Override the URL of pdf.js's WebAssembly decoders — OpenJPEG (JPEG 2000), * JBIG2 and QCMS (rarely needed; defaults to the CDN's). Without it pdf.js * cannot decode those images at all, so self-hosting means serving pdf.js's * `wasm/` directory alongside the other overrides. */ wasmUrl?: string | null; /** Override the URL of pdf.js's CMYK ICC profile (rarely needed; defaults to the CDN's). */ iccUrl?: string | null; /** Base path pdf.js resolves annotation-layer images against. */ imageResourcesPath?: string; /** Default for the component's `[enableHandTool]` input, which still wins when bound. */ enableHandTool?: boolean; /** * Maximum canvas area (in pixels) pdf.js will render a page at. * * Leave this unset unless you have measured a problem. pdf.js already picks * a platform-aware default: 2**25 (33,554,432) on desktop, and 5,242,880 on * iOS/Android where canvas memory is scarce. Past the cap it renders at a * lower effective pixel ratio (a softer page) instead of allocating. * * Overriding raises the mobile cap too. Budget accordingly: one page canvas * at page-width zoom on a HiDPI display is already ~25 MB, and pdf.js keeps * up to 10 rendered pages buffered. Pass 0 to disable the cap entirely. */ maxCanvasPixels?: number; } type HandToolCleanup = () => void; /** Options for text search delegation to the PDF.js find controller */ interface SearchOptions { highlightAll?: boolean; caseSensitive?: boolean; entireWord?: boolean; } /** Current match position and total match count for an active search */ interface PdfSearchMatches { current: number; total: number; } /** Rendered thumbnail data for a single PDF page */ interface ThumbnailData { url: string; width: number; height: number; } declare class PdfViewerComponent implements AfterViewInit { private readonly facade; private readonly documentActions; private readonly bridge; private readonly pdfjs; private readonly scaleService; private readonly syncService; private readonly lifecycleService; private readonly hostService; private readonly destroyRef; readonly containerRef: _angular_core.Signal | undefined>; readonly src: _angular_core.InputSignal | PDFSource | undefined>; readonly page: _angular_core.InputSignal; readonly renderText: _angular_core.InputSignal; readonly renderTextMode: _angular_core.InputSignal; readonly originalSize: _angular_core.InputSignal; readonly stickToPage: _angular_core.InputSignal; readonly zoom: _angular_core.InputSignal; readonly zoomScale: _angular_core.InputSignal; readonly rotation: _angular_core.InputSignal; readonly autoresize: _angular_core.InputSignal; readonly fitToPage: _angular_core.InputSignal; readonly showBorders: _angular_core.InputSignal; readonly cMapsUrl: _angular_core.InputSignal; readonly externalLinkTarget: _angular_core.InputSignal; readonly enableHandTool: _angular_core.InputSignal; readonly annotationMode: _angular_core.InputSignal; readonly locale: _angular_core.InputSignal; readonly passwordProvider: _angular_core.InputSignal<((reason: number) => Promise) | undefined>; readonly loadingTemplate: _angular_core.InputSignal | null>; readonly isLoading: _angular_core.WritableSignal; readonly afterLoadComplete: _angular_core.OutputEmitterRef; readonly pageRendered: _angular_core.OutputEmitterRef>; readonly pagesInitialized: _angular_core.OutputEmitterRef>; readonly textLayerRendered: _angular_core.OutputEmitterRef>; readonly error: _angular_core.OutputEmitterRef; readonly progress: _angular_core.OutputEmitterRef; readonly pageChange: _angular_core.OutputEmitterRef; readonly outlineLoaded: _angular_core.OutputEmitterRef; readonly searchResults: _angular_core.OutputEmitterRef; private readonly isVisible; private readonly isInitialized; private readonly latestScrolledPage; private pdfjsBundle; private destroyed; private initializePromise; private loadRequestId; private readonly viewerReady; private readonly currentDocument; private readonly viewerState; private readonly syncTracker; constructor(); ngAfterViewInit(): void; private setupVisibilityObserver; private initializeOnce; private doInitialize; private initializeViewer; private getReconfigureKey; private reconfigureViewer; private applyScaleUpdate; private loadPdf; /** * Searches the loaded document for the given query via the PDF.js find controller. */ search(query: string, options?: SearchOptions): void; /** * Jumps to the next match for the most recent search. */ findNext(): void; /** * Jumps to the previous match for the most recent search. */ findPrevious(): void; /** * Clears the active search and its highlights. */ clearSearch(): void; /** * Gets the document outline, or an empty array when none exists. */ getOutline(): Promise; /** * Gets the metadata embedded in the current document. */ getMetadata(): Promise; /** * Navigates to an internal table-of-contents entry. */ navigateToOutline(item: PDFOutlineItem): void; /** * Renders a thumbnail for the given page at a max width of 150px. */ getThumbnail(page: number): Promise; /** * Downloads the current document's raw bytes as a PDF file. */ download(filename?: string): Promise; /** * Prints the current document by loading it into a hidden iframe. */ print(): Promise; /** * Gets the number of pages in the current document (0 when none is loaded). */ getPageCount(): number; private setupFacadeEventHandlers; private resolveAnnotationMode; private getScaleConfig; private updateHandTool; private cleanup; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } declare const PDF_VIEWER_CONFIG: InjectionToken; /** * Provides PDF viewer configuration. Use in app config or component providers. * * Every field is optional: pdf.js and all of its runtime resources resolve * against a pinned CDN by default, so this is only needed to self-host, point * at a different CDN, or change viewer behaviour. * * @example * ```typescript * // In app.config.ts * export const appConfig: ApplicationConfig = { * providers: [ * providePdfViewerConfig({ * cdnBaseUrl: '/assets/pdfjs/', // self-hosted mirror of the pdfjs-dist package * enableHandTool: true, * }), * ], * }; * ``` * * @param config - Configuration overrides * @returns Provider for {@link PDF_VIEWER_CONFIG} */ declare function providePdfViewerConfig(config: PdfViewerConfig): Provider; declare function isSSR(): boolean; /** * Loads pdf.js — core, viewer, and stylesheet — from a CDN, no host * `pdfjs-dist` install needed. URLs are runtime-computed template strings * rather than literals: bundlers only ever treat this as an opaque runtime * fetch this way, so it stays a separate, lazily-loaded chunk and never * affects the host's own build. * * Core/viewer load sequentially (pdf_viewer.mjs reads globalThis.pdfjsLib); * the stylesheet loads in parallel and is awaited before returning. */ declare class PdfjsService { private readonly config; private loadPromise; load(): Promise; private loadBundle; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵprov: _angular_core.ɵɵInjectableDeclaration; } /** CSS units conversion factor: 96 DPI / 72 points per inch */ declare const CSS_UNITS: number; declare const BORDER_WIDTH = 9; /** Scale increment for snapping (e.g. 0.05 = 5% steps: 0.5, 0.55, 1.0, 1.05...) */ declare const SCALE_INCREMENT = 0.05; declare const RESIZE_DEBOUNCE_TIME = 100; declare const PAGE_CHANGE_DEBOUNCE_TIME = 100; declare function createEventBus(EventBusConstructor: new () => EventBus, container: HTMLElement, destroyRef: DestroyRef): EventBus; /** * Sets up grab-to-pan (hand tool) on a scrollable container. * Left-click and drag pans the content. */ declare function setupHandTool(container: HTMLElement, enabled: boolean): HandToolCleanup; declare function buildDocumentParams({ src, cMapsUrl, standardFontDataUrl, wasmUrl, iccUrl, enableXfa, }: DocumentParamsInput): PDFDocumentParameters; declare function isValidPdfSource(value: unknown): value is PDFSource; /** * Snaps scale to the nearest increment for clean, predictable zoom levels. */ declare function roundScaleToIncrement(scale: number, increment?: number): number; /** * Calculates the scale factor for PDF page rendering based on container dimensions, * zoom settings, and scale mode. */ declare function calculatePdfScale({ viewportWidth, viewportHeight, containerWidth, containerHeight, zoom, zoomScale, showBorders, }: ScaleCalculationParams): number; /** * Coerces a value to a valid integer page number for PDF.js APIs. * PDF.js requires Number.isInteger(pageNumber). * * @param value - Page number (may be string from bindings/URL/events) * @returns Integer between 1 and totalPages (or 1 if totalPages invalid) */ declare function toIntegerPageNumber(value: unknown, totalPages?: number): number; declare function normalizePageNumber(page: number, totalPages: number): number; /** pdfjs-dist version this library's hand-typed API surface was written against. */ declare const PDFJS_VERSION = "6.3.289"; type CdnConfig = Pick; /** * Resolves the CDN root every other default URL hangs off, always with a * trailing slash — pdf.js concatenates filenames onto these bases directly * (`${wasmUrl}qcms_bg.wasm`), so a missing slash silently produces 404s. */ declare function resolveCdnBaseUrl(config?: CdnConfig): string; /** Default worker URL, pinned to {@link PDFJS_VERSION}. */ declare function resolveDefaultWorkerSrc(config?: CdnConfig): string; /** Default CMap URL for CJK text rendering. */ declare function resolveDefaultCMapsUrl(config?: CdnConfig): string; /** Default standard-fonts URL, used for the 14 standard PDF fonts. */ declare function resolveDefaultStandardFontDataUrl(config?: CdnConfig): string; /** * Default URL for pdf.js's WebAssembly decoders (OpenJPEG for JPEG 2000, JBIG2, * and QCMS for colour management). pdf.js has no fallback for this: left unset * it warns and those images fail to decode, so it is a default, not an extra. */ declare function resolveDefaultWasmUrl(config?: CdnConfig): string; /** Default URL for the bundled ICC profile pdf.js uses for CMYK colour spaces. */ declare function resolveDefaultIccUrl(config?: CdnConfig): string; /** * Sets GlobalWorkerOptions.workerSrc exactly once per app lifetime. Cross-origin * URLs (the CDN default included) are handled by pdf.js itself: it wraps the * worker in a same-origin blob shim that imports the real URL from inside the * worker, working around the same-origin restriction on `new Worker()`. */ declare function ensureWorkerConfigured(lib: PDFJsLib, config?: PdfViewerConfig): void; /** * Injects pdf.js's own stylesheet (required for text/annotation layer * positioning), once per app lifetime. * * Prepended rather than appended: pdf_viewer.css declares generic `:root` * custom properties and `color-scheme`, so injecting it last would let vendor * CSS outrank the host application's own equally-specific rules. First in * `` keeps the host's styles authoritative. */ declare function ensureStylesheetLoaded(config?: CdnConfig): Promise; declare const THUMBNAIL_MAX_WIDTH = 150; declare function renderPageThumbnail(page: PDFPageProxy, maxWidth?: number): Promise; declare function downloadBytes(data: Uint8Array, filename?: string): Promise; declare function printBytes(data: Uint8Array): Promise; export { BORDER_WIDTH, CSS_UNITS, PAGE_CHANGE_DEBOUNCE_TIME, PDFJS_VERSION, PDF_VIEWER_CONFIG, PdfViewerComponent, PdfViewerError, PdfjsService, RESIZE_DEBOUNCE_TIME, RenderTextMode, SCALE_INCREMENT, THUMBNAIL_MAX_WIDTH, buildDocumentParams, calculatePdfScale, createEventBus, downloadBytes, ensureStylesheetLoaded, ensureWorkerConfigured, isSSR, isValidPdfSource, normalizePageNumber, printBytes, providePdfViewerConfig, renderPageThumbnail, resolveCdnBaseUrl, resolveDefaultCMapsUrl, resolveDefaultIccUrl, resolveDefaultStandardFontDataUrl, resolveDefaultWasmUrl, resolveDefaultWorkerSrc, roundScaleToIncrement, setupHandTool, toIntegerPageNumber, toPdfViewerError }; export type { AnnotationDisplayMode, DocumentParamsInput, EventBus, ExternalLinkTarget, HandToolCleanup, PDFDocumentLoadingTask, PDFDocumentMetadata, PDFDocumentParameters, PDFDocumentProxy, PDFFindController, PDFJsBundle, PDFJsLib, PDFJsViewer, PDFLinkService, PDFOutlineItem, PDFPageProxy, PDFProgressData, PDFSource, PDFViewer, PdfSearchMatches, PdfViewerConfig, PdfViewerErrorCode, PdfViewerOptions, ScaleCalculationParams, SearchOptions, ThumbnailData, ZoomScale };