@chialab/pdfjs-lib 1.0.0-alpha.3 → 1.0.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -7
- package/dist/browser/{FoxitDingbats-SB6TO3S5.js → FoxitDingbats-XZTZYAP6.js} +1 -1
- package/dist/browser/{FoxitFixed-UIGSMBQB.js → FoxitFixed-DRWD6QNM.js} +1 -1
- package/dist/browser/{FoxitFixedBold-2PAEIZAT.js → FoxitFixedBold-A3IBPIFC.js} +1 -1
- package/dist/browser/{FoxitFixedBoldItalic-OSQUQDEE.js → FoxitFixedBoldItalic-V4ORMFGL.js} +1 -1
- package/dist/browser/{FoxitFixedItalic-W73RDK22.js → FoxitFixedItalic-Z7BSNTJA.js} +1 -1
- package/dist/browser/{FoxitSerif-3HH3SOZF.js → FoxitSerif-Y34FHWHO.js} +1 -1
- package/dist/browser/{FoxitSerifBold-HXP2QOO7.js → FoxitSerifBold-NCWBT4GX.js} +1 -1
- package/dist/browser/{FoxitSerifBoldItalic-FZXLNWD7.js → FoxitSerifBoldItalic-YTEOG5ZU.js} +1 -1
- package/dist/browser/{FoxitSerifItalic-WQFHUBI2.js → FoxitSerifItalic-3H547RIJ.js} +1 -1
- package/dist/browser/{FoxitSymbol-OVWU7LKS.js → FoxitSymbol-EMTQEYPB.js} +1 -1
- package/dist/browser/{LiberationSans-Bold-GSJN42N5.js → LiberationSans-Bold-MGX34QV4.js} +1 -1
- package/dist/browser/LiberationSans-Bold-PQY5JZAT.js +9 -0
- package/dist/browser/LiberationSans-BoldItalic-PBNZJX4S.js +9 -0
- package/dist/browser/{LiberationSans-BoldItalic-UCPQJ3L2.js → LiberationSans-BoldItalic-WSEQ5LH5.js} +1 -1
- package/dist/browser/{LiberationSans-Italic-6CIHEALY.js → LiberationSans-Italic-E4SLDR4M.js} +1 -1
- package/dist/browser/LiberationSans-Italic-NAYVQTNG.js +9 -0
- package/dist/browser/{LiberationSans-Regular-KIF3IRJY.js → LiberationSans-Regular-3SH5NGZO.js} +1 -1
- package/dist/browser/LiberationSans-Regular-FMNBW2LE.js +9 -0
- package/dist/browser/NodeUtilsStabs-AQQCOPNR.js +19 -0
- package/dist/browser/chunk-3ZTAZS2X.js +25 -0
- package/dist/browser/{chunk-O4UKW7AD.js → chunk-7YYVRRNF.js} +5 -0
- package/dist/browser/{chunk-DYHYQ33L.js → chunk-R7G44NYV.js} +834 -84
- package/dist/browser/index.js +21400 -4931
- package/dist/browser/openjpeg-Q27OVS4T.js +9 -0
- package/dist/browser/qcms_bg-BCJEADMU.js +9 -0
- package/dist/browser/worker.js +8311 -7089
- package/dist/index.d.ts +11 -1
- package/dist/lib/AnnotationData.d.ts +8 -8
- package/dist/lib/AnnotationOperatorsList.d.ts +21 -0
- package/dist/lib/Canvas.d.ts +0 -5
- package/dist/lib/CanvasGraphics.d.ts +1 -0
- package/dist/lib/NodeCanvasFactory.d.ts +9 -0
- package/dist/lib/NodeFilterFactory.d.ts +10 -0
- package/dist/lib/NodeUtils.d.ts +24 -0
- package/dist/lib/Path2D.d.ts +9 -49
- package/dist/lib/StandardFontDataFactory.d.ts +2 -2
- package/dist/lib/StructTreePage.d.ts +5 -0
- package/dist/lib/Svg.d.ts +144 -0
- package/dist/lib/SvgCanvasContext.d.ts +36 -22
- package/dist/lib/TextLayer.d.ts +48 -10
- package/dist/lib/TextLayer_v2.d.ts +8 -0
- package/dist/lib/WasmFactory.d.ts +5 -0
- package/dist/lib/utils.d.ts +29 -3
- package/dist/node/{FoxitDingbats-65AZ2Z2V.js → FoxitDingbats-UZC34T4F.js} +1 -1
- package/dist/node/{FoxitFixed-OZGLVVOQ.js → FoxitFixed-DSJVG3IJ.js} +1 -1
- package/dist/node/{FoxitFixedBold-37OOYMV7.js → FoxitFixedBold-YSX4X5NA.js} +1 -1
- package/dist/node/{FoxitFixedBoldItalic-XYFHEG2V.js → FoxitFixedBoldItalic-IFYYA6RR.js} +1 -1
- package/dist/node/{FoxitFixedItalic-MM7OSGS6.js → FoxitFixedItalic-4PEFPCQV.js} +1 -1
- package/dist/node/{FoxitSerif-MLMJQPRP.js → FoxitSerif-7SSP2H2U.js} +1 -1
- package/dist/node/{FoxitSerifBold-AC7RJQWJ.js → FoxitSerifBold-KLMURJ6N.js} +1 -1
- package/dist/node/{FoxitSerifBoldItalic-YCQ4CLKE.js → FoxitSerifBoldItalic-VSYHWLRM.js} +1 -1
- package/dist/node/{FoxitSerifItalic-CXVTCST4.js → FoxitSerifItalic-NTOPMQDD.js} +1 -1
- package/dist/node/{FoxitSymbol-VUGMZN5C.js → FoxitSymbol-QPUM74UN.js} +1 -1
- package/dist/node/{LiberationSans-Bold-XSHQQBWB.js → LiberationSans-Bold-BXFYN4PV.js} +1 -1
- package/dist/node/LiberationSans-Bold-VIZ4XT4N.js +9 -0
- package/dist/node/{LiberationSans-BoldItalic-CTAZRFRL.js → LiberationSans-BoldItalic-DQQC5TNJ.js} +1 -1
- package/dist/node/LiberationSans-BoldItalic-WXMOSICD.js +9 -0
- package/dist/node/LiberationSans-Italic-34IBVQZ4.js +9 -0
- package/dist/node/{LiberationSans-Italic-WIOTUKLC.js → LiberationSans-Italic-Z4MFN6PY.js} +1 -1
- package/dist/node/LiberationSans-Regular-JOSGNSW5.js +9 -0
- package/dist/node/{LiberationSans-Regular-CDMMZL5S.js → LiberationSans-Regular-MACKS2VL.js} +1 -1
- package/dist/node/NodeUtils-PVXQMWFJ.js +20 -0
- package/dist/node/chunk-4Y7OZIIX.js +1319 -0
- package/dist/node/chunk-O74KGUUC.js +2093 -0
- package/dist/node/chunk-T2JWSGAF.js +1225 -0
- package/dist/node/chunk-ZFIGV5OT.js +63 -0
- package/dist/node/index.js +23520 -8727
- package/dist/node/openjpeg-QFJSFVSJ.js +9 -0
- package/dist/node/qcms_bg-PRPVJQFC.js +9 -0
- package/dist/node/worker.js +8320 -7096
- package/dist/pdf.js/external/openjpeg/openjpeg.d.ts +2 -0
- package/dist/pdf.js/external/qcms/qcms.d.ts +92 -0
- package/dist/pdf.js/external/qcms/qcms_utils.d.ts +14 -0
- package/dist/pdf.js/src/core/arithmetic_decoder.d.ts +21 -0
- package/dist/pdf.js/src/core/ascii_85_stream.d.ts +8 -0
- package/dist/pdf.js/src/core/ascii_hex_stream.d.ts +8 -0
- package/dist/pdf.js/src/core/base_stream.d.ts +32 -0
- package/dist/pdf.js/src/core/binary_cmap.d.ts +3 -0
- package/dist/pdf.js/src/core/ccitt.d.ts +72 -0
- package/dist/pdf.js/src/core/ccitt_stream.d.ts +9 -0
- package/dist/pdf.js/src/core/cff_font.d.ts +15 -0
- package/dist/pdf.js/src/core/cff_parser.d.ts +166 -0
- package/dist/pdf.js/src/core/charsets.d.ts +3 -0
- package/dist/pdf.js/src/core/cmap.d.ts +37 -0
- package/dist/pdf.js/src/core/colorspace.d.ts +177 -0
- package/dist/pdf.js/src/core/colorspace_utils.d.ts +21 -0
- package/dist/pdf.js/src/core/core_utils.d.ts +140 -0
- package/dist/pdf.js/src/core/decode_stream.d.ts +25 -0
- package/dist/pdf.js/src/core/encodings.d.ts +7 -0
- package/dist/pdf.js/src/core/flate_stream.d.ts +15 -0
- package/dist/pdf.js/src/core/font_renderer.d.ts +34 -0
- package/dist/pdf.js/src/core/fonts.d.ts +98 -0
- package/dist/pdf.js/src/core/fonts_utils.d.ts +32 -0
- package/dist/pdf.js/src/core/glyf.d.ts +44 -0
- package/dist/pdf.js/src/core/glyphlist.d.ts +2 -0
- package/dist/pdf.js/src/core/icc_colorspace.d.ts +22 -0
- package/dist/pdf.js/src/core/jbig2.d.ts +12 -0
- package/dist/pdf.js/src/core/jbig2_stream.d.ts +17 -0
- package/dist/pdf.js/src/core/jpeg_stream.d.ts +25 -0
- package/dist/pdf.js/src/core/jpg.d.ts +62 -0
- package/dist/pdf.js/src/core/jpx.d.ts +35 -0
- package/dist/pdf.js/src/core/jpx_stream.d.ts +17 -0
- package/dist/pdf.js/src/core/lzw_stream.d.ts +21 -0
- package/dist/pdf.js/src/core/metrics.d.ts +2 -0
- package/dist/pdf.js/src/core/name_number_tree.d.ts +21 -0
- package/dist/pdf.js/src/core/opentype_file_builder.d.ts +12 -0
- package/dist/pdf.js/src/core/parser.d.ts +81 -0
- package/dist/pdf.js/src/core/predictor_stream.d.ts +15 -0
- package/dist/pdf.js/src/core/primitives.d.ts +78 -0
- package/dist/pdf.js/src/core/run_length_stream.d.ts +7 -0
- package/dist/pdf.js/src/core/standard_fonts.d.ts +18 -0
- package/dist/pdf.js/src/core/stream.d.ts +21 -0
- package/dist/pdf.js/src/core/struct_tree.d.ts +92 -0
- package/dist/pdf.js/src/core/to_unicode_map.d.ts +21 -0
- package/dist/pdf.js/src/core/type1_font.d.ts +17 -0
- package/dist/pdf.js/src/core/type1_parser.d.ts +29 -0
- package/dist/pdf.js/src/core/unicode.d.ts +5 -0
- package/dist/pdf.js/src/display/annotation_layer.d.ts +35 -5
- package/dist/pdf.js/src/display/annotation_storage.d.ts +3 -8
- package/dist/pdf.js/src/display/api.d.ts +86 -77
- package/dist/pdf.js/src/display/api_utils.d.ts +13 -0
- package/dist/pdf.js/src/display/canvas.d.ts +88 -94
- package/dist/pdf.js/src/display/canvas_dependency_tracker.d.ts +160 -0
- package/dist/pdf.js/src/display/display_utils.d.ts +34 -1
- package/dist/pdf.js/src/display/draw_layer.d.ts +2 -2
- package/dist/pdf.js/src/display/editor/alt_text.d.ts +1 -1
- package/dist/pdf.js/src/display/editor/annotation_editor_layer.d.ts +10 -8
- package/dist/pdf.js/src/display/editor/color_picker.d.ts +20 -1
- package/dist/pdf.js/src/display/editor/comment.d.ts +47 -0
- package/dist/pdf.js/src/display/editor/draw.d.ts +8 -8
- package/dist/pdf.js/src/display/editor/drawers/freedraw.d.ts +4 -3
- package/dist/pdf.js/src/display/editor/drawers/highlight.d.ts +2 -1
- package/dist/pdf.js/src/display/editor/drawers/signaturedraw.d.ts +13 -13
- package/dist/pdf.js/src/display/editor/editor.d.ts +117 -16
- package/dist/pdf.js/src/display/editor/freetext.d.ts +11 -7
- package/dist/pdf.js/src/display/editor/highlight.d.ts +9 -3
- package/dist/pdf.js/src/display/editor/ink.d.ts +6 -0
- package/dist/pdf.js/src/display/editor/signature.d.ts +3 -5
- package/dist/pdf.js/src/display/editor/stamp.d.ts +4 -3
- package/dist/pdf.js/src/display/editor/toolbar.d.ts +8 -3
- package/dist/pdf.js/src/display/editor/tools.d.ts +36 -12
- package/dist/pdf.js/src/display/font_loader.d.ts +27 -1
- package/dist/pdf.js/src/display/metadata.d.ts +1 -2
- package/dist/pdf.js/src/display/optional_content_config.d.ts +1 -1
- package/dist/pdf.js/src/display/pattern_helper.d.ts +6 -4
- package/dist/pdf.js/src/display/pdf_objects.d.ts +40 -0
- package/dist/pdf.js/src/display/text_layer.d.ts +9 -9
- package/dist/pdf.js/src/display/touch_manager.d.ts +5 -1
- package/dist/pdf.js/src/display/worker_options.d.ts +2 -2
- package/dist/pdf.js/src/pdf.d.ts +9 -1
- package/dist/pdf.js/src/shared/obj-bin-transform.d.ts +64 -0
- package/dist/pdf.js/src/shared/scripting_utils.d.ts +2 -0
- package/dist/pdf.js/src/shared/util.d.ts +129 -102
- package/dist/pdf.js/web/comment_manager.d.ts +20 -0
- package/dist/pdf.js/web/interfaces.d.ts +7 -0
- package/dist/pdf.js/web/text_accessibility.d.ts +1 -1
- package/package.json +16 -4
- package/dist/node/chunk-7MW5RQZ5.js +0 -30
- package/dist/node/chunk-KTTVPO2G.js +0 -1775
- package/dist/pdf.js/src/display/node_utils.d.ts +0 -32
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,19 @@ import './lib/PDFPageProxy';
|
|
|
3
3
|
export type { DocumentInitParameters } from './pdf.js/src/display/api';
|
|
4
4
|
export type { BaseCanvasFactory } from './pdf.js/src/display/canvas_factory';
|
|
5
5
|
export * from './lib/utils';
|
|
6
|
+
export { type SvgRoot, type SvgElement, type SvgImage, type SvgMarkedContent, type SvgPath, type SvgNode, isSvgElement, isSvgImage, isSvgMarkedContent, isSvgPath, isSvgRoot, renderSvgNode, } from './lib/Svg';
|
|
6
7
|
export * from './lib/Canvas';
|
|
8
|
+
export * from './lib/WasmFactory';
|
|
7
9
|
export * from './lib/StandardFontDataFactory';
|
|
8
10
|
export * from './lib/AnnotationData';
|
|
11
|
+
export * from './lib/CanvasGraphics';
|
|
9
12
|
export * from './lib/SvgCanvasContext';
|
|
10
|
-
export
|
|
13
|
+
export { type TextLayerRoot, type TextLayerNode, type TextLayerAnchor, type TextLayerFigure, type TextLayerElement, TEXT_LAYER_FONT_FAMILY, isTextNode, isAnchorNode, isFigureNode, isElementNode, createTextLayer, loadTextLayerFonts, loadDefaultFonts, renderTextLayer, } from './lib/TextLayer';
|
|
14
|
+
export declare const textLayerUtils: {
|
|
15
|
+
findNode: (root: import(".").TextLayerElement, callback: (node: import(".").TextLayerNode, parent: import(".").TextLayerElement) => boolean | null | undefined) => import(".").TextLayerNode | null;
|
|
16
|
+
findNodes: (node: import(".").TextLayerElement, callback: (node: import(".").TextLayerNode, parent: import(".").TextLayerElement) => boolean | null | undefined) => import(".").TextLayerNode[];
|
|
17
|
+
getNodeContents: (node: import(".").TextLayerNode) => string;
|
|
18
|
+
flattenNodes: (node: import(".").TextLayerNode | string) => import(".").TextLayerNode[];
|
|
19
|
+
};
|
|
20
|
+
export * from './lib/TextLayer_v2';
|
|
11
21
|
export * from './pdf.js/src/pdf.js';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
type
|
|
2
|
-
type
|
|
3
|
-
type
|
|
4
|
-
|
|
1
|
+
import type { SvgRoot } from './Svg';
|
|
2
|
+
export type Rect = [number, number, number, number];
|
|
3
|
+
export type Color = [number, number, number];
|
|
4
|
+
export type Dir = 'ltr' | 'rtl';
|
|
5
|
+
export declare enum BorderStyle {
|
|
5
6
|
SOLID = 1,
|
|
6
7
|
DASHED = 2
|
|
7
8
|
}
|
|
8
|
-
declare enum LineEnding {
|
|
9
|
+
export declare enum LineEnding {
|
|
9
10
|
NONE = "None",
|
|
10
11
|
SQUARE = "Square",
|
|
11
12
|
CIRCLE = "Circle",
|
|
@@ -106,7 +107,7 @@ export interface StrikeOutAnnotationData extends TextAnnotationData {
|
|
|
106
107
|
}
|
|
107
108
|
export interface StampAnnotationData extends TextAnnotationData {
|
|
108
109
|
subtype: 'Stamp';
|
|
109
|
-
graphics:
|
|
110
|
+
graphics: SvgRoot;
|
|
110
111
|
}
|
|
111
112
|
export interface CaretAnnotationData extends TextAnnotationData {
|
|
112
113
|
subtype: 'Caret';
|
|
@@ -122,7 +123,7 @@ export interface FileAttachmentAnnotationData extends TextAnnotationData {
|
|
|
122
123
|
subtype: 'FileAttachment';
|
|
123
124
|
file: {
|
|
124
125
|
filename: string;
|
|
125
|
-
content?: Uint8Array | null;
|
|
126
|
+
content?: Uint8Array<ArrayBuffer> | null;
|
|
126
127
|
};
|
|
127
128
|
}
|
|
128
129
|
export interface SoundAnnotationData extends TextAnnotationData {
|
|
@@ -201,4 +202,3 @@ export declare function isTrapNetAnnotation(annotation: AnnotationData): annotat
|
|
|
201
202
|
export declare function isWatermarkAnnotation(annotation: AnnotationData): annotation is WatermarkAnnotationData;
|
|
202
203
|
export declare function isThreeDAnnotation(annotation: AnnotationData): annotation is ThreeDAnnotationData;
|
|
203
204
|
export declare function isRedactAnnotation(annotation: AnnotationData): annotation is RedactAnnotationData;
|
|
204
|
-
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PDFOperatorList } from '../pdf.js/src/display/api';
|
|
2
|
+
export declare class AnnotationOperatorsList {
|
|
3
|
+
readonly map: Map<string, {
|
|
4
|
+
fn: number;
|
|
5
|
+
args: unknown[];
|
|
6
|
+
}[]>;
|
|
7
|
+
/**
|
|
8
|
+
* The list of operators to be executed.
|
|
9
|
+
* @param operatorList The list of operators to be executed.
|
|
10
|
+
*/
|
|
11
|
+
constructor(operatorList: PDFOperatorList);
|
|
12
|
+
/**
|
|
13
|
+
* Get the list of operators for the given annotation id.
|
|
14
|
+
* @param id The id of the annotation.
|
|
15
|
+
* @return The list of operators for the given annotation id.
|
|
16
|
+
*/
|
|
17
|
+
get(id: string): {
|
|
18
|
+
fn: number;
|
|
19
|
+
args: unknown[];
|
|
20
|
+
}[];
|
|
21
|
+
}
|
package/dist/lib/Canvas.d.ts
CHANGED
|
@@ -9,9 +9,4 @@ declare const Path2DConstructor: {
|
|
|
9
9
|
* @returns A promise that resolves to the canvas.
|
|
10
10
|
*/
|
|
11
11
|
export declare function createCanvas(width: number, height: number): Promise<HTMLCanvasElement>;
|
|
12
|
-
/**
|
|
13
|
-
* Load the fonts.
|
|
14
|
-
* @returns A promise that resolves when the fonts are loaded.
|
|
15
|
-
*/
|
|
16
|
-
export declare function loadDefaultFonts(): Promise<void>;
|
|
17
12
|
export { Path2DConstructor as Path2D };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Canvas } from 'skia-canvas';
|
|
2
|
+
import { BaseCanvasFactory } from '../pdf.js/src/display/canvas_factory.js';
|
|
3
|
+
export declare class NodeCanvasFactory extends BaseCanvasFactory {
|
|
4
|
+
_createCanvas(width: number, height: number): Canvas;
|
|
5
|
+
create(width: number, height: number): {
|
|
6
|
+
canvas: void;
|
|
7
|
+
context: any;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseFilterFactory } from '../pdf.js/src/display/filter_factory.js';
|
|
2
|
+
export type Filter = (ctx: CanvasRenderingContext2D) => void;
|
|
3
|
+
export declare const filtersRegistry: Map<string, Filter>;
|
|
4
|
+
export declare class NodeFilterFactory extends BaseFilterFactory {
|
|
5
|
+
addFilter(maps: number[][]): string;
|
|
6
|
+
addHCMFilter(fgColor: string, bgColor: string): string;
|
|
7
|
+
addAlphaFilter(map: number[]): string;
|
|
8
|
+
addLuminosityFilter(map?: number[]): string;
|
|
9
|
+
addHighlightHCMFilter(filterName: string, fgColor: string, bgColor: string, newFgColor: string, newBgColor: string): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseCMapReaderFactory } from '../pdf.js/src/display/cmap_reader_factory.js';
|
|
2
|
+
import { BaseStandardFontDataFactory } from '../pdf.js/src/display/standard_fontdata_factory.js';
|
|
3
|
+
import { BaseWasmFactory } from '../pdf.js/src/display/wasm_factory.js';
|
|
4
|
+
export declare function fetchData(url: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
5
|
+
export declare class NodeCMapReaderFactory extends BaseCMapReaderFactory {
|
|
6
|
+
/**
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
9
|
+
_fetch(url: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
10
|
+
}
|
|
11
|
+
export declare class NodeStandardFontDataFactory extends BaseStandardFontDataFactory {
|
|
12
|
+
/**
|
|
13
|
+
* @ignore
|
|
14
|
+
*/
|
|
15
|
+
_fetch(url: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
16
|
+
}
|
|
17
|
+
export declare class NodeWasmFactory extends BaseWasmFactory {
|
|
18
|
+
/**
|
|
19
|
+
* @ignore
|
|
20
|
+
*/
|
|
21
|
+
_fetch(url: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
22
|
+
}
|
|
23
|
+
export * from './NodeCanvasFactory.js';
|
|
24
|
+
export * from './NodeFilterFactory.js';
|
package/dist/lib/Path2D.d.ts
CHANGED
|
@@ -1,57 +1,17 @@
|
|
|
1
1
|
import { Path2D } from './Canvas';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
export declare enum CommandType {
|
|
3
|
+
MoveTo = 0,
|
|
4
|
+
LineTo = 1,
|
|
5
|
+
Arc = 2,
|
|
6
|
+
Bezier = 3,
|
|
7
|
+
Quad = 4,
|
|
8
|
+
Close = 5
|
|
8
9
|
}
|
|
9
|
-
export
|
|
10
|
-
type: 'lineTo';
|
|
11
|
-
args: {
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export interface ArcCommand {
|
|
17
|
-
type: 'arc';
|
|
18
|
-
args: {
|
|
19
|
-
x: number;
|
|
20
|
-
y: number;
|
|
21
|
-
radius: number;
|
|
22
|
-
startAngle: number;
|
|
23
|
-
endAngle: number;
|
|
24
|
-
anticlockwise: boolean;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export interface BezierCurveToCommand {
|
|
28
|
-
type: 'bezierCurveTo';
|
|
29
|
-
args: {
|
|
30
|
-
cp1x: number;
|
|
31
|
-
cp1y: number;
|
|
32
|
-
cp2x: number;
|
|
33
|
-
cp2y: number;
|
|
34
|
-
x: number;
|
|
35
|
-
y: number;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export interface QuadraticCurveToCommand {
|
|
39
|
-
type: 'quadraticCurveTo';
|
|
40
|
-
args: {
|
|
41
|
-
qx1: number;
|
|
42
|
-
qy1: number;
|
|
43
|
-
qx: number;
|
|
44
|
-
qy: number;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export interface ClosePathCommand {
|
|
48
|
-
type: 'closePath';
|
|
49
|
-
}
|
|
50
|
-
export type PathCommand = MoveToCommand | LineToCommand | ArcCommand | BezierCurveToCommand | QuadraticCurveToCommand | ClosePathCommand;
|
|
10
|
+
export type PathCommand = [CommandType.MoveTo, number, number] | [CommandType.LineTo, number, number] | [CommandType.Arc, number, number, number, number, number, boolean] | [CommandType.Bezier, number, number, number, number, number, number] | [CommandType.Quad, number, number, number, number] | [CommandType.Close];
|
|
51
11
|
export declare function parseCommands(svgPath: string): PathCommand[];
|
|
52
12
|
export declare function commandToSvgPath(command: PathCommand): string;
|
|
53
13
|
export declare function transformPath(commands: PathCommand[], transform: DOMMatrix): PathCommand[];
|
|
54
|
-
export declare function
|
|
14
|
+
export declare function getBBox(commands: PathCommand[]): {
|
|
55
15
|
x: number;
|
|
56
16
|
y: number;
|
|
57
17
|
width: number;
|
|
@@ -8,7 +8,7 @@ export declare class StandardFontDataFactory extends BaseStandardFontDataFactory
|
|
|
8
8
|
* Fetch the corresponding standard font data.
|
|
9
9
|
* We need to use specific dynamic imports for each font file for the bundler to include them.
|
|
10
10
|
*/
|
|
11
|
-
fetch({ filename }: {
|
|
11
|
+
fetch({ filename, }: {
|
|
12
12
|
filename: string;
|
|
13
|
-
}): Promise<Uint8Array
|
|
13
|
+
}): Promise<Uint8Array<ArrayBuffer>>;
|
|
14
14
|
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
type BoundingBox = {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
7
|
+
export interface SvgNode<Attrs = Record<string, unknown>> {
|
|
8
|
+
tag: string;
|
|
9
|
+
attrs: Attrs & {
|
|
10
|
+
transform?: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface SvgElement<Attrs = Record<string, unknown>> extends SvgNode<Attrs> {
|
|
14
|
+
children: (SvgNode | string)[];
|
|
15
|
+
}
|
|
16
|
+
export interface SvgGraphic extends SvgNode<{
|
|
17
|
+
x?: number;
|
|
18
|
+
y?: number;
|
|
19
|
+
width?: number;
|
|
20
|
+
height?: number;
|
|
21
|
+
x1?: number;
|
|
22
|
+
y1?: number;
|
|
23
|
+
x2?: number;
|
|
24
|
+
y2?: number;
|
|
25
|
+
points?: string;
|
|
26
|
+
cx?: number;
|
|
27
|
+
cy?: number;
|
|
28
|
+
r?: number;
|
|
29
|
+
rx?: number;
|
|
30
|
+
ry?: number;
|
|
31
|
+
}> {
|
|
32
|
+
}
|
|
33
|
+
export interface SvgPath extends SvgNode<{
|
|
34
|
+
d: string;
|
|
35
|
+
fill?: string;
|
|
36
|
+
stroke?: string;
|
|
37
|
+
'stroke-width'?: string | number;
|
|
38
|
+
'is-glyph'?: boolean;
|
|
39
|
+
}> {
|
|
40
|
+
tag: 'path';
|
|
41
|
+
}
|
|
42
|
+
export interface SvgImage extends SvgNode<{
|
|
43
|
+
href: string;
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
}> {
|
|
47
|
+
tag: 'image';
|
|
48
|
+
}
|
|
49
|
+
export interface SvgMarkedContent extends SvgNode<{
|
|
50
|
+
href: string;
|
|
51
|
+
type: string;
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
}> {
|
|
57
|
+
tag: 'use';
|
|
58
|
+
}
|
|
59
|
+
export interface SvgRoot extends SvgElement<{
|
|
60
|
+
id?: string;
|
|
61
|
+
width: number;
|
|
62
|
+
height: number;
|
|
63
|
+
}> {
|
|
64
|
+
tag: 'svg';
|
|
65
|
+
}
|
|
66
|
+
export declare function isSvgElement(node: SvgNode): node is SvgElement;
|
|
67
|
+
export declare function isSvgPath(node: SvgNode): node is SvgPath;
|
|
68
|
+
export declare function isSvgImage(node: SvgNode): node is SvgImage;
|
|
69
|
+
export declare function isSvgMarkedContent(node: SvgNode): node is SvgMarkedContent;
|
|
70
|
+
export declare function isSvgRoot(node: SvgNode): node is SvgRoot;
|
|
71
|
+
export declare enum PrefixType {
|
|
72
|
+
Root = "svg",
|
|
73
|
+
Clip = "clip",
|
|
74
|
+
Pattern = "pattern",
|
|
75
|
+
MarkedContent = "marked_content"
|
|
76
|
+
}
|
|
77
|
+
export declare function id(type: PrefixType, id?: string | null, scope?: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* Traverse the SVG tree to find a node matching the given criteria.
|
|
80
|
+
* @param root The root element to start the search from.
|
|
81
|
+
* @param matcher A function that returns true for the desired node.
|
|
82
|
+
* @returns The first matching node, or null if none is found.
|
|
83
|
+
*/
|
|
84
|
+
export declare function findSvgNode(root: SvgElement, matcher: (node: SvgNode) => boolean): SvgNode | null;
|
|
85
|
+
/**
|
|
86
|
+
* Parse a transform string into a transformation matrix.
|
|
87
|
+
* @param input The transform string.
|
|
88
|
+
* @returns A transformation matrix.
|
|
89
|
+
*/
|
|
90
|
+
export declare function parseTransform(input: string): DOMMatrix;
|
|
91
|
+
export declare function matrixToTransform(matrix: DOMMatrix): string;
|
|
92
|
+
/**
|
|
93
|
+
* Parse a font string into its components.
|
|
94
|
+
* @param fontString The font string.
|
|
95
|
+
* @returns An object containing the font components.
|
|
96
|
+
*/
|
|
97
|
+
export declare function parseFontStyle(fontString: string): {
|
|
98
|
+
fontStyle: string;
|
|
99
|
+
fontVariant: string;
|
|
100
|
+
fontWeight: string;
|
|
101
|
+
fontSize: string;
|
|
102
|
+
lineHeight: string;
|
|
103
|
+
fontFamilies: string[];
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Convert textAlign to text-anchor.
|
|
107
|
+
* @param textAlign The textAlign value.
|
|
108
|
+
* @returns The corresponding text-anchor value.
|
|
109
|
+
*/
|
|
110
|
+
export declare function getTextAnchor(textAlign: string): 'start' | 'end' | 'middle';
|
|
111
|
+
/**
|
|
112
|
+
* Convert textBaseline to dominant-baseline.
|
|
113
|
+
* @param textBaseline The textBaseline value.
|
|
114
|
+
* @returns The corresponding dominant-baseline value.
|
|
115
|
+
*/
|
|
116
|
+
export declare function getDominantBaseline(textBaseline: string): 'alphabetic' | 'hanging' | 'text-before-edge' | 'text-after-edge' | 'central';
|
|
117
|
+
/**
|
|
118
|
+
* Normalize a vector.
|
|
119
|
+
* @param vector The input vector.
|
|
120
|
+
* @returns The normalized vector.
|
|
121
|
+
*/
|
|
122
|
+
export declare function normalizeVector(vector: [number, number]): [number, number];
|
|
123
|
+
/**
|
|
124
|
+
* Get the angle of a vector in radians.
|
|
125
|
+
* @param vector The input vector.
|
|
126
|
+
* @returns The angle in radians.
|
|
127
|
+
*/
|
|
128
|
+
export declare function getAngle(vector: [number, number]): number;
|
|
129
|
+
/**
|
|
130
|
+
* Get the bounding box of a SVG node.
|
|
131
|
+
* @param node The SVG node.
|
|
132
|
+
* @param defs The SVG definitions (for resolving references).
|
|
133
|
+
* @param inheritedMatrix The inherited transformation matrix.
|
|
134
|
+
* @returns The bounding box of the SVG node.
|
|
135
|
+
*/
|
|
136
|
+
export declare function getBBox(node: SvgNode, defs?: SvgNode[], inheritedMatrix?: DOMMatrix): BoundingBox | null;
|
|
137
|
+
/**
|
|
138
|
+
* Make a HTML string from a Svg node.
|
|
139
|
+
* @param node The node to render.
|
|
140
|
+
* @param attrs The attributes to add to the node.
|
|
141
|
+
* @returns A HTML string representation of the node.
|
|
142
|
+
*/
|
|
143
|
+
export declare function renderSvgNode(node: SvgNode | string): string;
|
|
144
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Path2D } from './Path2D';
|
|
2
|
+
import { type SvgElement, type SvgNode, type SvgRoot } from './Svg';
|
|
2
3
|
interface CanvasStyle {
|
|
3
|
-
strokeStyle: string |
|
|
4
|
-
fillStyle: string |
|
|
4
|
+
strokeStyle: string | SvgLinearGradient | SvgPattern;
|
|
5
|
+
fillStyle: string | SvgLinearGradient | SvgRadialGradient | SvgPattern;
|
|
5
6
|
fillRule: CanvasFillRule;
|
|
6
7
|
filter: string;
|
|
7
8
|
lineCap: CanvasLineCap;
|
|
@@ -28,7 +29,7 @@ declare class SvgPattern {
|
|
|
28
29
|
constructor(src: string, width: number, height: number);
|
|
29
30
|
setTransform(matrix: DOMMatrix): void;
|
|
30
31
|
}
|
|
31
|
-
declare class
|
|
32
|
+
declare class SvgLinearGradient {
|
|
32
33
|
readonly x1: number;
|
|
33
34
|
readonly y1: number;
|
|
34
35
|
readonly x2: number;
|
|
@@ -40,22 +41,20 @@ declare class SvgGradient {
|
|
|
40
41
|
constructor(x1: number, y1: number, x2: number, y2: number);
|
|
41
42
|
addColorStop(offset: number, color: string): void;
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
declare class SvgRadialGradient {
|
|
45
|
+
readonly x0: number;
|
|
46
|
+
readonly y0: number;
|
|
47
|
+
readonly r0: number;
|
|
48
|
+
readonly x1: number;
|
|
49
|
+
readonly y1: number;
|
|
50
|
+
readonly r1: number;
|
|
51
|
+
readonly stops: {
|
|
52
|
+
offset: number;
|
|
53
|
+
color: string;
|
|
54
|
+
}[];
|
|
55
|
+
constructor(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number);
|
|
56
|
+
addColorStop(offset: number, color: string): void;
|
|
56
57
|
}
|
|
57
|
-
export declare function isSvgElement(node: SvgNode): node is SvgElement;
|
|
58
|
-
export declare function isSvgText(node: SvgNode): node is SvgText;
|
|
59
58
|
export declare class SvgCanvasContext {
|
|
60
59
|
private _width;
|
|
61
60
|
private _height;
|
|
@@ -64,13 +63,17 @@ export declare class SvgCanvasContext {
|
|
|
64
63
|
private _currentStyle;
|
|
65
64
|
private _styleStack;
|
|
66
65
|
private _groupStack;
|
|
66
|
+
private _markedStack;
|
|
67
67
|
private _transformMatrixStack;
|
|
68
68
|
private _root;
|
|
69
69
|
private _defs;
|
|
70
70
|
private _currentGroup;
|
|
71
71
|
private _currentElement;
|
|
72
|
+
private _currentMarked;
|
|
73
|
+
private _textActive;
|
|
72
74
|
private _transformMatrix;
|
|
73
75
|
private _currentPosition;
|
|
76
|
+
private _parents;
|
|
74
77
|
get canvas(): HTMLCanvasElement;
|
|
75
78
|
get fillStyle(): string;
|
|
76
79
|
set fillStyle(value: string);
|
|
@@ -103,6 +106,7 @@ export declare class SvgCanvasContext {
|
|
|
103
106
|
resize(width: number, height: number): void;
|
|
104
107
|
save(): void;
|
|
105
108
|
restore(): void;
|
|
109
|
+
clearRect(x: number, y: number, width: number, height: number): void;
|
|
106
110
|
beginPath(): void;
|
|
107
111
|
closePath(): void;
|
|
108
112
|
moveTo(x: number, y: number): void;
|
|
@@ -113,7 +117,7 @@ export declare class SvgCanvasContext {
|
|
|
113
117
|
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
|
|
114
118
|
rect(x: number, y: number, width: number, height: number): void;
|
|
115
119
|
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise: boolean): void;
|
|
116
|
-
stroke(): void;
|
|
120
|
+
stroke(path?: Path2D): void;
|
|
117
121
|
transform(...values: number[]): void;
|
|
118
122
|
translate(x: number, y: number): void;
|
|
119
123
|
scale(x: number, y: number): void;
|
|
@@ -124,14 +128,21 @@ export declare class SvgCanvasContext {
|
|
|
124
128
|
setLineDash(dashArray: number[]): void;
|
|
125
129
|
drawImage(image: CanvasImageSource, ...args: number[]): void;
|
|
126
130
|
createPattern(image: CanvasImageSource, repetition: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat' | null): SvgPattern;
|
|
127
|
-
createLinearGradient(x1: number, x2: number, y1: number, y2: number):
|
|
131
|
+
createLinearGradient(x1: number, x2: number, y1: number, y2: number): SvgLinearGradient;
|
|
132
|
+
createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): SvgRadialGradient;
|
|
128
133
|
clip(path: Path2D, fillRule: CanvasFillRule): void;
|
|
129
134
|
measureText(text: string): TextMetrics;
|
|
130
135
|
resetTransform(): void;
|
|
131
136
|
getTransform(): DOMMatrix;
|
|
132
137
|
setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
133
|
-
|
|
138
|
+
beginText(): void;
|
|
139
|
+
endText(): void;
|
|
140
|
+
beginMarkedContent(type: string, props?: number | {
|
|
141
|
+
id: number;
|
|
142
|
+
} | null): void;
|
|
143
|
+
endMarkedContent(): void;
|
|
134
144
|
protected _ensureTransformationGroup(): SvgElement;
|
|
145
|
+
protected _addNode(node: SvgNode, parent?: SvgElement): void;
|
|
135
146
|
protected _applyStyleState(styleState: CanvasStyle): void;
|
|
136
147
|
protected _getStyleState(): CanvasStyle;
|
|
137
148
|
protected _getTransformScale(): {
|
|
@@ -145,12 +156,15 @@ export declare class SvgCanvasContext {
|
|
|
145
156
|
};
|
|
146
157
|
protected _applyTransformation(node: SvgNode, matrix?: DOMMatrix): void;
|
|
147
158
|
protected _createPatternNode(pattern: SvgPattern, transform?: DOMMatrix): SvgElement;
|
|
148
|
-
protected _createGradientNode(gradient:
|
|
159
|
+
protected _createGradientNode(gradient: SvgLinearGradient | SvgRadialGradient): SvgElement;
|
|
149
160
|
protected _applyStyle(currentElement: SvgNode, type: 'fill' | 'stroke'): void;
|
|
150
161
|
protected _addPathCommand(command: string): void;
|
|
151
162
|
protected _applyText(text: string, x: number, y: number, action: 'fill'): void;
|
|
152
163
|
protected _clearCanvas(): void;
|
|
164
|
+
destroy(): void;
|
|
153
165
|
}
|
|
154
166
|
export declare function createSvgContext(width: number, height: number): Promise<CanvasRenderingContext2D>;
|
|
155
167
|
export declare function toSvgNode(ctx: CanvasRenderingContext2D): Promise<SvgRoot>;
|
|
168
|
+
export declare function toSvgString(ctx: CanvasRenderingContext2D): Promise<string>;
|
|
169
|
+
export declare function destroySvgContext(ctx: CanvasRenderingContext2D): void;
|
|
156
170
|
export {};
|
package/dist/lib/TextLayer.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { PDFPageProxy } from '../pdf.js/src/display/api';
|
|
1
|
+
import type { PDFPageProxy, StructTreeContent } from '../pdf.js/src/display/api';
|
|
2
2
|
import type { BaseCanvasFactory } from '../pdf.js/src/display/canvas_factory';
|
|
3
3
|
import type { PageViewport } from '../pdf.js/src/display/display_utils';
|
|
4
4
|
import { type AnnotationData } from './AnnotationData';
|
|
5
|
+
import type { StructTreeNodeWithAttrs } from './StructTreePage';
|
|
6
|
+
import { type SvgRoot } from './Svg';
|
|
5
7
|
export interface TextLayerNode {
|
|
6
8
|
id?: string;
|
|
7
9
|
role: string;
|
|
10
|
+
attrs?: Record<string, unknown>;
|
|
8
11
|
}
|
|
9
12
|
export interface TextLayerElement extends TextLayerNode {
|
|
10
13
|
children: (string | TextLayerNode)[];
|
|
@@ -19,27 +22,62 @@ export interface TextLayerAnchor extends TextLayerElement {
|
|
|
19
22
|
}
|
|
20
23
|
export interface TextLayerText extends TextLayerNode {
|
|
21
24
|
role: 'text';
|
|
22
|
-
text: string
|
|
23
|
-
|
|
25
|
+
text: string | {
|
|
26
|
+
text: string;
|
|
27
|
+
top: number;
|
|
28
|
+
left: number;
|
|
29
|
+
scale?: number;
|
|
30
|
+
}[];
|
|
24
31
|
top: number;
|
|
25
32
|
left: number;
|
|
26
33
|
fontSize: number;
|
|
34
|
+
fontWeight: number;
|
|
35
|
+
fontStyle: string;
|
|
27
36
|
fontFamily: string;
|
|
28
37
|
fontFallback: string;
|
|
29
38
|
dir: string;
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
hyphen?: boolean;
|
|
40
|
+
scale?: number;
|
|
41
|
+
angle?: number;
|
|
32
42
|
}
|
|
33
|
-
export interface
|
|
34
|
-
role: '
|
|
35
|
-
|
|
43
|
+
export interface TextLayerFigure extends TextLayerNode {
|
|
44
|
+
role: 'figure';
|
|
45
|
+
href: string;
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
alt?: string;
|
|
36
51
|
}
|
|
37
52
|
export declare function isTextNode(node: TextLayerNode): node is TextLayerText;
|
|
38
53
|
export declare function isAnchorNode(node: TextLayerNode): node is TextLayerAnchor;
|
|
39
|
-
export declare function
|
|
40
|
-
export declare function
|
|
54
|
+
export declare function isFigureNode(node: TextLayerNode): node is TextLayerFigure;
|
|
55
|
+
export declare function isElementNode(node: TextLayerNode): node is TextLayerElement;
|
|
56
|
+
export declare const TEXT_LAYER_FONT_FAMILY = "Liberation Sans";
|
|
57
|
+
export interface Glyph {
|
|
58
|
+
unicode: string;
|
|
59
|
+
isSpace: boolean;
|
|
60
|
+
}
|
|
61
|
+
export declare const fontLoader: (bold?: boolean, italic?: boolean) => Promise<Uint8Array<ArrayBuffer>>;
|
|
62
|
+
export declare function loadTextLayerFonts(document?: Document): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated Use `loadTextLayerFonts` instead.
|
|
65
|
+
*/
|
|
66
|
+
export declare const loadDefaultFonts: typeof loadTextLayerFonts;
|
|
67
|
+
export declare const normalizeMarkedContentId: (idRef: unknown) => string | null;
|
|
68
|
+
export declare const getNodeContents: (node: TextLayerNode) => string;
|
|
69
|
+
export declare const findNode: (root: TextLayerElement, callback: (node: TextLayerNode, parent: TextLayerElement) => boolean | null | undefined) => TextLayerNode | null;
|
|
70
|
+
export declare const findNodes: (node: TextLayerElement, callback: (node: TextLayerNode, parent: TextLayerElement) => boolean | null | undefined) => TextLayerNode[];
|
|
71
|
+
export declare const flattenNodes: (node: TextLayerNode | string) => TextLayerNode[];
|
|
72
|
+
export declare const renderTextLayer: (root: TextLayerRoot, options?: {
|
|
73
|
+
classes?: boolean;
|
|
74
|
+
styles?: boolean;
|
|
75
|
+
}) => string;
|
|
76
|
+
export declare const decorateStructTree: (node: StructTreeNodeWithAttrs | StructTreeContent, rootContainer: TextLayerRoot, graphics?: SvgRoot, annotations?: AnnotationData[], parents?: TextLayerElement[]) => void;
|
|
77
|
+
export declare function createTextLayer(page: PDFPageProxy, { canvasFactory, viewport, outputScale, annotations, graphics, }: {
|
|
41
78
|
canvasFactory: BaseCanvasFactory;
|
|
42
79
|
viewport?: PageViewport;
|
|
43
80
|
outputScale?: number;
|
|
44
81
|
annotations?: AnnotationData[];
|
|
82
|
+
graphics?: SvgRoot;
|
|
45
83
|
}): Promise<TextLayerRoot>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PDFPageProxy } from '../pdf.js/src/display/api';
|
|
2
|
+
import type { AnnotationData } from './AnnotationData';
|
|
3
|
+
import type { SvgRoot } from './Svg';
|
|
4
|
+
import { type TextLayerRoot } from './TextLayer';
|
|
5
|
+
export declare function createTextLayerV2(page: PDFPageProxy, { graphics, annotations: _annotations, }?: {
|
|
6
|
+
graphics?: SvgRoot;
|
|
7
|
+
annotations?: AnnotationData[];
|
|
8
|
+
}): Promise<TextLayerRoot>;
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,13 +1,39 @@
|
|
|
1
|
-
import type { Canvas } from '
|
|
1
|
+
import type { Canvas } from 'skia-canvas';
|
|
2
|
+
export type CanvasAndContext = {
|
|
3
|
+
canvas: HTMLCanvasElement;
|
|
4
|
+
context: CanvasRenderingContext2D;
|
|
5
|
+
};
|
|
2
6
|
/**
|
|
3
7
|
* Convert a canvas to a buffer.
|
|
4
8
|
* @param canvas The canvas to convert.
|
|
5
9
|
* @returns A promise that resolves to the buffer.
|
|
6
10
|
*/
|
|
7
|
-
export declare function canvasToData(canvas: HTMLCanvasElement | Canvas): Promise<Uint8Array
|
|
11
|
+
export declare function canvasToData(canvas: HTMLCanvasElement | Canvas): Promise<Uint8Array<ArrayBuffer>>;
|
|
8
12
|
/**
|
|
9
13
|
* Convert a buffer to a data url.
|
|
10
14
|
* @param data The buffer to convert.
|
|
15
|
+
* @param type The type of the data url. Defaults to 'image/png'.
|
|
11
16
|
* @returns A promise that resolves to the data url.
|
|
12
17
|
*/
|
|
13
|
-
export declare function toDataUrl(data: Uint8Array): Promise<string>;
|
|
18
|
+
export declare function toDataUrl(data: Uint8Array<ArrayBuffer>, type?: string): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Ensure the object can be serialized and unserialized as JSON.
|
|
21
|
+
* Internally it converts typed arrays to plain arrays.
|
|
22
|
+
* @param object The object to serialize.
|
|
23
|
+
* @returns The serialized object.
|
|
24
|
+
*/
|
|
25
|
+
export declare function makeSerializable<T>(object: T): T;
|
|
26
|
+
/**
|
|
27
|
+
* Convert hash color to RGB array.
|
|
28
|
+
* @param color The color in hex format (e.g., '#ff0000' or '#f00').
|
|
29
|
+
* @returns An array of RGB values [r, g, b].
|
|
30
|
+
*/
|
|
31
|
+
export declare function colorToRgb(color: string): [number, number, number];
|
|
32
|
+
export declare function rgbToHex(rgb: [number, number, number]): string;
|
|
33
|
+
export declare function rgbToHex(r: number, g: number, b: number): string;
|
|
34
|
+
export declare function parseRgbaColor(color: string): {
|
|
35
|
+
r: number;
|
|
36
|
+
g: number;
|
|
37
|
+
b: number;
|
|
38
|
+
a: number;
|
|
39
|
+
};
|