declare module 'pdfjs-dist' { // Worker const GlobalWorkerOptions: GlobalWorker; interface GlobalWorker { workerSrc: string; } // Loading task const PasswordResponses: PasswordResponsesValue; interface PasswordResponsesValue { NEED_PASSWORD: string; INCORRECT_PASSWORD: string; } type VerifyPassword = (password: string) => void; type FileData = string | Uint8Array; interface LoadingTask { onPassword: (verifyPassword: VerifyPassword, reason: string) => void; promise: Promise; destroy(): void; } interface PdfDocument { numPages: number; getAttachments(): Promise<{ [filename: string]: Attachment }>; getDestination(dest: string): Promise; getDownloadInfo(): Promise<{ length: number }>; getMetadata(): Promise; getOutline(): Promise; getPage(pageIndex: number): Promise; getPageIndex(ref: OutlineRef): Promise; } interface GetDocumentParams { url?: FileData; data?: FileData; cMapUrl?: string; cMapPacked?: boolean; } function getDocument(params: GetDocumentParams): LoadingTask; // Attachment interface Attachment { content: Uint8Array; filename: string; } // Metadata interface MetaData { contentDispositionFilename?: string; info: MetaDataInfo; } interface MetaDataInfo { Author: string; CreationDate: string; Creator: string; Keywords: string; ModDate: string; PDFFormatVersion: string; Producer: string; Subject: string; Title: string; } // Outline type OutlineDestinationType = string | OutlineDestination; interface Outline { bold?: boolean; color?: number[]; dest?: OutlineDestinationType; italic?: boolean; items: Outline[]; newWindow?: boolean; title: string; unsafeUrl?: string; url?: string; } type OutlineDestination = [ OutlineRef, OutlineDestinationName, // eslint-disable-next-line @typescript-eslint/no-explicit-any ...any[], ]; interface OutlineDestinationName { name: string; // Can be 'WYZ', 'Fit', ... } interface OutlineRef { gen: number; num: number; } // View port interface ViewPortParams { rotation?: number; scale: number; } interface ViewPortCloneParams { dontFlip: boolean; } interface ViewPort { height: number; rotation: number; transform: number[]; width: number; clone(params: ViewPortCloneParams): ViewPort; } // Render task interface PageRenderTask { // eslint-disable-next-line @typescript-eslint/no-explicit-any promise: Promise; cancel(): void; } // Render SVG interface SVGGraphics { getSVG(operatorList: PageOperatorList, viewport: ViewPort): Promise; } interface SVGGraphicsConstructor { new (commonObjs: PageCommonObjects, objs: PageObjects): SVGGraphics; } let SVGGraphics: SVGGraphicsConstructor; // Render text layer interface RenderTextLayerParams { textContent: PageTextContent; container: HTMLDivElement; viewport: ViewPort; } interface PageTextContent { items: PageTextItem[]; } interface PageTextItem { str: string; } function renderTextLayer(params: RenderTextLayerParams): PageRenderTask; // Annotations layer interface AnnotationsParams { // Can be 'display' or 'print' intent: string; } interface AnnotationPoint { x: number; y: number; } interface Annotation { annotationType: number; color?: Uint8ClampedArray; dest: string; hasAppearance: boolean; id: string; rect: number[]; subtype: string; // Border style borderStyle: { dashArray: number[]; horizontalCornerRadius: number; style: number; verticalCornerRadius: number; width: number; }; // For annotation that has a popup hasPopup?: boolean; contents?: string; modificationDate?: string; title?: string; // Parent annotation parentId?: string; parentType?: string; // File attachment annotation file?: Attachment; // Ink annotation inkLists?: AnnotationPoint[][]; // Line annotation lineCoordinates: number[]; // Link annotation // `action` can be `FirstPage`, `PrevPage`, `NextPage`, `LastPage`, `GoBack`, `GoForward` action?: string; url?: string; newWindow?: boolean; // Polyline annotation vertices?: AnnotationPoint[]; // Text annotation name?: string; } const AnnotationLayer: PdfAnnotationLayer; interface RenderAnnotationLayerParams { annotations: Annotation[]; div: HTMLDivElement | null; linkService: LinkService; page: Page; viewport: ViewPort; } interface PdfAnnotationLayer { render(params: RenderAnnotationLayerParams): void; update(params: RenderAnnotationLayerParams): void; } // Link service interface LinkService { externalLinkTarget?: number | null; getDestinationHash(dest: OutlineDestinationType): string; navigateTo(dest: OutlineDestinationType): void; } // Render page interface PageRenderParams { canvasContext: CanvasRenderingContext2D; // Should be 'print' when printing intent?: string; transform?: number[]; viewport: ViewPort; } interface Page { getAnnotations(params: AnnotationsParams): Promise; getTextContent(): Promise; getViewport(params: ViewPortParams): ViewPort; render(params: PageRenderParams): PageRenderTask; getOperatorList(): Promise; commonObjs: PageCommonObjects; objs: PageObjects; view: number[]; } /* eslint-disable @typescript-eslint/no-empty-interface */ interface PageCommonObjects {} interface PageObjects {} interface PageOperatorList {} /* eslint-enable @typescript-eslint/no-empty-interface */ }