UNPKG

@syncfusion/ej2-pdfviewer

Version:
614 lines (613 loc) 18.6 kB
import { PdfViewer, PdfViewerBase, ISize, PageOrganizerSettingsModel } from '../index'; import { DragEventArgs, DropEventArgs } from '@syncfusion/ej2-base'; import { Dialog } from '@syncfusion/ej2-popups'; import { Toolbar } from '@syncfusion/ej2-navigations'; import { TextBox } from '@syncfusion/ej2-inputs'; interface IActionOrganizeElements { action: string; UndoRedoTileActions: OrganizeDetails[]; toolbarActions: OrganizeDetails[]; selectedPagesIndexes: number[]; dropIndex: number; isRightInsertion: boolean; } /** * The `PageOrganizer` module is used to handle page organize operations of PDF viewer. * * @param {Event} event - The event triggering the page organization. * @param {Object} args - Additional arguments for the page organization. * @returns {void} */ export declare class PageOrganizer { /** * @private */ pdfViewer: PdfViewer; /** * @private */ pdfViewerBase: PdfViewerBase; private rotateRightButton; private rotateLeftButton; private insertRightButton; private insertLeftButton; private deleteButton; private copyButton; private pageZoomElement; private pageZoomDropDown; private pageZoomSlider; private pageZoomDecreaseButton; private pageZoomIncreaseButton; private pageZoomContainer; private toolbar; /** * @private */ importDocInputElement: HTMLElement; /** * @private */ importedDocumentName: string; private previewLimit; private lastRequestedPageIndex; private pageZoomSliderStep; private currentPageZoomSliderValue; private previouslyRequestedImageZoom; /** * @private */ importedDocumentData: string; /** * @private */ dataDetails: any[]; /** * @private */ dialogDivElement: HTMLElement; /** * @private */ waitingPopup: HTMLElement; private thumbnail; private imageContainer; /** * @private */ organizeDialog: Dialog; /** * @private */ tileAreaWrapper: HTMLElement; /** * @private */ tileAreaDiv: HTMLElement; private thumbnailImage; private importImageWrapper; private pageLink; private previewRequestHandler; private contextMenuObj; private mobileContextMenu; /** * @private */ organizePagesCollection: OrganizeDetails[]; /** * @private */ tempOrganizePagesCollection: OrganizeDetails[]; private isSkipRevert; private isAllImagesReceived; private selectAllCheckBox; /** * @private */ totalCheckedCount: number; /** * @private */ selectedPageIndexes: number[]; private dragEndIndex; /** * @private */ dragHoveredIndex: number; private dragObj; private dropObj; /** * @private */ virtualEle: HTMLElement; private previousClientY; /** * @private */ autoScrollInterval: number; private isRightInsertion; /** * @private */ gapBetweenDivs: number; private previousImageZoom; private currentImageZoom; /** * @private */ isDocumentModified: boolean; /** * @private */ undoOrganizeCollection: IActionOrganizeElements[]; /** * @private */ redoOrganizeCollection: IActionOrganizeElements[]; /** * @private */ toolbarUndoRedoCollection: OrganizeDetails[]; private startTile; private ctrlKey; private shiftKey; private isClickedOnCheckBox; private isTouchEvent; private isPageZoomChanged; private isInitialLoading; private boundOnTileAreaMouseDown; private boundOnTileAreaKeyDown; private boundOnTileAreaKeyUp; private boundPageOrganizerOnScroll; private boundPageZoomDropDownOpen; private boundPageZoomDropDownClose; private boundPageZoomChange; private boundIncreasePageZoom; private boundDecreasePageZoom; private boundImportDocument; private boundExtractInputChange; private extractButtonClickHandler; /** * @private */ extractButtonElement: HTMLElement; /** * @private */ isOrganizeWindowOpen: boolean; /** * @private */ isPageZoomPopupOpen: boolean; /** * @private */ extractDialog: Dialog; /** * @private */ extractPagesInput: TextBox; /** * @private */ isExtractToolbarVisible: boolean; /** * @private */ deleteExtractValue: string; /** * @private */ extractSecondaryToolbar: Toolbar; /** * @param {PdfViewer} pdfViewer - It describes about the pdfviewer * @param {PdfViewerBase} pdfViewerBase - It describes about the pdfviewer base * @private */ constructor(pdfViewer: PdfViewer, pdfViewerBase: PdfViewerBase); /** * @param {boolean} isReConstruct - It describes about the isReConstruct * @private * @returns {void} */ createOrganizeWindow(isReConstruct?: boolean): void; /** * @param {boolean} isReConstruct - Defines whether organizer window is reconstructed when closing * @private * @returns {void} */ createOrganizeWindowForMobile(isReConstruct?: boolean): void; /** * @private * @param {PageOrganizerSettingsModel} pageOrganizerSettings - new page organizer settings object * @param {oldpageOrganizerSettings} oldPageOrganizerSettings - old page organizer settings object * @returns {void} */ setPageOrganizerSettings(pageOrganizerSettings: PageOrganizerSettingsModel, oldPageOrganizerSettings?: PageOrganizerSettingsModel): void; /** * @private * @param {string} property - new toolbar item in organize toolbar. * @returns {void} */ updateToolbarItemState(property?: string): void; /** * @private * @returns {number} - number */ getImageZoomMin(): number; /** * @private * @returns {number} - number */ getImageZoomMax(): number; /** * @private * @returns {void} */ createRequestForPreview(): any; /** * @private * @param {PageOrganizer} proxy It describes about the page organizer * @returns {void} */ requestPreviewCreation(proxy: PageOrganizer): void; /** * @param {any} data - It describes about the data * @private * @returns {void} */ updatePreviewCollection(data: any): void; /** * @param {any} event - It describes about the event * @private * @returns {void} */ previewOnMessage(event: any): void; /** * @param {any} data - It describes about the data * @param {boolean} isClientRender - It describes about the isClientRender * @private * @returns {void} */ getData(data: any, isClientRender: boolean): void; /** * @param {any} event - It describes about the event * @private * @returns {void} */ pageDragDrop(event: any): void; /** * @private * @param {any} a - a value * @param {any} b - b value * @returns {number} - number */ sorting(a: any, b: any): number; /** * @param {number} pageIndex - It describes about the page index * @param {number} subIndex - It describes about the sub index * @param {number} pageOrder - It describes about the page order * @param {HTMLElement} targetElement - It describes about the target element * @param {boolean} isNewPage - It describes about the isNewPage * @param {boolean} isBefore - It describes about the isBefore * @param {boolean} isEmptyPage - It describes about the isEmptyPage * @param {boolean} isImportedPage - It describes about the isImportedPage * @param {string} documentName - It describes about the documentName * @private * @returns {void} */ tileImageRender(pageIndex: number, subIndex?: number, pageOrder?: number, targetElement?: HTMLElement, isNewPage?: boolean, isBefore?: boolean, isEmptyPage?: boolean, isImportedPage?: boolean, documentName?: string): void; /** * @param {DragEventArgs} e - It describes about the event * @private * @returns {void} */ autoScroll(e: DragEventArgs): void; /** * @param {DragEventArgs} e - It describes about the event * @param {DOMRect} tileRect - It describes about rect * @param {number} gapBetweenDivs - It describes about div gap * @param {HTMLElement} outerBorder - It describes about border * @private * @returns {void} */ handlePageMove(e: DropEventArgs, tileRect: DOMRect, gapBetweenDivs: number, outerBorder: HTMLElement): void; /** * @private * @returns {void} */ addSelectionRingStyle(): void; /** * @private * @returns {void} */ removeSelectionRingStyle(): void; /** * @param {number[]} selectedPageIndexes - It describes about the selected page index * @param {number} hoveredIndex - It describes about hovered index * @private * @returns {boolean} - Returns boolean value */ isHoveredOnSelectedPages(selectedPageIndexes: number[], hoveredIndex: number): boolean; /** * @param {MouseEvent} event - It describes about the event * @private * @returns {void} */ thumbnailMouseOver: (event: MouseEvent) => void; /** * @param {MouseEvent} event - It describes about the event * @private * @returns {void} */ thumbnailMouseLeave: (event: MouseEvent) => void; /** * @param {OrganizeDetails[]} UndoRedoTileActions - Specifies the details of the action occured page * @param {string} actionString - Specifies the Name of the action * @param {OrganizeDetails[]} toolbarActions - Collection to store multiple action as single action * @param {number[]} selectedPageIndexes - Collection to store selected page index * @param {number} dropIndex - Specifies where the page should be dropped * @param {boolean} isRightInsertion - Used to check whether the page should be dropped at right * @returns {void} * @private */ addOrganizeAction(UndoRedoTileActions: OrganizeDetails[], actionString: string, toolbarActions: OrganizeDetails[], selectedPageIndexes: number[], dropIndex: number, isRightInsertion: boolean): void; /** * @private * @returns {void} */ onSaveClicked(): void; /** * @param {boolean} isShow - specifies the isShow boolean. * @returns {void} * @private */ showOrganizeLoadingIndicator(isShow: boolean): void; /** * @private * @returns {void} */ undo: () => void; /** * @private * @returns {void} */ redo: () => void; /** * @param {HTMLElement} mainTileElement - It describes about tile element * @private * @returns {void} */ deletePageElement(mainTileElement: HTMLElement): void; private clonedCollection; /** * @param {string} documentData - specifies the documentData. * @param {string} password - specifies the password. * @param {boolean} isPasswordCorrect - specifies the isPasswordCorrect. * @returns {void} * @private */ loadImportDoc(documentData: string, password: string, isPasswordCorrect: boolean): void; /** * @param {string} password - specifies the password. * @param {string} documentName - specifies the documentName. * @param {string} documentData - specifies the documentData. * @returns {void} * @private */ importDocuments(password: string, documentName: string, documentData: string): void; /** * @private * @returns {void} */ updateOrganizePageCollection(): void; /** * * @param {any} pageCanvas - It describes about the page canvas * @param {number} pageNumber - It describes about the page number * @private * @returns {void} */ applyElementStyles(pageCanvas: any, pageNumber: number): void; /** * @private * @returns {void} */ onSaveasClicked(): void; /** * @private * @returns {void} */ updateOrganizePageActions(): void; /** * * Rotates all pages in the PDF Viewer by the specified angle. * * @param {PdfPageRotateAngle} pageRotateAngle - The angle by which to rotate the pages (PdfPageRotateAngle). * The rotation can be 0, 90, 180, or 270 degrees. * @returns {void} * @private */ rotateAllPages(pageRotateAngle: PdfPageRotateAngle): void; /** * Rotates the specified pages in the PDF Viewer by the specified angle. * * @param {number} pageIndexes - The array of page indexes to rotate. * @param {PdfPageRotateAngle} pageRotateAngle - The angle by which to rotate the pages (PdfPageRotateAngle). * The rotation can be 0, 90, 180, or 270 degrees. * @returns {void} * @private */ rotatePages(pageIndexes: number[], pageRotateAngle: PdfPageRotateAngle): void; /** * @private * @returns {void} */ rotatePages(pageStartIndex: number, pageEndIndex: number, pageRotateAngle: PdfPageRotateAngle): void; /** * @private * @returns {void} */ rotatePages(pageRotations: PageRotation[]): void; private generateRange; /** * @private * @param {number} newSize The size to which image zoom is to be updated * @param {number} oldSize The present value of image zoom * @returns {void} */ updateOrganizePageImageSize(newSize: number, oldSize?: number): void; /** * Rotates the specified pages clockwise by 90 degrees. * * @param {number} pageNumbers - Array of page numbers to rotate. * @private * @returns {void} */ rotateClockwise(pageNumbers: number[]): void; /** * Rotates the specified pages counterclockwise by 90 degrees. * * @param {number} pageNumbers - Array of page numbers to rotate. * @private * @returns {void} */ rotateCounterclockwise(pageNumbers: number[]): void; /** * Opens the page organizer dialog within the Pdf Viewer, allowing for management of PDF pages. * * ```html * <div id="pdfViewer" style="height: 100%;width: 100%;"></div> * ``` * ```ts * let viewer: PdfViewer = new PdfViewer(); * viewer.appendTo("#pdfViewer"); * viewer.documentLoad = () => { * viewer.pageOrganizer.openPageOrganizer(); * } * ``` * * @returns {void} */ openPageOrganizer(): void; /** * Closes the currently open page organizer dialog within the PDF Viewer, if present. * * ```html * <div id="pdfViewer" style="height: 100%;width: 100%;"></div> * ``` * ```ts * let viewer: PdfViewer = new PdfViewer(); * viewer.appendTo("#pdfViewer"); * viewer.documentLoad = () => { * viewer.pageOrganizer.closePageOrganizer(); * } * ``` * * @returns {void} */ closePageOrganizer(): void; /** * @private * @param {PageOrganizerSettingsModel} newProp The new pageOrganizerSettings Property of PdfViewer from onPropertyChanged * @returns {void} */ handleImageSizeBoundsChange(newProp: PageOrganizerSettingsModel): void; /** * @private * @param {boolean} showImageZoomingSlider The new showImageZoomingSlider property of PdfViewer.PageOrganizerSettings from onPropertyChanged * @returns {void} */ handleImageResizerVisibility(showImageZoomingSlider: boolean): void; /** * @private * @returns {void} */ switchPageOrganizer(): void; /** * @private * @returns {void} */ getModuleName(): string; /** * @private * @param {boolean} isImageRequest defines if the function is called for image request * @param {number} size optional size can be sent to check valid page zoom value * @returns {number} imageZoom value */ getImageZoomValue(isImageRequest?: boolean, size?: number): number; /** * @private * @param {number} currentValue - It describes about current value. * @param {number} previousValue - It describes about previous value. * @returns {void} */ handlePageZoomChange(currentValue: number, previousValue: number): void; /** * @private * @param {boolean} isShowRemove - It describes about show or remove the extract icon in organize window toolbar. * @returns {void} */ showRemoveExtractIcon(isShowRemove: boolean): void; /** * @private * @param {boolean} canExtractPages - It describes about show or hide the extract icon in organize window toolbar. * @returns {void} */ showHideExtractIcon(canExtractPages: boolean): void; /** * @private * @returns {void} */ clear(): void; /** * @private * @returns {void} */ destroy(): void; } /** * Enum for PdfPageRotateAngle */ export declare enum PdfPageRotateAngle { RotateAngle0 = 1, RotateAngle90 = 2, RotateAngle180 = 3, RotateAngle270 = 4, RotateAngle360 = 1 } export declare class PageRotation { pageIndex: number; rotationAngle: PdfPageRotateAngle; constructor(pageIndex: number, rotationAngle: PdfPageRotateAngle); } /** * Interface representing details about a page, including rotation angle and page index. * * @hidden */ export interface PageDetails { rotateAngle: number; pageIndex: number; } /** * Interface representing details about organizing pages, including page ID, current page index, rotate angle, and status of insertion and deletion. */ export declare class OrganizeDetails { currentPageIndex: number; pageIndex: number; copiedPageIndex: number; isInserted: boolean; isDeleted: boolean; isCopied: boolean; istargetCopied: boolean; hasEmptyPageAfter: boolean; hasEmptyPageBefore: boolean; rotateAngle: number; pageSize: ISize; isImportedDoc: boolean; documentName: string; password: string; documentData: string; constructor(currentPageIndex: number, pageIndex: number, copiedPageIndex: number, isInserted: boolean, isDeleted: boolean, isCopied: boolean, istargetCopied: boolean, hasEmptyPageAfter: boolean, hasEmptyPageBefore: boolean, rotateAngle: number, pageSize: ISize, isImportedDoc: boolean, documentName: string, password: string, documentData: string); } export {};