import { InputFile, RenderOptions, ViewOptions, InputUri, SaveOptions } from '../pdf-viewer-api/types'; import { PdfDestination, PdfFitMode, PdfPageLayoutMode, Annotation, DocumentChange, RotationDirection } from '../pdf-viewer-api'; import { SearchState } from '../pdf-viewer-canvas/state/search'; import { ActionDefinitions } from './state/index'; import { PdfWebViewerOptionsInterface } from './WebViewerOptions'; /** internal */ declare global { interface Window { PDFTOOLS_FOURHEIGHTS_PDFVIEWING_BASEURL: string; } } export interface FileOpenArgs { pdfFile: InputFile | InputUri; fdfFiles?: (InputFile | InputUri)[] | null; password?: string | null; viewOptions?: ViewOptions | null; renderOptions?: RenderOptions | null; } export interface SearchOptions { startPage?: number; isCaseSensitive?: boolean; isWrappingEnabled?: boolean; isRegex?: boolean; hideToolbar?: boolean; } /** internal */ export interface PdfWebViewerActions extends ActionDefinitions { api: { addPageRangeToThumbnailsQueue(pageRange: { from: number; to: number; }): void; close(): Promise; downloadFile(saveOptions?: SaveOptions): Promise; endSearch(): void; goTo(pdfDestination: PdfDestination): void; goToAnnotation(target: { annotation: Annotation; action?: 'select' | 'edit' | 'popup' | 'history'; }): void; hasChanges(): DocumentChange; loadNavigationItems(): void; nextPage(): void; nextSearchMatch(): void; open(fileOpenArgs: FileOpenArgs): void; closeFile(): void; previousPage(): void; previousSearchMatch(): void; print(): void; resetViewerMode(): void; rotate(): void; getFitMode(): PdfFitMode | null; setFitMode(fitMode: number): void; getPageLayoutMode(): PdfPageLayoutMode | null; setPageLayoutMode(layoutMode: number): void; getPageCount(): number | null; getPageNumber(): number | null; setPageNumber(page: number): void; rotatePage(pageRotation: { page: number; direction: RotationDirection; }): void; getRotation(): number | null; setRotation(rotation: number): void; getZoom(): number | null; setZoom(zoom: number): void; startSearch(): void; updateCanvasSearchState(searchState: SearchState): void; zoomIn(): void; zoomOut(): void; activateModule(moduleName: string, args: any): void; deactivateModule(moduleName: string): void; }; } export interface PdfWebViewerEventMap { busyState: boolean; appLoaded: boolean; documentLoaded: File | string; documentClosed: void; pageNumberChanged: number; zoomChanged: number; rotationChanged: number; fitModeChanged: PdfFitMode; pageLayoutModeChanged: PdfPageLayoutMode; documentChanged: void; textSelected: string; error: Error; } export type PdfWebViewerEventListener = (e: PdfWebViewerEventMap[K]) => void; export type PdfWebViewerEventTypes = keyof PdfWebViewerEventMap; export interface PdfWebViewerMetadata { version: string; type: 'stable' | 'extended'; } export declare class PdfWebViewer { private visiblePageRange; private eventListeners; private options; private element; private view; private viewerCanvas; private licenseKey; private loadThumbnailsQueue; private loadPageThumbnailsTimer; private metadata; constructor(containerElement: Element | null, license: string, options?: Partial); /** * Open a PDF and optionally one or more associated FDFs. * @param pdfFile * The PDF file to be opened. * @param fdfFiles * An array of FDF files to be opened jointly with the PDF. * Set to `null` if no FDF files need to be opened. * @param password * The password used for opening the PDF. * Set to `null` if the PDF is not encrypted. * @param renderOptions * Options used for rendering pages. * @param viewOptions * Options used for configuring the view * @returns * void */ open(pdfFile: InputFile | InputUri, fdfFiles?: (InputFile | InputUri)[] | null, password?: string | null, viewOptions?: ViewOptions, renderOptions?: RenderOptions): void; /** * @deprecated Deprecated in Version 3.10. Use save method instead. */ openFile(file: File | Blob | string, password?: string, pdfAuthorization?: string): void; /** * @deprecated Deprecated in Version 3.10. Use save method instead. */ openFDF(pdfFile: File | Blob | string, fdfFile: File | Blob | string, password?: string, pdfAuthorization?: string, fdfAuthorization?: string): void; /** * Return the opened PDF as binary data, * to be used, e.g., to save the file to disk. * @param saveOptions * Options for saving the document * @returns * A Promise with an Blob containing the data or null if no document is open * */ save(saveOptions?: SaveOptions): Promise | null; /** * @deprecated Deprecated in Version 3.10. Use save method instead. */ saveFile(asFdf?: boolean): Promise; /** * saves the currently opened PDF file to the local file system */ downloadFile(saveOptions?: SaveOptions): Promise | undefined; /** * Close the currently opened PDF file. */ close(): Promise | undefined; /** * dispose the PdfWebViewer. */ destroy(): void; /** * Get the total page count of the opened document. * @returns * The total number of pages of the currently opened file. * Returns null if no document is open */ getPageCount(): number | null; /** * Get the currently most visible page. * @returns * The number of the page which covers most area on the view port. * If multiple pages cover the same amount of space, * the one with smaller page number is returned. * Returns null if no document is open */ getPageNumber(): number | null; /** * Sets the first currently visible page. * @param pageNumber * The number of the page to be displayed */ setPageNumber(pageNumber: number): void; /** * Rotates a page 90 degrees either clockwise or counterclockwise * * @param pageNumber * The number of the page to be rotated * @param direction * Specifies whether the rotation is clockwise or counterclockwise. */ rotatePage(pageNumber: number, direction: RotationDirection): void; /** * Go to the next page. */ nextPage(): void; /** * Go to the previousPage page. */ previousPage(): void; /** * Get the viewer zoom. * @returns * The currently used zoom factor. * Returns null if no document is open. */ getZoom(): number | null; /** * Set the viewer zoom. * @param zoom * The zoom factor as a percentage of the original size. */ setZoom(zoom: number): void; /** * Sets the zoom to the closest higher predefined zoom Level. */ zoomIn(): void; /** * Sets the zoom to the closest smaller predefined zoom Level. */ zoomOut(): void; /** * Get the current fit mode. * @returns * The mode that is currently used for fitting the viewport to the visible pages. * Returns null if no document is open. */ getFitMode(): PdfFitMode | null; /** * Set the fit mode. * @param fitMode * The mode to be used for fitting the viewport to the visible pages. */ setFitMode(fitMode: PdfFitMode): void; /** * Get the current page layout mode. * @returns * The mode that is currently used for arranging pages on the canvas. * Returns null if no document is open. */ getPageLayoutMode(): PdfPageLayoutMode | null; /** * Set the page layout mode. * @param pageLayoutMode * The mode to be used for arranging pages on the canvas. */ setPageLayoutMode(pageLayoutMode: PdfPageLayoutMode): void; /** * Get the viewer rotation. * @returns * The currently used viewer rotation on all pages. * Returns null if no document is open */ getRotation(): number | null; /** * Set the viewer rotation. * NOTE: This only changes the view of the document and is not an operation on the document. * @param rotation * The rotation to be applied on all pages (cumulative with the embedded rotation per page). */ setRotation(rotation: number): void; /** * Get the product version of the viewer. * @returns * The product version of the PDF Web Viewer. */ getProductVersion(): string; /** * Get the metadata of the viewer. * @returns * The metadata of the PDF Web Viewer. */ getMetadata(): PdfWebViewerMetadata; /** * Check whether there are unsaved changes in the document. * @returns * A DocumentChange enum indicating what kind of changes were made * Returns null if no document is open */ hasChanges(): DocumentChange | null; /** * Opens the information pane and selects the given pane * @selectedPane * Name of the pane thath should be displayed */ showInformationPane(selectedPane?: 'thumbnail' | 'outline' | 'annotation'): void; /** * Closes the information pane */ hideInformationPane(): void; /** * Toggle the information pane */ toggleInformationPane(): void; /** * Opens the search tool bar and starts a new search with the given text * @param text * text to be searched for * @param searchOptions * Options for be used for searching */ startSearch(searchString: string, searchOptions?: SearchOptions): void; /** * Highlights the next search result */ nextSearchMatch(): void; /** * Highlights the previous search result */ previousSearchMatch(): void; /** * Stops the current search and closes the search tool bar */ endSearch(): void; /** * Opens the print dialog */ print(): void; /** * Returns the selected text */ getSelectedText(): string; /** * Register a function that will be called whenever the specified event is delivered * @param type * String representing the event type to listen for. * @param listener * The function that will be executet when an event of the specified type occurs */ addEventListener(type: K, listener: (e: PdfWebViewerEventMap[K]) => void): void; /** * Removes an event listener previously registered with addEventListener * @param type * String representing the event for which to remove an event listener. * @param listener * The event listener function of the event handler to remove from the event target. */ removeEventListener(type: K, listener: (e: PdfWebViewerEventMap[K]) => void): void; private dispatchEvent; private createView; private getScreenSize; private handleResize; private handleKeyboardShortcuts; private showUnconfirmedChangesDialog; private beforeOpen; private openResolve; private openReject; private handleDocumentOpened; private loadDocumentOutlines; private loadPageThumbnails; private addPagesToThumbnailsQueue; private updatePageThumbnail; private loadAnnotations; private handleDocumentClosed; private handleAppLoaded; private handleFirstVisiblePageChanged; private handleLastVisiblePageChanged; private handlePageNumberChanged; private updateVisiblePageRange; private handleZoomChanged; private handleFitModeChanged; private handlePageLayoutModeChanged; private handleRotationChanged; private handleBusyStateChanged; private handleAnnotationSelected; private handleAnnotationDeselected; private handleAnnotationCreated; private handleAnnotationUpdated; private handleAnnotationDeleted; private handlePageChanged; private handleTextSelected; private verifyOptions; private isContainedInArray; private handleError; }