unpdf 1.7.0 → 1.8.1
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 +3 -3
- package/dist/index.cjs +382 -384
- package/dist/index.d.cts +98 -95
- package/dist/index.d.mts +98 -95
- package/dist/index.mjs +381 -382
- package/dist/pdfjs.mjs +52 -59
- package/dist/types/external/brotli/decode.d.ts +5 -0
- package/dist/types/external/jbig2/jbig2.d.ts +2 -0
- package/dist/types/external/openjpeg/openjpeg.d.ts +2 -0
- package/dist/types/external/qcms/qcms.d.ts +92 -0
- package/dist/types/external/qcms/qcms_utils.d.ts +14 -0
- package/dist/types/src/core/ascii_85_stream.d.ts +7 -0
- package/dist/types/src/core/ascii_hex_stream.d.ts +7 -0
- package/dist/types/src/core/base_stream.d.ts +45 -0
- package/dist/types/src/core/brotli_stream.d.ts +9 -0
- package/dist/types/src/core/calculate_md5.d.ts +1 -0
- package/dist/types/src/core/calculate_sha256.d.ts +1 -0
- package/dist/types/src/core/calculate_sha_other.d.ts +2 -0
- package/dist/types/src/core/catalog.d.ts +169 -0
- package/dist/types/src/core/ccitt_stream.d.ts +18 -0
- package/dist/types/src/core/cleanup_helper.d.ts +1 -0
- package/dist/types/src/core/colorspace.d.ts +177 -0
- package/dist/types/src/core/colorspace_utils.d.ts +21 -0
- package/dist/types/src/core/core_utils.d.ts +132 -0
- package/dist/types/src/core/crypto.d.ts +136 -0
- package/dist/types/src/core/decode_stream.d.ts +32 -0
- package/dist/types/src/core/decrypt_stream.d.ts +9 -0
- package/dist/types/src/core/file_spec.d.ts +72 -0
- package/dist/types/src/core/flate_stream.d.ts +14 -0
- package/dist/types/src/core/icc_colorspace.d.ts +22 -0
- package/dist/types/src/core/image_utils.d.ts +52 -0
- package/dist/types/src/core/jbig2_ccittFax.d.ts +13 -0
- package/dist/types/src/core/jbig2_stream.d.ts +17 -0
- package/dist/types/src/core/jpeg_stream.d.ts +24 -0
- package/dist/types/src/core/jpg.d.ts +62 -0
- package/dist/types/src/core/jpx.d.ts +24 -0
- package/dist/types/src/core/jpx_stream.d.ts +15 -0
- package/dist/types/src/core/lzw_stream.d.ts +19 -0
- package/dist/types/src/core/metadata_parser.d.ts +13 -0
- package/dist/types/src/core/name_number_tree.d.ts +21 -0
- package/dist/types/src/core/parser.d.ts +121 -0
- package/dist/types/src/core/pattern.d.ts +63 -0
- package/dist/types/src/core/predictor_stream.d.ts +14 -0
- package/dist/types/src/core/primitives.d.ts +81 -0
- package/dist/types/src/core/run_length_stream.d.ts +6 -0
- package/dist/types/src/core/stream.d.ts +20 -0
- package/dist/types/src/core/string_utils.d.ts +5 -0
- package/dist/types/src/core/struct_tree.d.ts +93 -0
- package/dist/types/src/core/unicode.d.ts +5 -0
- package/dist/types/src/core/wasm_image.d.ts +21 -0
- package/dist/types/src/core/xml_parser.d.ts +79 -0
- package/dist/types/src/core/xref.d.ts +52 -0
- package/dist/types/src/display/annotation_layer.d.ts +10 -8
- package/dist/types/src/display/api.d.ts +92 -65
- package/dist/types/src/display/binary_data_factory.d.ts +0 -4
- package/dist/types/src/display/canvas.d.ts +58 -12
- package/dist/types/src/display/canvas_dependency_tracker.d.ts +2 -2
- package/dist/types/src/display/display_utils.d.ts +4 -156
- package/dist/types/src/display/draw_layer.d.ts +127 -2
- package/dist/types/src/display/editor/alt_text.d.ts +1 -1
- package/dist/types/src/display/editor/annotation_editor_layer.d.ts +3 -3
- package/dist/types/src/display/editor/color_picker.d.ts +3 -2
- package/dist/types/src/display/editor/draw.d.ts +10 -3
- package/dist/types/src/display/editor/drawers/freedraw.d.ts +3 -3
- package/dist/types/src/display/editor/drawers/highlight.d.ts +0 -1
- package/dist/types/src/display/editor/drawers/outline.d.ts +0 -1
- package/dist/types/src/display/editor/drawers/signaturedraw.d.ts +13 -13
- package/dist/types/src/display/editor/editor.d.ts +2 -1
- package/dist/types/src/display/editor/freetext.d.ts +2 -2
- package/dist/types/src/display/editor/highlight.d.ts +3 -3
- package/dist/types/src/display/editor/ink.d.ts +2 -0
- package/dist/types/src/display/editor/toolbar.d.ts +2 -2
- package/dist/types/src/display/editor/tools.d.ts +31 -14
- package/dist/types/src/display/filter_factory.d.ts +26 -0
- package/dist/types/src/display/node_utils.d.ts +2 -2
- package/dist/types/src/display/obj_bin_transform_display.d.ts +2 -6
- package/dist/types/src/display/optional_content_config.d.ts +13 -3
- package/dist/types/src/display/page_viewport.d.ts +137 -0
- package/dist/types/src/display/pattern_helper.d.ts +11 -4
- package/dist/types/src/display/text_layer.d.ts +10 -10
- package/dist/types/src/display/text_layer_images.d.ts +1 -1
- package/dist/types/src/display/webgpu.d.ts +11 -0
- package/dist/types/src/display/worker_options.d.ts +2 -2
- package/dist/types/src/display/xfa_layer.d.ts +8 -1
- package/dist/types/src/pdf.d.ts +5 -4
- package/dist/types/src/shared/image_utils.d.ts +11 -0
- package/dist/types/src/shared/internal_evt.d.ts +7 -0
- package/dist/types/src/shared/math_clamp.d.ts +1 -0
- package/dist/types/src/shared/util.d.ts +24 -13
- package/dist/types/web/annotation_editor_layer_builder.d.ts +1 -1
- package/dist/types/web/annotation_layer_builder.d.ts +6 -3
- package/dist/types/web/app_options.d.ts +1 -1
- package/dist/types/web/autolinker.d.ts +3 -3
- package/dist/types/web/base_pdf_page_view.d.ts +1 -0
- package/dist/types/web/comment_manager.d.ts +1 -1
- package/dist/types/web/draw_layer_builder.d.ts +44 -0
- package/dist/types/web/event_utils.d.ts +0 -8
- package/dist/types/web/generic_scripting.d.ts +1 -1
- package/dist/types/web/genericl10n.d.ts +5 -5
- package/dist/types/web/internal_evt.d.ts +7 -0
- package/dist/types/web/l10n.d.ts +2 -2
- package/dist/types/web/pdf_find_controller.d.ts +12 -1
- package/dist/types/web/pdf_link_service.d.ts +8 -0
- package/dist/types/web/pdf_page_view.d.ts +10 -3
- package/dist/types/web/pdf_thumbnail_view.d.ts +5 -5
- package/dist/types/web/pdf_thumbnail_viewer.d.ts +31 -12
- package/dist/types/web/pdf_viewer.d.ts +15 -1
- package/dist/types/web/text_accessibility.d.ts +1 -1
- package/dist/types/web/text_layer_builder.d.ts +5 -5
- package/dist/types/web/xfa_layer_builder.d.ts +3 -3
- package/package.json +23 -23
- package/dist/index.d.ts +0 -189
- package/dist/types/src/display/webgpu_mesh.d.ts +0 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Canvas, SKRSContext2D } from
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import * as PDFJS from './types/src/pdf.js';
|
|
6
|
-
|
|
1
|
+
import { DocumentInitParameters, PDFDocumentProxy } from "./types/src/display/api.js";
|
|
2
|
+
import { Canvas, SKRSContext2D } from "@napi-rs/canvas";
|
|
3
|
+
import * as PDFJS from "./types/src/pdf.js";
|
|
4
|
+
//#region src/_internal/canvas.d.ts
|
|
7
5
|
interface CanvasFactoryContext {
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
canvas?: HTMLCanvasElement | Canvas;
|
|
7
|
+
context?: CanvasRenderingContext2D | SKRSContext2D | null;
|
|
10
8
|
}
|
|
11
9
|
/**
|
|
12
10
|
* Derived from the PDF.js project by the Mozilla Foundation.
|
|
@@ -14,17 +12,17 @@ interface CanvasFactoryContext {
|
|
|
14
12
|
* @license Apache-2.0
|
|
15
13
|
*/
|
|
16
14
|
declare class BaseCanvasFactory {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
#private;
|
|
16
|
+
constructor({ enableHWA }?: {
|
|
17
|
+
enableHWA?: boolean | undefined;
|
|
18
|
+
});
|
|
19
|
+
create(width: number, height: number): {
|
|
20
|
+
canvas: Canvas | HTMLCanvasElement;
|
|
21
|
+
context: SKRSContext2D | CanvasRenderingContext2D | null;
|
|
22
|
+
};
|
|
23
|
+
reset({ canvas }: CanvasFactoryContext, width: number, height: number): void;
|
|
24
|
+
destroy(context: CanvasFactoryContext): void;
|
|
25
|
+
_createCanvas(width: number, height: number): HTMLCanvasElement | Canvas;
|
|
28
26
|
}
|
|
29
27
|
/**
|
|
30
28
|
* Derived from the PDF.js project by the Mozilla Foundation.
|
|
@@ -32,26 +30,27 @@ declare class BaseCanvasFactory {
|
|
|
32
30
|
* @license Apache-2.0
|
|
33
31
|
*/
|
|
34
32
|
declare class DOMCanvasFactory extends BaseCanvasFactory {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
_document: Document;
|
|
34
|
+
constructor({ ownerDocument, enableHWA }?: {
|
|
35
|
+
ownerDocument?: Document | undefined;
|
|
36
|
+
enableHWA?: boolean | undefined;
|
|
37
|
+
});
|
|
38
|
+
_createCanvas(width: number, height: number): HTMLCanvasElement;
|
|
41
39
|
}
|
|
42
40
|
declare class NodeCanvasFactory extends BaseCanvasFactory {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
constructor({ enableHWA }?: {
|
|
42
|
+
enableHWA?: boolean | undefined;
|
|
43
|
+
});
|
|
44
|
+
_createCanvas(width: number, height: number): Canvas;
|
|
47
45
|
}
|
|
48
|
-
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/image.d.ts
|
|
49
48
|
interface ExtractedImageObject {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
data: Uint8ClampedArray;
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
channels: 1 | 3 | 4;
|
|
53
|
+
key: string;
|
|
55
54
|
}
|
|
56
55
|
/**
|
|
57
56
|
* Extracts images from a specific page of a PDF document, including necessary metadata,
|
|
@@ -71,78 +70,82 @@ interface ExtractedImageObject {
|
|
|
71
70
|
*/
|
|
72
71
|
declare function extractImages$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, pageNumber: number): Promise<ExtractedImageObject[]>;
|
|
73
72
|
declare function renderPageAsImage$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, pageNumber: number, options?: {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
canvasImport?: () => Promise<typeof import('@napi-rs/canvas')>;
|
|
74
|
+
/** @default 1.0 */
|
|
75
|
+
scale?: number;
|
|
76
|
+
width?: number;
|
|
77
|
+
height?: number;
|
|
78
|
+
toDataURL?: false;
|
|
80
79
|
}): Promise<ArrayBuffer>;
|
|
81
80
|
declare function renderPageAsImage$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, pageNumber: number, options: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
canvasImport?: () => Promise<typeof import('@napi-rs/canvas')>;
|
|
82
|
+
/** @default 1.0 */
|
|
83
|
+
scale?: number;
|
|
84
|
+
width?: number;
|
|
85
|
+
height?: number;
|
|
86
|
+
toDataURL: true;
|
|
88
87
|
}): Promise<string>;
|
|
89
|
-
declare function createIsomorphicCanvasFactory(canvasImport?: () => Promise<typeof
|
|
90
|
-
|
|
88
|
+
declare function createIsomorphicCanvasFactory(canvasImport?: () => Promise<typeof import('@napi-rs/canvas')>): Promise<typeof DOMCanvasFactory | typeof NodeCanvasFactory>;
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/links.d.ts
|
|
91
91
|
declare function extractLinks$1(data: DocumentInitParameters['data'] | PDFDocumentProxy): Promise<{
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
totalPages: number;
|
|
93
|
+
links: string[];
|
|
94
94
|
}>;
|
|
95
|
-
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/meta.d.ts
|
|
96
97
|
declare function getMeta$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, options?: {
|
|
97
|
-
|
|
98
|
+
parseDates?: boolean;
|
|
98
99
|
}): Promise<{
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
info: Record<string, any>;
|
|
101
|
+
metadata: import("./types/src/display/metadata.js").Metadata;
|
|
101
102
|
}>;
|
|
102
|
-
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/text.d.ts
|
|
103
105
|
interface StructuredTextItem {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
106
|
+
/** Text content. */
|
|
107
|
+
str: string;
|
|
108
|
+
/** X position in PDF coordinate space (origin: bottom-left). */
|
|
109
|
+
x: number;
|
|
110
|
+
/** Y position in PDF coordinate space (origin: bottom-left). */
|
|
111
|
+
y: number;
|
|
112
|
+
/** Width in device space. */
|
|
113
|
+
width: number;
|
|
114
|
+
/** Height in device space. */
|
|
115
|
+
height: number;
|
|
116
|
+
/** Font size derived from the transformation matrix. */
|
|
117
|
+
fontSize: number;
|
|
118
|
+
/** Font family resolved from the page's style table, empty when unknown. */
|
|
119
|
+
fontFamily: string;
|
|
120
|
+
/** Text direction: `"ltr"`, `"rtl"`, or `"ttb"`. */
|
|
121
|
+
dir: string;
|
|
122
|
+
/** Whether the text item is followed by a line break. */
|
|
123
|
+
hasEOL: boolean;
|
|
122
124
|
}
|
|
123
125
|
declare function extractTextItems$1(data: DocumentInitParameters['data'] | PDFDocumentProxy): Promise<{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
totalPages: number;
|
|
127
|
+
items: StructuredTextItem[][];
|
|
126
128
|
}>;
|
|
127
129
|
declare function extractText$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, options?: {
|
|
128
|
-
|
|
130
|
+
mergePages?: false;
|
|
129
131
|
}): Promise<{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
totalPages: number;
|
|
133
|
+
text: string[];
|
|
132
134
|
}>;
|
|
133
135
|
declare function extractText$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, options: {
|
|
134
|
-
|
|
136
|
+
mergePages: true;
|
|
135
137
|
}): Promise<{
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
totalPages: number;
|
|
139
|
+
text: string;
|
|
138
140
|
}>;
|
|
139
141
|
declare function extractText$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, options?: {
|
|
140
|
-
|
|
142
|
+
mergePages?: boolean;
|
|
141
143
|
}): Promise<{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
totalPages: number;
|
|
145
|
+
text: string | string[];
|
|
144
146
|
}>;
|
|
145
|
-
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/config.d.ts
|
|
146
149
|
/**
|
|
147
150
|
* By default, unpdf will use the latest version of PDF.js compiled for
|
|
148
151
|
* serverless environments. If you want to use a different version, you can
|
|
@@ -157,14 +160,14 @@ declare function extractText$1(data: DocumentInitParameters['data'] | PDFDocumen
|
|
|
157
160
|
declare function definePDFJSModule(pdfjs: () => Promise<any>): Promise<void>;
|
|
158
161
|
/** @deprecated Use `definePDFJSModule` instead. Will be removed in v2. */
|
|
159
162
|
declare function configureUnPDF(options: {
|
|
160
|
-
|
|
163
|
+
pdfjs?: () => Promise<any>;
|
|
161
164
|
}): Promise<void>;
|
|
162
|
-
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/utils.d.ts
|
|
163
167
|
/**
|
|
164
|
-
* Returns a PDFDocumentProxy instance from a given binary data.
|
|
168
|
+
* Returns a `PDFDocumentProxy` instance from a given binary data.
|
|
165
169
|
*
|
|
166
170
|
* Applies the following defaults:
|
|
167
|
-
* - `isEvalSupported: false`
|
|
168
171
|
* - `useSystemFonts: true`
|
|
169
172
|
*
|
|
170
173
|
* In Node.js environments, additionally applies:
|
|
@@ -175,15 +178,15 @@ declare function configureUnPDF(options: {
|
|
|
175
178
|
declare function getDocumentProxy(data: DocumentInitParameters['data'], options?: DocumentInitParameters): Promise<PDFDocumentProxy>;
|
|
176
179
|
declare function getResolvedPDFJS(): Promise<typeof PDFJS>;
|
|
177
180
|
declare function resolvePDFJSImport(pdfjsResolver?: () => Promise<any>, { reload }?: {
|
|
178
|
-
|
|
181
|
+
reload?: boolean | undefined;
|
|
179
182
|
}): Promise<void>;
|
|
180
|
-
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/index.d.ts
|
|
181
185
|
declare const getMeta: typeof getMeta$1;
|
|
182
186
|
declare const extractText: typeof extractText$1;
|
|
183
187
|
declare const extractTextItems: typeof extractTextItems$1;
|
|
184
188
|
declare const extractImages: typeof extractImages$1;
|
|
185
189
|
declare const renderPageAsImage: typeof renderPageAsImage$1;
|
|
186
190
|
declare const extractLinks: typeof extractLinks$1;
|
|
187
|
-
|
|
188
|
-
export { configureUnPDF, createIsomorphicCanvasFactory, definePDFJSModule, extractImages, extractLinks, extractText, extractTextItems, getDocumentProxy, getMeta, getResolvedPDFJS, renderPageAsImage, resolvePDFJSImport };
|
|
189
|
-
export type { StructuredTextItem };
|
|
191
|
+
//#endregion
|
|
192
|
+
export { type StructuredTextItem, configureUnPDF, createIsomorphicCanvasFactory, definePDFJSModule, extractImages, extractLinks, extractText, extractTextItems, getDocumentProxy, getMeta, getResolvedPDFJS, renderPageAsImage, resolvePDFJSImport };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Canvas, SKRSContext2D } from
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import * as PDFJS from './types/src/pdf.js';
|
|
6
|
-
|
|
1
|
+
import { DocumentInitParameters, PDFDocumentProxy } from "./types/src/display/api.js";
|
|
2
|
+
import { Canvas, SKRSContext2D } from "@napi-rs/canvas";
|
|
3
|
+
import * as PDFJS from "./types/src/pdf.js";
|
|
4
|
+
//#region src/_internal/canvas.d.ts
|
|
7
5
|
interface CanvasFactoryContext {
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
canvas?: HTMLCanvasElement | Canvas;
|
|
7
|
+
context?: CanvasRenderingContext2D | SKRSContext2D | null;
|
|
10
8
|
}
|
|
11
9
|
/**
|
|
12
10
|
* Derived from the PDF.js project by the Mozilla Foundation.
|
|
@@ -14,17 +12,17 @@ interface CanvasFactoryContext {
|
|
|
14
12
|
* @license Apache-2.0
|
|
15
13
|
*/
|
|
16
14
|
declare class BaseCanvasFactory {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
#private;
|
|
16
|
+
constructor({ enableHWA }?: {
|
|
17
|
+
enableHWA?: boolean | undefined;
|
|
18
|
+
});
|
|
19
|
+
create(width: number, height: number): {
|
|
20
|
+
canvas: Canvas | HTMLCanvasElement;
|
|
21
|
+
context: SKRSContext2D | CanvasRenderingContext2D | null;
|
|
22
|
+
};
|
|
23
|
+
reset({ canvas }: CanvasFactoryContext, width: number, height: number): void;
|
|
24
|
+
destroy(context: CanvasFactoryContext): void;
|
|
25
|
+
_createCanvas(width: number, height: number): HTMLCanvasElement | Canvas;
|
|
28
26
|
}
|
|
29
27
|
/**
|
|
30
28
|
* Derived from the PDF.js project by the Mozilla Foundation.
|
|
@@ -32,26 +30,27 @@ declare class BaseCanvasFactory {
|
|
|
32
30
|
* @license Apache-2.0
|
|
33
31
|
*/
|
|
34
32
|
declare class DOMCanvasFactory extends BaseCanvasFactory {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
_document: Document;
|
|
34
|
+
constructor({ ownerDocument, enableHWA }?: {
|
|
35
|
+
ownerDocument?: Document | undefined;
|
|
36
|
+
enableHWA?: boolean | undefined;
|
|
37
|
+
});
|
|
38
|
+
_createCanvas(width: number, height: number): HTMLCanvasElement;
|
|
41
39
|
}
|
|
42
40
|
declare class NodeCanvasFactory extends BaseCanvasFactory {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
constructor({ enableHWA }?: {
|
|
42
|
+
enableHWA?: boolean | undefined;
|
|
43
|
+
});
|
|
44
|
+
_createCanvas(width: number, height: number): Canvas;
|
|
47
45
|
}
|
|
48
|
-
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/image.d.ts
|
|
49
48
|
interface ExtractedImageObject {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
data: Uint8ClampedArray;
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
channels: 1 | 3 | 4;
|
|
53
|
+
key: string;
|
|
55
54
|
}
|
|
56
55
|
/**
|
|
57
56
|
* Extracts images from a specific page of a PDF document, including necessary metadata,
|
|
@@ -71,78 +70,82 @@ interface ExtractedImageObject {
|
|
|
71
70
|
*/
|
|
72
71
|
declare function extractImages$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, pageNumber: number): Promise<ExtractedImageObject[]>;
|
|
73
72
|
declare function renderPageAsImage$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, pageNumber: number, options?: {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
canvasImport?: () => Promise<typeof import('@napi-rs/canvas')>;
|
|
74
|
+
/** @default 1.0 */
|
|
75
|
+
scale?: number;
|
|
76
|
+
width?: number;
|
|
77
|
+
height?: number;
|
|
78
|
+
toDataURL?: false;
|
|
80
79
|
}): Promise<ArrayBuffer>;
|
|
81
80
|
declare function renderPageAsImage$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, pageNumber: number, options: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
canvasImport?: () => Promise<typeof import('@napi-rs/canvas')>;
|
|
82
|
+
/** @default 1.0 */
|
|
83
|
+
scale?: number;
|
|
84
|
+
width?: number;
|
|
85
|
+
height?: number;
|
|
86
|
+
toDataURL: true;
|
|
88
87
|
}): Promise<string>;
|
|
89
|
-
declare function createIsomorphicCanvasFactory(canvasImport?: () => Promise<typeof
|
|
90
|
-
|
|
88
|
+
declare function createIsomorphicCanvasFactory(canvasImport?: () => Promise<typeof import('@napi-rs/canvas')>): Promise<typeof DOMCanvasFactory | typeof NodeCanvasFactory>;
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/links.d.ts
|
|
91
91
|
declare function extractLinks$1(data: DocumentInitParameters['data'] | PDFDocumentProxy): Promise<{
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
totalPages: number;
|
|
93
|
+
links: string[];
|
|
94
94
|
}>;
|
|
95
|
-
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/meta.d.ts
|
|
96
97
|
declare function getMeta$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, options?: {
|
|
97
|
-
|
|
98
|
+
parseDates?: boolean;
|
|
98
99
|
}): Promise<{
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
info: Record<string, any>;
|
|
101
|
+
metadata: import("./types/src/display/metadata.js").Metadata;
|
|
101
102
|
}>;
|
|
102
|
-
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/text.d.ts
|
|
103
105
|
interface StructuredTextItem {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
106
|
+
/** Text content. */
|
|
107
|
+
str: string;
|
|
108
|
+
/** X position in PDF coordinate space (origin: bottom-left). */
|
|
109
|
+
x: number;
|
|
110
|
+
/** Y position in PDF coordinate space (origin: bottom-left). */
|
|
111
|
+
y: number;
|
|
112
|
+
/** Width in device space. */
|
|
113
|
+
width: number;
|
|
114
|
+
/** Height in device space. */
|
|
115
|
+
height: number;
|
|
116
|
+
/** Font size derived from the transformation matrix. */
|
|
117
|
+
fontSize: number;
|
|
118
|
+
/** Font family resolved from the page's style table, empty when unknown. */
|
|
119
|
+
fontFamily: string;
|
|
120
|
+
/** Text direction: `"ltr"`, `"rtl"`, or `"ttb"`. */
|
|
121
|
+
dir: string;
|
|
122
|
+
/** Whether the text item is followed by a line break. */
|
|
123
|
+
hasEOL: boolean;
|
|
122
124
|
}
|
|
123
125
|
declare function extractTextItems$1(data: DocumentInitParameters['data'] | PDFDocumentProxy): Promise<{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
totalPages: number;
|
|
127
|
+
items: StructuredTextItem[][];
|
|
126
128
|
}>;
|
|
127
129
|
declare function extractText$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, options?: {
|
|
128
|
-
|
|
130
|
+
mergePages?: false;
|
|
129
131
|
}): Promise<{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
totalPages: number;
|
|
133
|
+
text: string[];
|
|
132
134
|
}>;
|
|
133
135
|
declare function extractText$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, options: {
|
|
134
|
-
|
|
136
|
+
mergePages: true;
|
|
135
137
|
}): Promise<{
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
totalPages: number;
|
|
139
|
+
text: string;
|
|
138
140
|
}>;
|
|
139
141
|
declare function extractText$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, options?: {
|
|
140
|
-
|
|
142
|
+
mergePages?: boolean;
|
|
141
143
|
}): Promise<{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
totalPages: number;
|
|
145
|
+
text: string | string[];
|
|
144
146
|
}>;
|
|
145
|
-
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/config.d.ts
|
|
146
149
|
/**
|
|
147
150
|
* By default, unpdf will use the latest version of PDF.js compiled for
|
|
148
151
|
* serverless environments. If you want to use a different version, you can
|
|
@@ -157,14 +160,14 @@ declare function extractText$1(data: DocumentInitParameters['data'] | PDFDocumen
|
|
|
157
160
|
declare function definePDFJSModule(pdfjs: () => Promise<any>): Promise<void>;
|
|
158
161
|
/** @deprecated Use `definePDFJSModule` instead. Will be removed in v2. */
|
|
159
162
|
declare function configureUnPDF(options: {
|
|
160
|
-
|
|
163
|
+
pdfjs?: () => Promise<any>;
|
|
161
164
|
}): Promise<void>;
|
|
162
|
-
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/utils.d.ts
|
|
163
167
|
/**
|
|
164
|
-
* Returns a PDFDocumentProxy instance from a given binary data.
|
|
168
|
+
* Returns a `PDFDocumentProxy` instance from a given binary data.
|
|
165
169
|
*
|
|
166
170
|
* Applies the following defaults:
|
|
167
|
-
* - `isEvalSupported: false`
|
|
168
171
|
* - `useSystemFonts: true`
|
|
169
172
|
*
|
|
170
173
|
* In Node.js environments, additionally applies:
|
|
@@ -175,15 +178,15 @@ declare function configureUnPDF(options: {
|
|
|
175
178
|
declare function getDocumentProxy(data: DocumentInitParameters['data'], options?: DocumentInitParameters): Promise<PDFDocumentProxy>;
|
|
176
179
|
declare function getResolvedPDFJS(): Promise<typeof PDFJS>;
|
|
177
180
|
declare function resolvePDFJSImport(pdfjsResolver?: () => Promise<any>, { reload }?: {
|
|
178
|
-
|
|
181
|
+
reload?: boolean | undefined;
|
|
179
182
|
}): Promise<void>;
|
|
180
|
-
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/index.d.ts
|
|
181
185
|
declare const getMeta: typeof getMeta$1;
|
|
182
186
|
declare const extractText: typeof extractText$1;
|
|
183
187
|
declare const extractTextItems: typeof extractTextItems$1;
|
|
184
188
|
declare const extractImages: typeof extractImages$1;
|
|
185
189
|
declare const renderPageAsImage: typeof renderPageAsImage$1;
|
|
186
190
|
declare const extractLinks: typeof extractLinks$1;
|
|
187
|
-
|
|
188
|
-
export { configureUnPDF, createIsomorphicCanvasFactory, definePDFJSModule, extractImages, extractLinks, extractText, extractTextItems, getDocumentProxy, getMeta, getResolvedPDFJS, renderPageAsImage, resolvePDFJSImport };
|
|
189
|
-
export type { StructuredTextItem };
|
|
191
|
+
//#endregion
|
|
192
|
+
export { type StructuredTextItem, configureUnPDF, createIsomorphicCanvasFactory, definePDFJSModule, extractImages, extractLinks, extractText, extractTextItems, getDocumentProxy, getMeta, getResolvedPDFJS, renderPageAsImage, resolvePDFJSImport };
|