UNPKG

@syncfusion/ej2-pdfviewer

Version:
327 lines (326 loc) 11.8 kB
import { RedactionSettingsModel, AnnotationType, IPoint, IRectangle, PdfAnnotationBaseModel, PdfViewer, PdfViewerBase, IAnnotation } from '../../index'; /** * Interface for Redaction Annotation * * @hidden */ export interface IRedactionAnnotation extends IAnnotation { bounds: any; rotateAngle: string; isLocked: boolean; pageNumber: number; annotationId: string; customData: object; overlayText: string; isRepeat: boolean; fontColor: string; fontSize: number; fontFamily: string; textAlign: string; markerFillColor: string; markerBorderColor: string; markerOpacity: number; isPrint: boolean; id?: string; allowedInteractions?: any; isReadonly?: boolean; redactionContent?: string; annotationAddMode?: string; } /** * RedactionAnnotation class to handle redaction annotations * * @hidden */ export declare class Redaction { private pdfViewer; private pdfViewerBase; /** * @private */ redactionFillColor: string; /** * @private */ redactionPageNumbers: any; /** * @private */ redactionFontColor: string; /** * @private */ redactionFontSize: number; /** * @private */ redactionFontFamily: string; /** * @private */ textAlign: string; /** * @private */ redactionMarkerFillColor: string; /** * @private */ redactionBorderColor: string; /** * @private */ redactionOutlineOpacity: number; /** * @private */ redactionCount: number; /** * @private */ isAddAnnotationProgramatically: boolean; /** * @private */ isRepeat: boolean; /** * @private */ overlayText: string; /** * @private */ isRedactionHovered: boolean; private previousTool; private isAnnotationHoverd; private orginalFillColor; private orginalBorderColor; private orginalOpacity; private hoveredRedactionAnnotName; /** * @private */ hoveredRedactionId: string; /** * Update annotation details for programmatic addition * @param {RedactionSettingsModel} options - The redaction settings * @param {IPoint} offset - The offset point * @returns {any} The redaction annotation object * @private */ updateAddAnnotationDetails(options: RedactionSettingsModel, offset: IPoint): any; /** * Handle redaction annotation hover * @param {PdfAnnotationBaseModel} annotation - The annotation being hovered * @param {number} pageIndex - The page index * @param {any} currentAnnot - currentAnnot * @returns {void} * @private */ handleRedactionHover(annotation: PdfAnnotationBaseModel, pageIndex: number, currentAnnot?: any): void; /** * Reset redaction annotation hover state * @returns {void} * @private */ resetRedactionHover(): void; /** * Constructor for RedactionAnnotation class * @param {PdfViewer} pdfviewer - The PDF Viewer instance * @param {PdfViewerBase} pdfViewerBase - The PDF Viewer Base instance */ constructor(pdfviewer: PdfViewer, pdfViewerBase: PdfViewerBase); /** * Initialize redaction properties with default values or from settings * @returns {void} * @private */ private initializeRedactionProperties; /** * Render redaction annotations on the page * @param {any} redactionAnnotations - The redaction annotations to render * @param {number} pageNumber - The page number to render on * @param {boolean} isImportAction - Whether this is an import action * @param {any} isAnnotOrderAction - Whether this is an isAnnotOrderAction * @returns {void} * @private */ renderRedactionAnnotations(redactionAnnotations: any, pageNumber: number, isImportAction?: boolean, isAnnotOrderAction?: boolean): void; private createAnnotationObject; private updateRedactionProperties; private drawRedactionAnnotation; /** * Get annotation settings specific to redaction * @param {any} annotation - The annotation to get settings for * @returns {any} The annotation settings * @private */ getSettings(annotation: any): any; /** * Set annotation type to Redaction * @param {AnnotationType} type - The annotation type * @returns {void} * @private */ setAnnotationType(type: AnnotationType): void; /** * Update redaction annotation collections * @param {any} annotation - The annotation to update * @param {number} pageNumber - The page number * @returns {IRedactionAnnotation | null} The updated annotation object * @private */ updateRedactionAnnotationCollections(annotation: any, pageNumber: number): IRedactionAnnotation | null; /** * Modify redaction annotation in collection * @param {string} property - The property to modify * @param {number} pageNumber - The page number * @param {any} annotationBase - The annotation to modify * @returns {IRedactionAnnotation | null} The modified annotation * @private */ modifyInCollection(property: string, pageNumber: number, annotationBase: any): IRedactionAnnotation | null; /** * Add redaction annotation to collection * @param {number} pageNumber - The page number * @param {IRedactionAnnotation} annotationBase - The annotation to add * @returns {void} - void * @private */ addInCollection(pageNumber: number, annotationBase: IRedactionAnnotation): void; /** * Manage annotations in storage * @param {IRedactionAnnotation[]} pageAnnotations - The annotations for the page * @param {number} pageNumber - The page number * @returns {void} - void * @private */ private manageAnnotations; /** * Save imported redaction annotations * @param {any} annotation - The annotation to save * @param {number} pageIndex - The page index * @returns {void} - void * @private */ saveImportedRedactionAnnotations(annotation: any, pageIndex: number): void; /** * Get selector settings for redaction annotation * @param {string} type - The annotation type * @param {string} subject - The annotation subject * @returns {AnnotationSelectorSettingsModel} The selector settings * @private */ private getSelector; /** * Save redaction annotations to JSON format for export * @returns {string} JSON string of redaction annotations * @private */ saveRedactionAnnotations(): string; /** * Save redaction annotations to JSON format for export * @param {any} newAnnotation - new annotation * @param {boolean} canSaved - can saved * @private * @returns {any} - JSON string of redaction annotations */ combineBounds(newAnnotation: any, canSaved?: boolean): any; /** * @private * @returns {void} */ deleteTextRedactAnnotation(): void; /** * @param {MouseEvent} event - It describes about the event * @private * @returns {void} */ onTextRedactMouseMove(event: MouseEvent): void; /** * @param {TouchEvent} event - It describes about the event * @private * @returns {void} */ onTextRedactAnnotationTouchEnd(event: TouchEvent): void; private onTextRedactTouchEnd; /** * @private * @returns {void} */ clearCurrentSelectedAnnotation(): void; /** * @param {number} pageNumber - It describes about the pageNumber * @private * @returns {void} */ clearAnnotationSelection(pageNumber: number): void; /** * @param {MouseEvent} event - It describes about the event * @private * @returns {void} */ onTextRedactAnnotationMouseUp(event: MouseEvent): void; private getCurrentMarkupAnnotation; private compareCurrentAnnotations; private onTextRedactMouseUp; /** * @param {any} textRedactAnnotations - It describes about the text markup annotations * @param {number} pageNumber - It describes about the page number * @param {boolean} isImportTextMarkup - It describes about the isImportTextMarkup * @param {boolean} isAnnotOrderAction - It describes about the isAnnotOrderAction * @private * @returns {void} */ renderTextRedactAnnotationsInPage(textRedactAnnotations: any, pageNumber: number, isImportTextMarkup?: boolean, isAnnotOrderAction?: boolean): void; /** * @param {any} textRedactAnnotations - It describes about the text markup annotations * @param {number} pageNumber - It describes about the page number * @param {HTMLElement} canvas - It describe the canvas. * @param {number} factor - It describe the zoom factor. * @param {boolean} isImportAction - It describes about the isImportTextMarkup * @param {boolean} isAnnotOrderAction - It describes about the isAnnotOrderAction * @private * @returns {any} - redaction annotation */ renderTextRedactAnnotations(textRedactAnnotations: any, pageNumber: number, canvas: HTMLElement, factor: number, isImportAction?: boolean, isAnnotOrderAction?: boolean): any; private getAddedAnnotation; private getPageContext; private getMagnifiedValue; private drawTextRedactAnnotation; private renderTextRedactAnnotation; /** * Draws a text redaction annotation on the specified page. * This method handles the visual representation of text redactions, typically used to obscure sensitive information. * It processes the annotation bounds, calculates positioning based on zoom factors, and manages rendering logic. * * @param {string} type - The annotation type (e.g., 'Redaction') * @param {IRectangle[]} bounds - The bounding rectangles defining the redaction area(s) on the page * @param {number} pageNumber - The page number where the redaction should be applied * @param {any} rect - Deprecated/unused parameter retained for backward compatibility * @param {number} factor - The current zoom factor for magnifying annotation dimensions * @param {string} textContent - The sensitive text content being redacted * @param {number} startIndex - The starting character index of the redacted text in the document * @param {number} endIndex - The ending character index of the redacted text in the document * @param {boolean} [isMultiSelect] - Indicates whether multiple text selections are being redacted * @param {HTMLElement} [targetElement] - The DOM element associated with the redaction (e.g., text layer) * @private * * @returns {void} */ drawTextRedact(type: string, bounds: IRectangle[], pageNumber: number, rect: any, factor: number, textContent: string, startIndex: number, endIndex: number, isMultiSelect?: boolean, targetElement?: any): void; private getRgbCode; /** * Retrieves the collection of redaction annotations for a given page. * If stored annotations exist for the page, they are returned; otherwise, * the provided redactionAnnotations array is used. This handles both stored * annotations (from session/local storage) and programmatically provided ones. * * @param {number} pageIndex - The page index to retrieve annotations for * @param {any[] | null} redactionAnnotations - Optional default annotations to use if no stored annotations exist * @private * * @returns {any[]} The array of redaction annotations for the specified page */ getAnnotations(pageIndex: number, redactionAnnotations: any[] | null): any[]; }