export declare type ISafeAny = any; export declare type IScrollToLabelParams = ISafeAny; export interface ISearchParams { keyword: string; caseSensitive: boolean; } export interface IPdfConfig { pdfOnly: boolean; pdfUrl: string; pdfInfoUrl: string | IViewPort[]; pdfCharsUrl: string | string[]; pdfTextUrl: string; pdfEnablePreRender?: boolean; pdfPreRenderUrl?: string; pdfPageMaxCacheCount?: number; pdfPagePreloadCount?: number; pdfLazyLoading?: boolean; pdfGetDocumentParams?: DocumentInitParameters; } export interface IStyles { normalStyle?: Partial; hoverStyle?: Partial; selectedStyle?: Partial; activeStyle?: Partial; } export interface IFunctionsConfig { labelVisible: boolean; labelDeletable: boolean; labelSelectable: boolean; tableMergeable: boolean; tableSplitable: boolean; tableVisible: boolean; watchTableChange: boolean; defaultZoom?: number; rotationList: IPdfRotation; } export interface ITableMirroringConfig { tableMirroring: boolean; tableMirroringPages: boolean[]; } export interface IPageLoadingConfig { pageLoadingStyle?: Partial; } export interface IConfig extends IPdfConfig, Partial, Partial, IPageLoadingConfig { id: string; operateMode?: OperateMode; requestConfig?: ISafeAny; } export interface IReadyParams { pageCount: number; } export interface IViewPort { basePageIndex?: number; pageCharsCount?: number; height: number; scale: number; width: number; rotation?: number; num: number; } export interface IViewPortsObj { [key: number]: IViewPort; } export interface IMagnifierChangeEvent { viewportWidth: number; viewportHeight: number; top: number; left: number; width: number; height: number; pageNumber: number; src: string; } export interface IHistoryChangeEvent { counts: number; index: number; isFirst: boolean; isLast: boolean; labels?: ILabels; tables?: ITables; } export declare type IPdfRotation = number[]; export interface IPdfScrollingEvent { top: number; } export interface IKeyBoardEvent { altKey: boolean; char: string; charCode: number; code: string; ctrlKey: boolean; isComposing: boolean; key: string; keyCode: number; location: number; metaKey: boolean; repeat: boolean; shiftKey: boolean; DOM_KEY_LOCATION_LEFT: number; DOM_KEY_LOCATION_NUMPAD: number; DOM_KEY_LOCATION_RIGHT: number; DOM_KEY_LOCATION_STANDARD: number; } export declare enum OperateMode { none = "none", /** * 放大镜 */ magnifier = "magnifier", /** * 划选 */ textSlip = "textSlip", /** * 框选 */ textFrame = "textFrame", /** * 组合 */ textGroup = "textGroup", /** * 选择单元格 */ tableSelectCells = "tableSelectCells", /** * 新增表格 */ tableCreateTables = "tableCreateTables", /** * 调整表格 */ tableResizeTables = "tableResizeTables", /** * 删除表格 */ tableDeleteTables = "tableDeleteTables", /** * 增加横线 */ tableCreateHLines = "tableCreateHLines", /** * 增加竖线 */ tableCreateVLines = "tableCreateVLines", /** * 增加表格线 (任意长度) */ tableCreateLines = "tableCreateLines", /** * 调整线条 | 调整单元格(不规则表格) */ tableResizeCells = "tableResizeCells", /** * 删除线 */ tableDeleteLines = "tableDeleteLines", /** * 删除单元格线 */ tableDeleteCellLines = "tableDeleteCellLines", /** * 绘制单元格 */ tableCreateCells = "tableCreateCells", /** * 表格受控模式 */ tableAllControl = "tableAllControl", /** * 绘制多边形 */ polygonDrawing = "polygonDrawing", /** * 绘制矩形 */ rectDrawing = "rectDrawing", /** * 调整形状 */ shapeResizing = "shapeResizing" } export interface IScrollOffset { offsetTop?: number; offsetLeft?: number; } export interface IScrollToRectParams extends IScrollOffset { pageIndex: number; x0: number; y0: number; x1: number; y1: number; } export interface IScrollToPageParams { pageIndex: number; top?: number; } export declare type ILabelPlacement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom'; export interface ILabel extends IStyles { uuid: string; word: string; index: number; words?: ILabelRangeWord[]; selected?: boolean; active?: boolean; pageNumber?: number; unselectable?: boolean; deleteable?: boolean; position?: ILabelPosition; lastPageNumber?: number; prevPagesHeight?: number; activeAnimation?: 'normal' | 'flash'; tooltipHidden?: boolean; controlExp?: { text: string; height: number; style: Partial; placement?: ILabelPlacement; visible?: 'none' | 'start' | 'end' | 'all'; }; info?: { [prop: string]: ISafeAny; }; } export interface ILabelRangeWord { index: number; word: string; pageNumber: number; top: number; left: number; width: number; height: number; docIndex: number; } export interface ISearchLabel extends ILabel { prefix: string; suffix: string; } export declare type ILabelPosition = [number, number, number, number]; export declare type ILabels = ILabel[]; export declare type ISearchLabels = ISearchLabel[]; export interface IClickMetadata { altKey: boolean; ctrlKey: boolean; metaKey: boolean; shiftKey: boolean; which: number; } export interface IPosition { x: number; y: number; width: number; height: number; } export interface IPointer { x: number; y: number; } export interface IEvent { data: T[]; } export interface IEventWithPosition { data: T[]; position: IPosition; } export declare type ICreateLabelsEvent = IEventWithPosition; export declare type IDragLabelsEvent = IEvent; export declare type IResizeLabelsEvent = IEvent; export declare type IDeleteLabelsEvent = IEventWithPosition; export declare type IMouseEnterLabelsEvent = IEventWithPosition; export declare type IMouseLeaveLabelsEvent = IEvent; export interface IClickLabelsEvent extends IEventWithPosition { metadata: IClickMetadata; } export interface IScrollToLabelsParams extends IScrollOffset { labels: ILabel[]; activeIndex?: number; } export interface ISetLabelsParams { labels: ILabels; recordHistory?: boolean; } /** * 可视化 page json */ export interface IVisualPageJsonParams { pageNumberList: number[]; borderVisible?: boolean; borderCorrection?: boolean; textVisible?: boolean; indexVisible?: boolean; } export interface ISetShapesParams { shapes: IShapes; } export interface ITableStyle { lineStyle: { defaultColor: string; }; } export interface ITable { table_id?: string; mask: number[][]; cells: ICell[][]; style?: ITableStyle; text_matrix: string[][]; matrix_type: null | 'insert' | 'update' | 'delete'; } export interface ICell extends IStyles { x: number; y: number; height: number; width: number; page_num: number; tableId?: string; text?: string; } export declare type ITables = { page_number: number; tables: ITable[]; }[]; export interface IScrollToTablesParams extends IScrollOffset { tables: ITable[]; activeIndex?: number; } export interface IScrollToTableCellsParams extends IScrollOffset { cells: ICell[]; activeIndex?: number; } export interface IHighLightTableCellsParams extends IScrollOffset { cells: ICell[]; activeIndex?: number; } export interface IHighLightTableCells extends IScrollOffset { cells: { x: number; y: number; width: number; height: number; groupId: string; pageIndex: number; style?: Partial; hoverStyle?: Partial; }[]; } export interface ITableMatrix { tableId: string; type: 'update' | 'insert' | 'delete' | null; pageNumber: number; area: number[]; lines: number[][][]; } export interface IThinTable { tableId: string; pageIndex: number; } export interface IViewTable { tableId: string; height: number; top: number; containerHeight: number; } export declare type ICreateTablesEvent = IEvent<{ id: string; area: IPosition; pageIndex: number; }>; export declare type IViewTablesChangeEvent = IEvent; export declare type IDeleteTablesEvent = IEvent; export declare type IMouseEnterTablesEvent = IEventWithPosition; export declare type IMouseLeaveTablesEvent = IEvent; export interface IClickTablesEvent extends IEventWithPosition { cell: { x: number; y: number; col: number; row: number; selected: boolean; } | null; metadata: IClickMetadata; } export interface IUpdateTablesEvent { data: { tableId: string; cells: ICell[][]; mask: number[][]; }[]; } export interface IMergeTablesEvent { data: { tableId: string; cells: ICell[][]; mask: number[][]; pageIndex: number; }[]; } export declare type IHighLightCells = Array<{ tableId: string; pageNumber: number; startPoint: IPosition; endPoint: IPosition; style?: Partial; }>; export declare type ISplitTablesEvent = IEvent; /****************************************************************************** * * 不规则表格 * ******************************************************************************/ /** * 不规则表格 JSON */ export interface IIRCell { uuid: string; x: number; y: number; width: number; height: number; page_number: number; tooltip?: string; hidden?: boolean; selected?: boolean; active?: boolean; selectable?: boolean; deletable?: boolean; normalStyle?: Partial; selectedStyle?: Partial; hoverStyle?: Partial; activeStyle?: Partial; info?: { [key: string]: any; }; } export declare type IIRLineRow = [[number, number], [number, number]]; export declare type IIRCellRow = IIRCell[]; export declare type IIRTable = IIRTablePerPage[]; export interface IIRTableStyle extends ITableStyle { } export interface IIRTablePerPage { page_number: number; tables: Array<{ table_id: string; cells: IIRCellRow[]; lines: IIRLineRow[]; style?: IIRTableStyle; }>; } /** * * 不规则表格 EVENT * */ export declare type IUpdateIRTablesEvent = IEvent<{ tableId: string; cells: IIRCellRow[]; lines: IIRLineRow[]; }>; /** * 创建单元格(绘制单元格) */ export declare type ICreateIRTableCellsEvent = IEvent<{ area: { x: number; y: number; width: number; height: number; }; tableId: string; pageNumber: number; cells: IIRCellRow[]; lines: IIRLineRow[]; }>; /** * 跳转到单元格 */ export interface IScrollToIRTableCellsParams extends IScrollOffset { cells: Array<{ x: number; y: number; width: number; height: number; tableId: string; pageNumber: number; style: Partial; }>; } /****************************************************************************** * * 图形标注 * ******************************************************************************/ /** * 新增图形 */ export declare type ICreateShapesEvent = IEvent<(Omit | Omit) & { pageNumber: number; }>; export declare type IShapeEventBase = (Omit | Omit) & { pageNumber: number; uuid: string; }; /** * 点击图形 */ export declare type IClickShapesEvent = IEvent; /** * 更新图形 */ export declare type IUpdateShapesEvent = IEvent; /** * 删除图形 */ export declare type IDeleteShapesEvent = IEvent; /** * 图形 dom 更新 */ export interface IShapeDomsChangeEvent { data: { [uuid: string]: boolean; }; } export interface DocumentInitParameters { /** * - Basic authentication headers. */ httpHeaders?: Object; /** * - Indicates whether or not * cross-site Access-Control requests should be made using credentials such * as cookies or authorization headers. The default is `false`. */ withCredentials?: boolean; /** * - For decrypting password-protected PDFs. */ password?: string; /** * - The PDF file length. It's used for progress * reports and range requests operations. */ length?: number; /** * - Specify maximum number of bytes fetched * per range request. The default value is {@link DEFAULT_RANGE_CHUNK_SIZE}. */ rangeChunkSize?: number; /** * - The worker that will be used for loading and * parsing the PDF data. */ worker?: ISafeAny; /** * - Controls the logging level; the constants * from {@link VerbosityLevel} should be used. */ verbosity?: number; /** * - The base URL of the document, used when * attempting to recover valid absolute URLs for annotations, and outline * items, that (incorrectly) only specify relative URLs. */ docBaseUrl?: string; /** * - The URL where the predefined Adobe CMaps are * located. Include the trailing slash. */ cMapUrl?: string; /** * - Specifies if the Adobe CMaps are binary * packed or not. */ cMapPacked?: boolean; /** * - The factory that will be used when * reading built-in CMap files. Providing a custom factory is useful for * environments without Fetch API or `XMLHttpRequest` support, such as * Node.js. The default value is {DOMCMapReaderFactory}. */ CMapReaderFactory?: Object; /** * - Reject certain promises, e.g. * `getOperatorList`, `getTextContent`, and `RenderTask`, when the associated * PDF data cannot be successfully parsed, instead of attempting to recover * whatever possible of the data. The default value is `false`. */ stopAtErrors?: boolean; /** * - The maximum allowed image size in total * pixels, i.e. width * height. Images above this value will not be rendered. * Use -1 for no limit, which is also the default value. */ maxImageSize?: number; /** * - Determines if we can evaluate strings * as JavaScript. Primarily used to improve performance of font rendering, and * when parsing PDF functions. The default value is `true`. */ isEvalSupported?: boolean; /** * - By default fonts are converted to * OpenType fonts and loaded via `@font-face` rules. If disabled, fonts will * be rendered using a built-in font renderer that constructs the glyphs with * primitive path commands. The default value is `false`. */ disableFontFace?: boolean; /** * - Include additional properties, * which are unused during rendering of PDF documents, when exporting the * parsed font data from the worker-thread. This may be useful for debugging * purposes (and backwards compatibility), but note that it will lead to * increased memory usage. The default value is `false`. */ fontExtraProperties?: boolean; /** * - Specify an explicit document * context to create elements with and to load resources, such as fonts, * into. Defaults to the current document. */ ownerDocument?: HTMLDocument; /** * - Disable range request loading of PDF * files. When enabled, and if the server supports partial content requests, * then the PDF will be fetched in chunks. The default value is `false`. */ disableRange?: boolean; /** * - Disable streaming of PDF file data. * By default PDF.js attempts to load PDF files in chunks. The default value * is `false`. */ disableStream?: boolean; /** * - Disable pre-fetching of PDF file * data. When range requests are enabled PDF.js will automatically keep * fetching more data even if it isn't needed to display the current page. * The default value is `false`. * * NOTE: It is also necessary to disable streaming, see above, in order for * disabling of pre-fetching to work correctly. */ disableAutoFetch?: boolean; /** * - Enables special hooks for debugging PDF.js * (see `web/debugger.js`). The default value is `false`. */ pdfBug?: boolean; } export declare type IShapes = IShape[]; export declare type IShape = IShapePolygon | IShapeRectangle; export declare type IShapeDecalPlacement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom'; export interface IShapeDecal { placement: IShapeDecalPlacement; text: string; style?: Partial; bgColor?: string; } export interface IShapeBase extends IStyles { pageNumber: number; uuid: string; selected?: boolean; active?: boolean; selectable?: boolean; deleteable?: boolean; hidden?: boolean; trackDomChange?: boolean; activeAnimation?: 'flash' | 'normal'; decal?: IShapeDecal; info?: { [key: string]: ISafeAny; }; } export interface IShapePolygon extends IShapeBase { type: 'polygon'; points: IPointer[]; } export interface IShapeRectangle extends IShapeBase { type: 'rectangle'; points: [IPointer, IPointer]; } export interface IScrollToShapesParams extends IScrollOffset { shapes: IShapes; activeIndex?: number; topDistance?: number; }