unpdf 1.7.0 → 1.8.0
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 +97 -94
- package/dist/index.d.mts +97 -94
- 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/types/web/l10n.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export const GenericL10n: null;
|
|
|
4
4
|
* internally.
|
|
5
5
|
*/
|
|
6
6
|
export class L10n {
|
|
7
|
-
static
|
|
8
|
-
static
|
|
7
|
+
static #fixupLangCode(langCode: any): any;
|
|
8
|
+
static #isRTL(lang: any): boolean;
|
|
9
9
|
constructor({ lang, isRTL }: {
|
|
10
10
|
lang: any;
|
|
11
11
|
isRTL: any;
|
|
@@ -10,6 +10,13 @@ export type PDFFindControllerOptions = {
|
|
|
10
10
|
* - The application event bus.
|
|
11
11
|
*/
|
|
12
12
|
eventBus: EventBus;
|
|
13
|
+
/**
|
|
14
|
+
* - The number of milliseconds to delay execution of
|
|
15
|
+
* find commands. In the viewer each keystroke in the find bar triggers a
|
|
16
|
+
* `find` event, so this delay avoids triggering a search prematurely when the
|
|
17
|
+
* user is still typing the query. The default value is 250.
|
|
18
|
+
*/
|
|
19
|
+
delay?: number | undefined;
|
|
13
20
|
/**
|
|
14
21
|
* - True if the matches
|
|
15
22
|
* count must be updated on progress or only when the last page is reached.
|
|
@@ -29,6 +36,10 @@ export function normalize(text: any, options?: {}): any[];
|
|
|
29
36
|
* @typedef {Object} PDFFindControllerOptions
|
|
30
37
|
* @property {PDFLinkService} linkService - The navigation/linking service.
|
|
31
38
|
* @property {EventBus} eventBus - The application event bus.
|
|
39
|
+
* @property {number} [delay] - The number of milliseconds to delay execution of
|
|
40
|
+
* find commands. In the viewer each keystroke in the find bar triggers a
|
|
41
|
+
* `find` event, so this delay avoids triggering a search prematurely when the
|
|
42
|
+
* user is still typing the query. The default value is 250.
|
|
32
43
|
* @property {boolean} [updateMatchesCountOnProgress] - True if the matches
|
|
33
44
|
* count must be updated on progress or only when the last page is reached.
|
|
34
45
|
* The default value is `true`.
|
|
@@ -40,7 +51,7 @@ export class PDFFindController {
|
|
|
40
51
|
/**
|
|
41
52
|
* @param {PDFFindControllerOptions} options
|
|
42
53
|
*/
|
|
43
|
-
constructor({ linkService, eventBus, updateMatchesCountOnProgress }: PDFFindControllerOptions);
|
|
54
|
+
constructor({ linkService, eventBus, delay, updateMatchesCountOnProgress, }: PDFFindControllerOptions);
|
|
44
55
|
_linkService: import("./pdf_link_service.js").PDFLinkService;
|
|
45
56
|
_eventBus: import("./event_utils.js").EventBus;
|
|
46
57
|
/**
|
|
@@ -106,6 +106,13 @@ export class PDFLinkService {
|
|
|
106
106
|
* @param {Object} [options]
|
|
107
107
|
*/
|
|
108
108
|
goToXY(pageNumber: number, x: number, y: number, options?: Object): void;
|
|
109
|
+
/**
|
|
110
|
+
* @param {string} id
|
|
111
|
+
* Unique attachment identifier (required).
|
|
112
|
+
* @returns {Promise<CatalogAttachmentContent>}
|
|
113
|
+
* Content.
|
|
114
|
+
*/
|
|
115
|
+
getAttachmentContent(id: string): Promise<CatalogAttachmentContent>;
|
|
109
116
|
/**
|
|
110
117
|
* Adds various attributes (href, title, target, rel) to hyperlinks.
|
|
111
118
|
* @param {HTMLAnchorElement} link
|
|
@@ -140,3 +147,4 @@ export class PDFLinkService {
|
|
|
140
147
|
}
|
|
141
148
|
export class SimpleLinkService extends PDFLinkService {
|
|
142
149
|
}
|
|
150
|
+
import type { CatalogAttachmentContent } from "../src/core/catalog.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type PageViewport = import("../src/display/
|
|
1
|
+
export type PageViewport = import("../src/display/page_viewport.js").PageViewport;
|
|
2
2
|
export type OptionalContentConfig = import("../src/display/optional_content_config.js").OptionalContentConfig;
|
|
3
3
|
export type EventBus = import("./event_utils.js").EventBus;
|
|
4
4
|
export type PDFRenderingQueue = import("./pdf_rendering_queue.js").PDFRenderingQueue;
|
|
@@ -86,6 +86,12 @@ export type PDFPageViewOptions = {
|
|
|
86
86
|
* dom to allow right-clicking and saving them. Use `-1` to disable this.
|
|
87
87
|
*/
|
|
88
88
|
imagesRightClickMinSize?: number | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* - When enabled, renders text
|
|
91
|
+
* selections in the draw layer.
|
|
92
|
+
* The default value is `true`.
|
|
93
|
+
*/
|
|
94
|
+
enableSelectionRendering?: boolean | undefined;
|
|
89
95
|
/**
|
|
90
96
|
* - When enabled, PDF
|
|
91
97
|
* rendering will keep track of which areas of the page each PDF operation
|
|
@@ -130,7 +136,7 @@ export class PDFPageView extends BasePDFPageView {
|
|
|
130
136
|
pageLabel: string | null;
|
|
131
137
|
rotation: number;
|
|
132
138
|
scale: number;
|
|
133
|
-
viewport: import("../src/display/
|
|
139
|
+
viewport: import("../src/display/page_viewport.js").PageViewport;
|
|
134
140
|
pdfPageRotate: number;
|
|
135
141
|
_optionalContentConfigPromise: Promise<import("../src/display/optional_content_config.js").OptionalContentConfig> | null;
|
|
136
142
|
imageResourcesPath: string;
|
|
@@ -157,6 +163,7 @@ export class PDFPageView extends BasePDFPageView {
|
|
|
157
163
|
deleteMe(isCut: any): void;
|
|
158
164
|
hasEditableAnnotations(): boolean;
|
|
159
165
|
get _textHighlighter(): any;
|
|
166
|
+
_refreshAnnotationLayer(): void;
|
|
160
167
|
reset({ keepAnnotationLayer, keepAnnotationEditorLayer, keepXfaLayer, keepTextLayer, keepCanvasWrapper, preserveDetailViewState, }?: {
|
|
161
168
|
keepAnnotationLayer?: boolean | undefined;
|
|
162
169
|
keepAnnotationEditorLayer?: boolean | undefined;
|
|
@@ -221,7 +228,7 @@ export class PDFPageView extends BasePDFPageView {
|
|
|
221
228
|
_getRenderingContext(canvas: any, transform: any, recordOperations: any, recordImages: any): {
|
|
222
229
|
canvas: any;
|
|
223
230
|
transform: any;
|
|
224
|
-
viewport: import("../src/display/
|
|
231
|
+
viewport: import("../src/display/page_viewport.js").PageViewport;
|
|
225
232
|
annotationMode: number;
|
|
226
233
|
optionalContentConfigPromise: Promise<import("../src/display/optional_content_config.js").OptionalContentConfig> | null;
|
|
227
234
|
annotationCanvasMap: any;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
export type OptionalContentConfig = import("../src/display/optional_content_config.js").OptionalContentConfig;
|
|
2
|
-
export type PageViewport = import("../src/display/display_utils.js").PageViewport;
|
|
3
|
-
export type EventBus = import("./event_utils.js").EventBus;
|
|
4
|
-
export type PDFRenderingQueue = import("./pdf_rendering_queue.js").PDFRenderingQueue;
|
|
5
1
|
export type PDFThumbnailViewOptions = {
|
|
6
2
|
/**
|
|
7
3
|
* - The viewer element.
|
|
@@ -52,6 +48,10 @@ export type PDFThumbnailViewOptions = {
|
|
|
52
48
|
*/
|
|
53
49
|
pageColors?: Object | undefined;
|
|
54
50
|
};
|
|
51
|
+
export type OptionalContentConfig = import("../src/display/optional_content_config.js").OptionalContentConfig;
|
|
52
|
+
export type PageViewport = import("../src/display/page_viewport.js").PageViewport;
|
|
53
|
+
export type EventBus = import("./event_utils.js").EventBus;
|
|
54
|
+
export type PDFRenderingQueue = import("./pdf_rendering_queue.js").PDFRenderingQueue;
|
|
55
55
|
export class PDFThumbnailView extends RenderableView {
|
|
56
56
|
/**
|
|
57
57
|
* @param {PDFThumbnailViewOptions} options
|
|
@@ -61,7 +61,7 @@ export class PDFThumbnailView extends RenderableView {
|
|
|
61
61
|
pageLabel: string | null;
|
|
62
62
|
pdfPage: any;
|
|
63
63
|
rotation: number;
|
|
64
|
-
viewport: import("../src/display/
|
|
64
|
+
viewport: import("../src/display/page_viewport.js").PageViewport;
|
|
65
65
|
pdfPageRotate: number;
|
|
66
66
|
_optionalContentConfigPromise: Promise<import("../src/display/optional_content_config.js").OptionalContentConfig> | null;
|
|
67
67
|
maxCanvasPixels: any;
|
|
@@ -49,6 +49,11 @@ export type PDFThumbnailViewerOptions = {
|
|
|
49
49
|
* and merge features.
|
|
50
50
|
*/
|
|
51
51
|
enableNewBadge?: boolean | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* - Enables the merge feature.
|
|
54
|
+
* The default value is `false`.
|
|
55
|
+
*/
|
|
56
|
+
enableMerge?: boolean | undefined;
|
|
52
57
|
/**
|
|
53
58
|
* - Enables split and merge features.
|
|
54
59
|
* The default value is `false`.
|
|
@@ -70,13 +75,15 @@ export type PDFThumbnailViewerOptions = {
|
|
|
70
75
|
*/
|
|
71
76
|
manageMenu?: Object | undefined;
|
|
72
77
|
/**
|
|
73
|
-
* - The
|
|
74
|
-
*
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
* - The waiting bar elements shown during
|
|
79
|
+
* long-running operations.
|
|
80
|
+
*/
|
|
81
|
+
waitingBar?: Object | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* - The file picker and button used to
|
|
84
|
+
* add one or more PDF files to merge with the current one.
|
|
78
85
|
*/
|
|
79
|
-
|
|
86
|
+
addFileComponent?: Object | undefined;
|
|
80
87
|
};
|
|
81
88
|
/**
|
|
82
89
|
* @typedef {Object} PDFThumbnailViewerOptions
|
|
@@ -98,6 +105,8 @@ export type PDFThumbnailViewerOptions = {
|
|
|
98
105
|
* events.
|
|
99
106
|
* @property {boolean} [enableNewBadge] - Enables the "new" badge for the split
|
|
100
107
|
* and merge features.
|
|
108
|
+
* @property {boolean} [enableMerge] - Enables the merge feature.
|
|
109
|
+
* The default value is `false`.
|
|
101
110
|
* @property {boolean} [enableSplitMerge] - Enables split and merge features.
|
|
102
111
|
* The default value is `false`.
|
|
103
112
|
* @property {Object} [statusBar] - The status bar elements to manage the status
|
|
@@ -106,19 +115,29 @@ export type PDFThumbnailViewerOptions = {
|
|
|
106
115
|
* action.
|
|
107
116
|
* @property {Object} [manageMenu] - The menu elements to manage saving edited
|
|
108
117
|
* PDF.
|
|
109
|
-
* @property {
|
|
110
|
-
*
|
|
111
|
-
|
|
118
|
+
* @property {Object} [waitingBar] - The waiting bar elements shown during
|
|
119
|
+
* long-running operations.
|
|
120
|
+
* @property {Object} [addFileComponent] - The file picker and button used to
|
|
121
|
+
* add one or more PDF files to merge with the current one.
|
|
122
|
+
*/
|
|
112
123
|
/**
|
|
113
124
|
* Viewer control to display thumbnails for pages in a PDF document.
|
|
114
125
|
*/
|
|
115
126
|
export class PDFThumbnailViewer {
|
|
116
|
-
static
|
|
117
|
-
static
|
|
127
|
+
static #draggingScaleFactor: number;
|
|
128
|
+
static #getScaleFactor(image: any): number;
|
|
129
|
+
static #fitImageDimensions(width: any, height: any, { minSide, maxSide }: {
|
|
130
|
+
minSide?: number | undefined;
|
|
131
|
+
maxSide: any;
|
|
132
|
+
}): {
|
|
133
|
+
width: any;
|
|
134
|
+
height: any;
|
|
135
|
+
};
|
|
136
|
+
static #fileToImageBitmap(file: any): Promise<ImageBitmap>;
|
|
118
137
|
/**
|
|
119
138
|
* @param {PDFThumbnailViewerOptions} options
|
|
120
139
|
*/
|
|
121
|
-
constructor({ container, eventBus, linkService, renderingQueue, maxCanvasPixels, maxCanvasDim, pageColors, abortSignal, enableSplitMerge, enableNewBadge, statusBar, undoBar, manageMenu,
|
|
140
|
+
constructor({ container, eventBus, linkService, renderingQueue, maxCanvasPixels, maxCanvasDim, pageColors, abortSignal, enableMerge, enableSplitMerge, enableNewBadge, statusBar, undoBar, waitingBar, manageMenu, addFileComponent, }: PDFThumbnailViewerOptions);
|
|
122
141
|
scrollableContainer: HTMLElement | null;
|
|
123
142
|
container: HTMLDivElement;
|
|
124
143
|
eventBus: import("./event_utils.js").EventBus;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type PDFDocumentProxy = import("../src/display/api.js").PDFDocumentProxy;
|
|
2
2
|
export type PDFPageProxy = import("../src/display/api.js").PDFPageProxy;
|
|
3
|
-
export type PageViewport = import("../src/display/
|
|
3
|
+
export type PageViewport = import("../src/display/page_viewport.js").PageViewport;
|
|
4
4
|
export type OptionalContentConfig = import("../src/display/optional_content_config.js").OptionalContentConfig;
|
|
5
5
|
export type EventBus = import("./event_utils.js").EventBus;
|
|
6
6
|
export type PDFFindController = import("./pdf_find_controller.js").PDFFindController;
|
|
@@ -110,6 +110,12 @@ export type PDFViewerOptions = {
|
|
|
110
110
|
* The default value is `true`.
|
|
111
111
|
*/
|
|
112
112
|
enableDetailCanvas?: boolean | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* - Enables rendering of text
|
|
115
|
+
* selections in the draw layer.
|
|
116
|
+
* The default value is `true`.
|
|
117
|
+
*/
|
|
118
|
+
enableSelectionRendering?: boolean | undefined;
|
|
113
119
|
/**
|
|
114
120
|
* - All images whose width and
|
|
115
121
|
* height are at least this value (in pixels) will be lazily inserted in the
|
|
@@ -205,6 +211,9 @@ export namespace PagesCountLimit {
|
|
|
205
211
|
* `maxCanvasDim`, it will draw a second canvas on top of the CSS-zoomed one,
|
|
206
212
|
* that only renders the part of the page that is close to the viewport.
|
|
207
213
|
* The default value is `true`.
|
|
214
|
+
* @property {boolean} [enableSelectionRendering] - Enables rendering of text
|
|
215
|
+
* selections in the draw layer.
|
|
216
|
+
* The default value is `true`.
|
|
208
217
|
* @property {number} [imagesRightClickMinSize] - All images whose width and
|
|
209
218
|
* height are at least this value (in pixels) will be lazily inserted in the
|
|
210
219
|
* dom to allow right-clicking and saving them. Use `-1` to disable this.
|
|
@@ -263,6 +272,7 @@ export class PDFViewer {
|
|
|
263
272
|
capCanvasAreaFactor: number | undefined;
|
|
264
273
|
enableDetailCanvas: boolean;
|
|
265
274
|
enableOptimizedPartialRendering: boolean;
|
|
275
|
+
enableSelectionRendering: boolean;
|
|
266
276
|
imagesRightClickMinSize: number;
|
|
267
277
|
l10n: import("./l10n.js").L10n | undefined;
|
|
268
278
|
pageColors: Object | null;
|
|
@@ -284,6 +294,10 @@ export class PDFViewer {
|
|
|
284
294
|
* @type {boolean} - True if all {PDFPageView} objects are initialized.
|
|
285
295
|
*/
|
|
286
296
|
get pageViewsReady(): boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Clear text selections within the viewer.
|
|
299
|
+
*/
|
|
300
|
+
clearSelection(): void;
|
|
287
301
|
/**
|
|
288
302
|
* @type {boolean}
|
|
289
303
|
*/
|
|
@@ -14,7 +14,7 @@ export class TextAccessibilityManager {
|
|
|
14
14
|
* @param {HTMLElement} e2
|
|
15
15
|
* @returns {number}
|
|
16
16
|
*/
|
|
17
|
-
static
|
|
17
|
+
static #compareElementPositions(e1: HTMLElement, e2: HTMLElement): number;
|
|
18
18
|
setTextMapping(textDivs: any): void;
|
|
19
19
|
/**
|
|
20
20
|
* Function called when the text layer has finished rendering.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type PDFPageProxy = import("../src/display/api.js").PDFPageProxy;
|
|
2
|
-
export type PageViewport = import("../src/display/
|
|
2
|
+
export type PageViewport = import("../src/display/page_viewport.js").PageViewport;
|
|
3
3
|
export type TextLayerImages = import("../src/display/text_layer_images.js").TextLayerImages;
|
|
4
4
|
export type TextHighlighter = import("./text_highlighter.js").TextHighlighter;
|
|
5
5
|
export type TextAccessibilityManager = import("./text_accessibility.js").TextAccessibilityManager;
|
|
@@ -42,10 +42,10 @@ export type TextLayerBuilderRenderOptions = {
|
|
|
42
42
|
* contain text that matches the PDF text they are overlaying.
|
|
43
43
|
*/
|
|
44
44
|
export class TextLayerBuilder {
|
|
45
|
-
static
|
|
46
|
-
static
|
|
47
|
-
static
|
|
48
|
-
static
|
|
45
|
+
static #textLayers: Map<any, any>;
|
|
46
|
+
static #selectionChangeAC: null;
|
|
47
|
+
static #removeGlobalSelectionListener(textLayerDiv: any): void;
|
|
48
|
+
static #enableGlobalSelectionListener(globalAbortSignal: any): void;
|
|
49
49
|
/**
|
|
50
50
|
* @param {TextLayerBuilderOptions} options
|
|
51
51
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type PDFPageProxy = import("../src/display/api.js").PDFPageProxy;
|
|
2
2
|
export type AnnotationStorage = import("../src/display/annotation_storage.js").AnnotationStorage;
|
|
3
|
-
export type PageViewport = import("../src/display/
|
|
3
|
+
export type PageViewport = import("../src/display/page_viewport.js").PageViewport;
|
|
4
4
|
export type PDFLinkService = import("./pdf_link_service.js").PDFLinkService;
|
|
5
5
|
export type XfaLayerBuilderOptions = {
|
|
6
6
|
pdfPage: PDFPageProxy;
|
|
@@ -32,12 +32,11 @@ export class XfaLayerBuilder {
|
|
|
32
32
|
* @param {XfaLayerBuilderOptions} options
|
|
33
33
|
*/
|
|
34
34
|
constructor({ pdfPage, annotationStorage, linkService, xfaHtml, }: XfaLayerBuilderOptions);
|
|
35
|
+
div: null;
|
|
35
36
|
pdfPage: import("../src/display/api.js").PDFPageProxy;
|
|
36
37
|
annotationStorage: import("../src/display/annotation_storage.js").AnnotationStorage;
|
|
37
38
|
linkService: import("./pdf_link_service.js").PDFLinkService;
|
|
38
39
|
xfaHtml: Object;
|
|
39
|
-
div: HTMLDivElement | null;
|
|
40
|
-
_cancelled: boolean;
|
|
41
40
|
/**
|
|
42
41
|
* @param {XfaLayerBuilderRenderOptions} viewport
|
|
43
42
|
* @returns {Promise<Object | void>} A promise that is resolved when rendering
|
|
@@ -47,4 +46,5 @@ export class XfaLayerBuilder {
|
|
|
47
46
|
render({ viewport, intent }: XfaLayerBuilderRenderOptions): Promise<Object | void>;
|
|
48
47
|
cancel(): void;
|
|
49
48
|
hide(): void;
|
|
49
|
+
#private;
|
|
50
50
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unpdf",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
5
|
-
"packageManager": "pnpm@
|
|
4
|
+
"version": "1.8.0",
|
|
5
|
+
"packageManager": "pnpm@11.17.0",
|
|
6
6
|
"description": "PDF extraction and rendering across all JavaScript runtimes",
|
|
7
7
|
"author": "Johann Schopplich <hello@johannschopplich.com>",
|
|
8
8
|
"license": "MIT",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"main": "./dist/index.cjs",
|
|
48
48
|
"module": "./dist/index.mjs",
|
|
49
|
-
"types": "./dist/index.d.
|
|
49
|
+
"types": "./dist/index.d.cts",
|
|
50
50
|
"typesVersions": {
|
|
51
51
|
"*": {
|
|
52
52
|
"*": [
|
|
@@ -58,19 +58,23 @@
|
|
|
58
58
|
"files": [
|
|
59
59
|
"dist"
|
|
60
60
|
],
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=22"
|
|
63
|
+
},
|
|
61
64
|
"scripts": {
|
|
62
|
-
"build": "
|
|
63
|
-
"build:pdfjs": "
|
|
64
|
-
"dev": "
|
|
65
|
+
"build": "tsdown && node scripts/post-build.mjs",
|
|
66
|
+
"build:pdfjs": "rolldown --config pdfjs.rolldown.config.ts && cp -R node_modules/pdfjs-dist/types dist",
|
|
67
|
+
"dev": "tsdown --watch",
|
|
65
68
|
"lint": "eslint .",
|
|
66
69
|
"lint:fix": "eslint . --fix",
|
|
67
70
|
"release": "bumpp",
|
|
68
71
|
"test": "vitest",
|
|
72
|
+
"test:attw": "attw --pack --ignore-rules cjs-resolves-to-esm",
|
|
69
73
|
"test:types": "tsc --noEmit",
|
|
70
74
|
"test:types:dist": "tsc -p test/types/tsconfig.json"
|
|
71
75
|
},
|
|
72
76
|
"peerDependencies": {
|
|
73
|
-
"@napi-rs/canvas": "^0.1.69"
|
|
77
|
+
"@napi-rs/canvas": "^0.1.69 || ^1.0.0"
|
|
74
78
|
},
|
|
75
79
|
"peerDependenciesMeta": {
|
|
76
80
|
"@napi-rs/canvas": {
|
|
@@ -78,21 +82,17 @@
|
|
|
78
82
|
}
|
|
79
83
|
},
|
|
80
84
|
"devDependencies": {
|
|
81
|
-
"@antfu/eslint-config": "^
|
|
82
|
-
"@
|
|
83
|
-
"@
|
|
84
|
-
"@
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"tslib": "^2.8.1",
|
|
94
|
-
"typescript": "^6.0.2",
|
|
95
|
-
"unbuild": "^3.6.1",
|
|
96
|
-
"vitest": "^4.1.4"
|
|
85
|
+
"@antfu/eslint-config": "^9.2.0",
|
|
86
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
87
|
+
"@napi-rs/canvas": "^1.0.2",
|
|
88
|
+
"@types/node": "^26.1.1",
|
|
89
|
+
"bumpp": "^12.0.0",
|
|
90
|
+
"eslint": "^10.7.0",
|
|
91
|
+
"pdfjs-dist": "~6.1.200",
|
|
92
|
+
"rolldown": "^1.2.0",
|
|
93
|
+
"tinyglobby": "^0.2.17",
|
|
94
|
+
"tsdown": "^0.22.14",
|
|
95
|
+
"typescript": "^6.0.3",
|
|
96
|
+
"vitest": "^4.1.10"
|
|
97
97
|
}
|
|
98
98
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import * as _napi_rs_canvas from '@napi-rs/canvas';
|
|
2
|
-
import { Canvas, SKRSContext2D } from '@napi-rs/canvas';
|
|
3
|
-
import { DocumentInitParameters, PDFDocumentProxy } from './types/src/display/api.js';
|
|
4
|
-
import * as pdfjs_dist_types_src_display_metadata from './types/src/display/metadata.js';
|
|
5
|
-
import * as PDFJS from './types/src/pdf.js';
|
|
6
|
-
|
|
7
|
-
interface CanvasFactoryContext {
|
|
8
|
-
canvas?: HTMLCanvasElement | Canvas;
|
|
9
|
-
context?: CanvasRenderingContext2D | SKRSContext2D | null;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Derived from the PDF.js project by the Mozilla Foundation.
|
|
13
|
-
* @see https://github.com/mozilla/pdf.js/blob/b8de9a372f9bbf7e33adb362eeae5ef1919dba73/src/display/canvas_factory.js#L18
|
|
14
|
-
* @license Apache-2.0
|
|
15
|
-
*/
|
|
16
|
-
declare class BaseCanvasFactory {
|
|
17
|
-
#private;
|
|
18
|
-
constructor({ enableHWA }?: {
|
|
19
|
-
enableHWA?: boolean | undefined;
|
|
20
|
-
});
|
|
21
|
-
create(width: number, height: number): {
|
|
22
|
-
canvas: Canvas | HTMLCanvasElement;
|
|
23
|
-
context: SKRSContext2D | CanvasRenderingContext2D | null;
|
|
24
|
-
};
|
|
25
|
-
reset({ canvas }: CanvasFactoryContext, width: number, height: number): void;
|
|
26
|
-
destroy(context: CanvasFactoryContext): void;
|
|
27
|
-
_createCanvas(width: number, height: number): HTMLCanvasElement | Canvas;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Derived from the PDF.js project by the Mozilla Foundation.
|
|
31
|
-
* @see https://github.com/mozilla/pdf.js/blob/b8de9a372f9bbf7e33adb362eeae5ef1919dba73/src/display/canvas_factory.js#L18
|
|
32
|
-
* @license Apache-2.0
|
|
33
|
-
*/
|
|
34
|
-
declare class DOMCanvasFactory extends BaseCanvasFactory {
|
|
35
|
-
_document: Document;
|
|
36
|
-
constructor({ ownerDocument, enableHWA }?: {
|
|
37
|
-
ownerDocument?: Document | undefined;
|
|
38
|
-
enableHWA?: boolean | undefined;
|
|
39
|
-
});
|
|
40
|
-
_createCanvas(width: number, height: number): HTMLCanvasElement;
|
|
41
|
-
}
|
|
42
|
-
declare class NodeCanvasFactory extends BaseCanvasFactory {
|
|
43
|
-
constructor({ enableHWA }?: {
|
|
44
|
-
enableHWA?: boolean | undefined;
|
|
45
|
-
});
|
|
46
|
-
_createCanvas(width: number, height: number): Canvas;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
interface ExtractedImageObject {
|
|
50
|
-
data: Uint8ClampedArray;
|
|
51
|
-
width: number;
|
|
52
|
-
height: number;
|
|
53
|
-
channels: 1 | 3 | 4;
|
|
54
|
-
key: string;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Extracts images from a specific page of a PDF document, including necessary metadata,
|
|
58
|
-
* such as width, height, and calculated color channels.
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* const imagesData = await extractImages(pdf, pageNum)
|
|
62
|
-
*
|
|
63
|
-
* for (const imgData of imagesData) {
|
|
64
|
-
* const imageIndex = totalImagesProcessed + 1
|
|
65
|
-
* await sharp(imgData.data, {
|
|
66
|
-
* raw: { width: imgData.width, height: imgData.height, channels: imgData.channels }
|
|
67
|
-
* })
|
|
68
|
-
* .png()
|
|
69
|
-
* .toFile(`${imageIndex}.png`)
|
|
70
|
-
* }
|
|
71
|
-
*/
|
|
72
|
-
declare function extractImages$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, pageNumber: number): Promise<ExtractedImageObject[]>;
|
|
73
|
-
declare function renderPageAsImage$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, pageNumber: number, options?: {
|
|
74
|
-
canvasImport?: () => Promise<typeof _napi_rs_canvas>;
|
|
75
|
-
/** @default 1.0 */
|
|
76
|
-
scale?: number;
|
|
77
|
-
width?: number;
|
|
78
|
-
height?: number;
|
|
79
|
-
toDataURL?: false;
|
|
80
|
-
}): Promise<ArrayBuffer>;
|
|
81
|
-
declare function renderPageAsImage$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, pageNumber: number, options: {
|
|
82
|
-
canvasImport?: () => Promise<typeof _napi_rs_canvas>;
|
|
83
|
-
/** @default 1.0 */
|
|
84
|
-
scale?: number;
|
|
85
|
-
width?: number;
|
|
86
|
-
height?: number;
|
|
87
|
-
toDataURL: true;
|
|
88
|
-
}): Promise<string>;
|
|
89
|
-
declare function createIsomorphicCanvasFactory(canvasImport?: () => Promise<typeof _napi_rs_canvas>): Promise<typeof DOMCanvasFactory | typeof NodeCanvasFactory>;
|
|
90
|
-
|
|
91
|
-
declare function extractLinks$1(data: DocumentInitParameters['data'] | PDFDocumentProxy): Promise<{
|
|
92
|
-
totalPages: number;
|
|
93
|
-
links: string[];
|
|
94
|
-
}>;
|
|
95
|
-
|
|
96
|
-
declare function getMeta$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, options?: {
|
|
97
|
-
parseDates?: boolean;
|
|
98
|
-
}): Promise<{
|
|
99
|
-
info: Record<string, any>;
|
|
100
|
-
metadata: pdfjs_dist_types_src_display_metadata.Metadata;
|
|
101
|
-
}>;
|
|
102
|
-
|
|
103
|
-
interface StructuredTextItem {
|
|
104
|
-
/** Text content. */
|
|
105
|
-
str: string;
|
|
106
|
-
/** X position in PDF coordinate space (origin: bottom-left). */
|
|
107
|
-
x: number;
|
|
108
|
-
/** Y position in PDF coordinate space (origin: bottom-left). */
|
|
109
|
-
y: number;
|
|
110
|
-
/** Width in device space. */
|
|
111
|
-
width: number;
|
|
112
|
-
/** Height in device space. */
|
|
113
|
-
height: number;
|
|
114
|
-
/** Font size derived from the transformation matrix. */
|
|
115
|
-
fontSize: number;
|
|
116
|
-
/** Font family name. */
|
|
117
|
-
fontFamily: string;
|
|
118
|
-
/** Text direction: `"ltr"`, `"rtl"`, or `"ttb"`. */
|
|
119
|
-
dir: string;
|
|
120
|
-
/** Whether the text item is followed by a line break. */
|
|
121
|
-
hasEOL: boolean;
|
|
122
|
-
}
|
|
123
|
-
declare function extractTextItems$1(data: DocumentInitParameters['data'] | PDFDocumentProxy): Promise<{
|
|
124
|
-
totalPages: number;
|
|
125
|
-
items: StructuredTextItem[][];
|
|
126
|
-
}>;
|
|
127
|
-
declare function extractText$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, options?: {
|
|
128
|
-
mergePages?: false;
|
|
129
|
-
}): Promise<{
|
|
130
|
-
totalPages: number;
|
|
131
|
-
text: string[];
|
|
132
|
-
}>;
|
|
133
|
-
declare function extractText$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, options: {
|
|
134
|
-
mergePages: true;
|
|
135
|
-
}): Promise<{
|
|
136
|
-
totalPages: number;
|
|
137
|
-
text: string;
|
|
138
|
-
}>;
|
|
139
|
-
declare function extractText$1(data: DocumentInitParameters['data'] | PDFDocumentProxy, options?: {
|
|
140
|
-
mergePages?: boolean;
|
|
141
|
-
}): Promise<{
|
|
142
|
-
totalPages: number;
|
|
143
|
-
text: string | string[];
|
|
144
|
-
}>;
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* By default, unpdf will use the latest version of PDF.js compiled for
|
|
148
|
-
* serverless environments. If you want to use a different version, you can
|
|
149
|
-
* provide a custom resolver function.
|
|
150
|
-
*
|
|
151
|
-
* @example
|
|
152
|
-
* // Use the official PDF.js build (make sure to install it first)
|
|
153
|
-
* import { definePDFJSModule } from 'unpdf'
|
|
154
|
-
*
|
|
155
|
-
* await definePDFJSModule(() => import('pdfjs-dist'))
|
|
156
|
-
*/
|
|
157
|
-
declare function definePDFJSModule(pdfjs: () => Promise<any>): Promise<void>;
|
|
158
|
-
/** @deprecated Use `definePDFJSModule` instead. Will be removed in v2. */
|
|
159
|
-
declare function configureUnPDF(options: {
|
|
160
|
-
pdfjs?: () => Promise<any>;
|
|
161
|
-
}): Promise<void>;
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Returns a PDFDocumentProxy instance from a given binary data.
|
|
165
|
-
*
|
|
166
|
-
* Applies the following defaults:
|
|
167
|
-
* - `isEvalSupported: false`
|
|
168
|
-
* - `useSystemFonts: true`
|
|
169
|
-
*
|
|
170
|
-
* In Node.js environments, additionally applies:
|
|
171
|
-
* - `disableFontFace: true`
|
|
172
|
-
* - `standardFontDataUrl` resolved from the local `pdfjs-dist` package
|
|
173
|
-
* - `cMapUrl` and `cMapPacked` resolved from the local `pdfjs-dist` package
|
|
174
|
-
*/
|
|
175
|
-
declare function getDocumentProxy(data: DocumentInitParameters['data'], options?: DocumentInitParameters): Promise<PDFDocumentProxy>;
|
|
176
|
-
declare function getResolvedPDFJS(): Promise<typeof PDFJS>;
|
|
177
|
-
declare function resolvePDFJSImport(pdfjsResolver?: () => Promise<any>, { reload }?: {
|
|
178
|
-
reload?: boolean | undefined;
|
|
179
|
-
}): Promise<void>;
|
|
180
|
-
|
|
181
|
-
declare const getMeta: typeof getMeta$1;
|
|
182
|
-
declare const extractText: typeof extractText$1;
|
|
183
|
-
declare const extractTextItems: typeof extractTextItems$1;
|
|
184
|
-
declare const extractImages: typeof extractImages$1;
|
|
185
|
-
declare const renderPageAsImage: typeof renderPageAsImage$1;
|
|
186
|
-
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 };
|