UNPKG

@mescius/dspdfviewer

Version:
203 lines (202 loc) 11.7 kB
import { AnnotationBase, StampAnnotation } from "../Annotations/AnnotationTypes"; import { DataStorage } from "../DataStorage/DataStorage"; import { FontFormat } from "../Models/ViewerTypes"; import { SharedRef } from "./SharedRef"; export declare function generateUid(caller?: string): string; export declare function updateInitialRectPosition(annotation: AnnotationBase, newXY?: number[]): void; export declare function resetStampAspectRatio(imageData: Uint8Array, viewer: any, pageIndex: number, originalNode: StampAnnotation, imageDpi?: number, select?: boolean): Promise<{ pageIndex: number; annotation: AnnotationBase; } | null>; export declare function isTypedArray(arr: any): boolean; /** * Merge everything from sourceObj to destinationObj, returns destinationObj. * Note, by default, non-empty primitive values are NOT preserved in the destination object. * @param destinationObj Destination object * @param sourceVal Source object * @param preserveNonEmpty Set to true if you don't want to replace non-empty primitive values. */ export declare function mergeObject(destinationObj: any, sourceVal: any, preserveNonEmpty?: boolean, copyUndefined?: boolean): any; export declare function cloneObject(obj: any): any; export declare function getTransformMatrix(viewBox: number[], rotation: number, scaleX: number, scaleY: number, ignoreRotate?: boolean): number[]; export declare function adjustCoordinates(realViewBox: number[], point: number[], rotation: number, inverse?: boolean, fromBottomLeft?: boolean, scale?: number): number[]; /** * Applies the transform to the rectangle and finds the minimum axially * aligned bounding box. * @param r * @param m */ export declare function getAxialAlignedBoundingBox(r: any, m: any): number[]; /** * Apply matrix transform. * @param p x, y point * @param m transform matrix */ export declare function applyTransform(p: number[], m: number[]): number[]; /** * Apply inverse matrix transformation. * @param p x, y point * @param m transform matrix */ export declare function applyInverseTransform(p: number[], m: number[]): number[]; export declare function inverseTransform(m: number[]): number[]; /** * Converts PDF point to the viewport coordinates. For examples, useful for * converting PDF location into canvas pixel coordinates. * @param {number} x - The x-coordinate. * @param {number} y - The y-coordinate. * @return {Array<number>} Array containing `x` and `y` properties of the * point in the viewport coordinate space. * <br />See {@link convertToPdfPoint} */ export declare function convertToViewportPoint(x: number, y: number, transform: number[]): number[]; /** * Converts viewport coordinates to the PDF location. For examples, useful * for converting canvas pixel location into PDF one. * @param {number} x - The x-coordinate. * @param {number} y - The y-coordinate. * @return {Array<number>} Array containing `x` and `y` properties of the * point in the PDF coordinate space. * <br />See {@link convertToViewportPoint} */ export declare function convertToPdfPoint(x: number, y: number, transform: number[]): number[]; /** * Change bounds origin. * @param bounds * @param viewBox * @param destOrigin */ export declare function changeRectangleOrigin(bounds: number[], viewBox: number[], destOrigin?: 'TopLeft' | 'BottomLeft', normalize?: boolean): number[]; export declare function changeOriginToBottom(top: number, view: number[]): number; export declare function changeOriginToTop(bottom: number, view: number[]): number; /** * Convert a PDF date string to a JavaScript `Date` object. * * The PDF date string format is described in section 7.9.4 of the official * PDF 32000-1:2008 specification. However, in the PDF 1.7 reference (sixth * edition) Adobe describes the same format including a trailing apostrophe. * This syntax in incorrect, but Adobe Acrobat creates PDF files that contain * them. We ignore all apostrophes as they are not necessary for date parsing. * * Moreover, Adobe Acrobat doesn't handle changing the date to universal time * and doesn't use the user's time zone (effectively ignoring the HH' and mm' * parts of the date string). * * @param {string} input * @return {Date|null} */ export declare function pdfDateStringToDate(input?: string | Date): Date | null; /** * Convert various input types to a PDF date string in UTC. * * The PDF date string format is described in section 7.9.4 of the official * PDF 32000-1:2008 specification. The output will follow the PDF date string * format in UTC, without any local time zone information. * * @param {Date | string | any | number} input - The date input, which can be a JavaScript Date object, a date string, a Moment object, or a timestamp (number). * @return {string | null} - The formatted PDF date string in UTC, or null if the input is invalid. */ export declare function dateToPdfDateString(input: Date | string | any | number | undefined): string | null; export declare function formatRelativeDate(date: Date | null, i18n: any, dateFormat?: string): string; export declare function copyStringToClipboard(result: string): void; /** * Formats a date or time based on the provided format string. * * @param date - The date or time value to format. * @param {string} date_time_format - A string indicating the style used to format a date or time. * Examples: "dd-mm-yyyy", "d-m-yy", "mm/dd/yyyy", etc. * @returns {string} The formatted date or time string. */ export declare function formatDateTime(date: Date, date_time_format?: string): string; export declare function humanReadableFileSize(size: number, in17n: any): string; export declare function getDefaultUserName(): string; export declare function getActiveUserName(options?: any): string; export declare function setActiveUserName(userName: string, setBy: 'annotation_editor' | 'user'): void; export declare function attachHeadJs(src: string, id?: string, ownerDoc?: ShadowRoot | Document): Promise<any>; export declare function stripHtmlTags(s: any): string; /** * cleanseRichText: Removes outer XML tags and dangerous elements from rich text. * * This function takes a string of rich text, typically extracted from an XML document, * and cleanses it by removing the outer XML tags and any dangerous elements present. * Dangerous elements include <script>, <iframe>, <object>, <embed>, <form>, <input>, * <textarea>, <select>, <option>, and <button>. These elements are considered potentially * harmful and are stripped from the text. * * @param {string} text - The rich text string to be cleansed. * @returns {string} The cleansed rich text without the outer XML tags and dangerous elements. **/ export declare function cleanseRichText(text?: string): string; export declare function attachHeadCss(css: any, id?: string, ownerDoc?: ShadowRoot | Document): void; export declare function detachHeadJs(id: string, ownerDoc?: ShadowRoot | Document): void; export declare function detachHeadCss(id: string, ownerDoc?: ShadowRoot | Document): void; export declare function moveInkLists(inkLists: { x: number; y: number; }[][], deltaX: number, deltaY: number): void; export declare function getAccentTextColor(): string; export declare function sortedIndex(array: number[], value: number): number; export declare function isEditorModeEnabled(container: HTMLElement): boolean; export declare function logMessage(msg: string): void; export declare function logError(msg: any): void; /** * Set the checked state of an input element, toggles the * visibility of the canvas's appearance if needed. * @param element * @param isChecked */ export declare function setInputCheckedState(element: HTMLInputElement, isChecked: boolean, linkService: any, fieldValue: string): void; export declare function updateInputCheckedAppearance(input: HTMLInputElement, isChecked?: boolean, checkedButtonValue?: string | null): void; /** * Method is called when the annotation bounds position is changed. * @param node * @param diffx moved distance for x axis * @param diffy moved distance for y axis */ export declare function updateAnnotationContentPosition(node: AnnotationBase, diffx?: number, diffy?: number): void; export declare function clearAnnotationRotate(contentElement: HTMLElement): void; export declare function applyAnnotationRotate2(contentElement: HTMLElement, data: AnnotationBase, force?: boolean): void; export declare function applyAnnotationRotate(contentElement: HTMLElement, data: AnnotationBase, force?: boolean): void; export declare function insertFirst(parent: HTMLElement, insertElem: HTMLElement): void; export declare function initAnnotationRotateSupport(container: HTMLElement, data: AnnotationBase, element: HTMLElement | string): void; export declare function calcRotationRectangles(node: AnnotationBase, rotationAngle: number, knownInitialRect?: number[]): void; export declare function findRotationInit(rect: number[], angleDeg: number): number[]; export declare function updateRotationInit(annotation: AnnotationBase): void; export declare function isAnnotationAllowsSelectTextBehind(annotationElement?: HTMLElement | null): boolean; /** * getStandardizedLanguageKey - Function for obtaining a standardized language key. * @param lng - Language key in ISO 639-1 format (e.g., 'en', 'ja', 'ru', 'zh', 'de') or 'auto' for automatic detection. * @param fallbackLng - Optional, fall-back language key. * @returns The standardized language key (e.g., 'en', 'ja', 'ru', 'zh', 'de') or the fallback language name if the language key cannot be standardized. */ export declare function getStandardizedLanguageKey(lng: string | undefined, fallbackLng?: string | undefined): string; export declare function injectSerializableFile(annotation: AnnotationBase, storage: DataStorage, filePrefix?: string): void; export declare function generateRichMediaPoster(annotation: AnnotationBase, sharedRef: SharedRef, args?: { filePropName?: "posterFile" | "file"; knownFileId?: string; width?: number; height?: number; foreColor?: string; backColor?: string; drawBackOnly?: boolean; }): Promise<void>; /** * Sets image file from canvas and updates annotation properties accordingly. * @async * @param {HTMLCanvasElement} canvas - The HTML canvas element containing the image data. * @param {AnnotationBase} annotation - The annotation object to update. * @param {SharedRef} sharedRef - The shared reference object. * @param {"posterFile" | "file"} [filePropName="file"] - The property name for the file. * @param {boolean} [disposeCanvas=true] - Whether to dispose of the canvas after processing. * @returns {Promise<void>} A Promise that resolves once the operation is completed. **/ export declare function setImageFileFromCanvas(canvas: HTMLCanvasElement, annotation: AnnotationBase, sharedRef: SharedRef, filePropName?: "posterFile" | "file", disposeCanvas?: boolean, knownFileId?: string | undefined): Promise<void>; export declare function getValueFromCssText(cssText: string, key: string): string | null; /** * Loads the file data from the given URL and converts it to a Uint8Array. * * @param {string} url - The URL of the file. * @returns {Promise<Uint8Array>} - A promise that resolves to the file data as a Uint8Array. */ export declare function loadFileData(url: string): Promise<Uint8Array>; export declare function getFontFormatFromUrl(url: string, defaultFormat?: FontFormat): FontFormat | undefined;