unpdf 1.8.0 → 1.9.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 +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +15 -15
- package/dist/index.d.mts +15 -15
- package/dist/index.mjs +1 -1
- package/dist/pdfjs.mjs +37 -37
- package/dist/types/external/qcms/qcms.d.ts +11 -7
- package/dist/types/external/qcms/qcms_utils.d.ts +1 -6
- package/dist/types/src/core/base_stream.d.ts +8 -1
- package/dist/types/src/core/catalog.d.ts +12 -12
- package/dist/types/src/core/colorspace.d.ts +6 -15
- package/dist/types/src/core/core_utils.d.ts +18 -14
- package/dist/types/src/core/crypto.d.ts +0 -1
- package/dist/types/src/core/file_spec.d.ts +4 -9
- package/dist/types/src/core/icc_colorspace.d.ts +0 -1
- package/dist/types/src/core/image_resizer.d.ts +24 -0
- package/dist/types/src/core/image_utils.d.ts +4 -4
- package/dist/types/src/core/jpeg_stream.d.ts +1 -1
- package/dist/types/src/core/jpg.d.ts +9 -13
- package/dist/types/src/core/parser.d.ts +0 -2
- package/dist/types/src/core/pattern.d.ts +0 -2
- package/dist/types/src/core/primitives.d.ts +30 -16
- package/dist/types/src/core/sasl_prep.d.ts +1 -0
- package/dist/types/src/core/sound.d.ts +39 -0
- package/dist/types/src/core/string_utils.d.ts +1 -1
- package/dist/types/src/core/struct_tree.d.ts +3 -3
- package/dist/types/src/core/xml_parser.d.ts +1 -2
- package/dist/types/src/core/xref.d.ts +2 -15
- package/dist/types/src/display/annotation_layer.d.ts +9 -20
- package/dist/types/src/display/annotation_storage.d.ts +7 -7
- package/dist/types/src/display/api.d.ts +155 -108
- package/dist/types/src/display/canvas.d.ts +2 -1
- package/dist/types/src/display/canvas_dependency_tracker.d.ts +8 -3
- package/dist/types/src/display/content_disposition.d.ts +0 -1
- package/dist/types/src/display/display_utils.d.ts +2 -2
- package/dist/types/src/display/draw_layer.d.ts +2 -6
- package/dist/types/src/display/editor/annotation_editor_layer.d.ts +18 -19
- package/dist/types/src/display/editor/color_picker.d.ts +1 -1
- package/dist/types/src/display/editor/comment.d.ts +1 -1
- package/dist/types/src/display/editor/draw.d.ts +78 -27
- package/dist/types/src/display/editor/drawers/freedraw.d.ts +11 -9
- package/dist/types/src/display/editor/drawers/highlight.d.ts +99 -15
- package/dist/types/src/display/editor/drawers/inkdraw.d.ts +7 -2
- package/dist/types/src/display/editor/drawers/outline.d.ts +65 -2
- package/dist/types/src/display/editor/editor.d.ts +24 -22
- package/dist/types/src/display/editor/freetext.d.ts +1 -1
- package/dist/types/src/display/editor/highlight.d.ts +44 -35
- package/dist/types/src/display/editor/ink.d.ts +7 -2
- package/dist/types/src/display/editor/stamp.d.ts +1 -1
- package/dist/types/src/display/editor/tools.d.ts +21 -19
- package/dist/types/src/display/filter_factory.d.ts +1 -3
- package/dist/types/src/display/font_loader.d.ts +1 -15
- package/dist/types/src/display/network_utils.d.ts +1 -0
- package/dist/types/src/display/obj_bin_transform_display.d.ts +25 -38
- package/dist/types/src/display/page_viewport.d.ts +5 -5
- package/dist/types/src/display/pages_mapper.d.ts +10 -4
- package/dist/types/src/display/pattern_helper.d.ts +4 -3
- package/dist/types/src/display/pdf_objects.d.ts +1 -3
- package/dist/types/src/display/text_layer.d.ts +2 -0
- package/dist/types/src/display/touch_manager.d.ts +46 -9
- package/dist/types/src/display/worker_options.d.ts +2 -2
- package/dist/types/src/display/xfa_layer.d.ts +7 -12
- package/dist/types/src/display/xfa_text.d.ts +2 -5
- package/dist/types/src/pdf.d.ts +2 -1
- package/dist/types/src/shared/base_pdf_stream.d.ts +6 -7
- package/dist/types/src/shared/css_utils.d.ts +8 -0
- package/dist/types/src/shared/message_handler.d.ts +2 -11
- package/dist/types/src/shared/obj_bin_transform_utils.d.ts +4 -3
- package/dist/types/src/shared/util.d.ts +4 -6
- package/dist/types/web/annotation_editor_layer_builder.d.ts +5 -3
- package/dist/types/web/annotation_layer_builder.d.ts +8 -12
- package/dist/types/web/draw_layer_builder.d.ts +7 -9
- package/dist/types/web/event_utils.d.ts +12 -13
- package/dist/types/web/genericl10n.d.ts +2 -2
- package/dist/types/web/l10n.d.ts +1 -1
- package/dist/types/web/pdf_find_controller.d.ts +5 -6
- package/dist/types/web/pdf_find_utils.d.ts +8 -14
- package/dist/types/web/pdf_history.d.ts +1 -1
- package/dist/types/web/pdf_link_service.d.ts +5 -7
- package/dist/types/web/pdf_page_view.d.ts +3 -3
- package/dist/types/web/pdf_rendering_queue.d.ts +4 -5
- package/dist/types/web/pdf_scripting_manager.d.ts +4 -4
- package/dist/types/web/pdf_thumbnail_view.d.ts +2 -2
- package/dist/types/web/pdf_thumbnail_viewer.d.ts +14 -15
- package/dist/types/web/pdf_viewer.d.ts +36 -16
- package/dist/types/web/renderable_view.d.ts +1 -1
- package/dist/types/web/sidebar.d.ts +3 -3
- package/dist/types/web/struct_tree_layer_builder.d.ts +20 -6
- package/dist/types/web/text_accessibility.d.ts +4 -2
- package/dist/types/web/text_highlighter.d.ts +1 -2
- package/dist/types/web/text_layer_builder.d.ts +5 -5
- package/dist/types/web/ui_utils.d.ts +8 -13
- package/dist/types/web/xfa_layer_builder.d.ts +7 -7
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ console.log(await document.getMetadata())
|
|
|
91
91
|
## How It Works
|
|
92
92
|
|
|
93
93
|
> [!NOTE]
|
|
94
|
-
> The serverless PDF.js bundle is built from PDF.js
|
|
94
|
+
> The serverless PDF.js bundle is built from PDF.js v6.4.299. It requires the global `Iterator` constructor (Safari 18.4+); without it, importing the bundle throws.
|
|
95
95
|
|
|
96
96
|
Heart and soul of this package is the [`pdfjs.rolldown.config.ts`](./pdfjs.rolldown.config.ts) file. It uses [Rolldown](https://rolldown.rs/) to bundle PDF.js into a single file for serverless environments. The key techniques:
|
|
97
97
|
|
package/dist/index.cjs
CHANGED
|
@@ -53,7 +53,7 @@ let resolvedModule;
|
|
|
53
53
|
const isNode = globalThis.process?.release?.name === "node";
|
|
54
54
|
const isBrowser = typeof window !== "undefined";
|
|
55
55
|
/**
|
|
56
|
-
* Returns a PDFDocumentProxy instance from a given binary data.
|
|
56
|
+
* Returns a `PDFDocumentProxy` instance from a given binary data.
|
|
57
57
|
*
|
|
58
58
|
* Applies the following defaults:
|
|
59
59
|
* - `useSystemFonts: true`
|
package/dist/index.d.cts
CHANGED
|
@@ -85,7 +85,7 @@ declare function renderPageAsImage$1(data: DocumentInitParameters['data'] | PDFD
|
|
|
85
85
|
height?: number;
|
|
86
86
|
toDataURL: true;
|
|
87
87
|
}): Promise<string>;
|
|
88
|
-
declare function createIsomorphicCanvasFactory(canvasImport?: () => Promise<typeof import('@napi-rs/canvas')>): Promise<typeof DOMCanvasFactory | typeof NodeCanvasFactory>;
|
|
88
|
+
export declare function createIsomorphicCanvasFactory(canvasImport?: () => Promise<typeof import('@napi-rs/canvas')>): Promise<typeof DOMCanvasFactory | typeof NodeCanvasFactory>;
|
|
89
89
|
//#endregion
|
|
90
90
|
//#region src/links.d.ts
|
|
91
91
|
declare function extractLinks$1(data: DocumentInitParameters['data'] | PDFDocumentProxy): Promise<{
|
|
@@ -115,7 +115,7 @@ interface StructuredTextItem {
|
|
|
115
115
|
height: number;
|
|
116
116
|
/** Font size derived from the transformation matrix. */
|
|
117
117
|
fontSize: number;
|
|
118
|
-
/** Font family
|
|
118
|
+
/** Font family resolved from the page's style table, empty when unknown. */
|
|
119
119
|
fontFamily: string;
|
|
120
120
|
/** Text direction: `"ltr"`, `"rtl"`, or `"ttb"`. */
|
|
121
121
|
dir: string;
|
|
@@ -157,15 +157,15 @@ declare function extractText$1(data: DocumentInitParameters['data'] | PDFDocumen
|
|
|
157
157
|
*
|
|
158
158
|
* await definePDFJSModule(() => import('pdfjs-dist'))
|
|
159
159
|
*/
|
|
160
|
-
declare function definePDFJSModule(pdfjs: () => Promise<any>): Promise<void>;
|
|
160
|
+
export declare function definePDFJSModule(pdfjs: () => Promise<any>): Promise<void>;
|
|
161
161
|
/** @deprecated Use `definePDFJSModule` instead. Will be removed in v2. */
|
|
162
|
-
declare function configureUnPDF(options: {
|
|
162
|
+
export declare function configureUnPDF(options: {
|
|
163
163
|
pdfjs?: () => Promise<any>;
|
|
164
164
|
}): Promise<void>;
|
|
165
165
|
//#endregion
|
|
166
166
|
//#region src/utils.d.ts
|
|
167
167
|
/**
|
|
168
|
-
* Returns a PDFDocumentProxy instance from a given binary data.
|
|
168
|
+
* Returns a `PDFDocumentProxy` instance from a given binary data.
|
|
169
169
|
*
|
|
170
170
|
* Applies the following defaults:
|
|
171
171
|
* - `useSystemFonts: true`
|
|
@@ -175,18 +175,18 @@ declare function configureUnPDF(options: {
|
|
|
175
175
|
* - `standardFontDataUrl` resolved from the local `pdfjs-dist` package
|
|
176
176
|
* - `cMapUrl` and `cMapPacked` resolved from the local `pdfjs-dist` package
|
|
177
177
|
*/
|
|
178
|
-
declare function getDocumentProxy(data: DocumentInitParameters['data'], options?: DocumentInitParameters): Promise<PDFDocumentProxy>;
|
|
179
|
-
declare function getResolvedPDFJS(): Promise<typeof PDFJS>;
|
|
180
|
-
declare function resolvePDFJSImport(pdfjsResolver?: () => Promise<any>, { reload }?: {
|
|
178
|
+
export declare function getDocumentProxy(data: DocumentInitParameters['data'], options?: DocumentInitParameters): Promise<PDFDocumentProxy>;
|
|
179
|
+
export declare function getResolvedPDFJS(): Promise<typeof PDFJS>;
|
|
180
|
+
export declare function resolvePDFJSImport(pdfjsResolver?: () => Promise<any>, { reload }?: {
|
|
181
181
|
reload?: boolean | undefined;
|
|
182
182
|
}): Promise<void>;
|
|
183
183
|
//#endregion
|
|
184
184
|
//#region src/index.d.ts
|
|
185
|
-
declare const getMeta: typeof getMeta$1;
|
|
186
|
-
declare const extractText: typeof extractText$1;
|
|
187
|
-
declare const extractTextItems: typeof extractTextItems$1;
|
|
188
|
-
declare const extractImages: typeof extractImages$1;
|
|
189
|
-
declare const renderPageAsImage: typeof renderPageAsImage$1;
|
|
190
|
-
declare const extractLinks: typeof extractLinks$1;
|
|
185
|
+
export declare const getMeta: typeof getMeta$1;
|
|
186
|
+
export declare const extractText: typeof extractText$1;
|
|
187
|
+
export declare const extractTextItems: typeof extractTextItems$1;
|
|
188
|
+
export declare const extractImages: typeof extractImages$1;
|
|
189
|
+
export declare const renderPageAsImage: typeof renderPageAsImage$1;
|
|
190
|
+
export declare const extractLinks: typeof extractLinks$1;
|
|
191
191
|
//#endregion
|
|
192
|
-
export {
|
|
192
|
+
export type { StructuredTextItem };
|
package/dist/index.d.mts
CHANGED
|
@@ -85,7 +85,7 @@ declare function renderPageAsImage$1(data: DocumentInitParameters['data'] | PDFD
|
|
|
85
85
|
height?: number;
|
|
86
86
|
toDataURL: true;
|
|
87
87
|
}): Promise<string>;
|
|
88
|
-
declare function createIsomorphicCanvasFactory(canvasImport?: () => Promise<typeof import('@napi-rs/canvas')>): Promise<typeof DOMCanvasFactory | typeof NodeCanvasFactory>;
|
|
88
|
+
export declare function createIsomorphicCanvasFactory(canvasImport?: () => Promise<typeof import('@napi-rs/canvas')>): Promise<typeof DOMCanvasFactory | typeof NodeCanvasFactory>;
|
|
89
89
|
//#endregion
|
|
90
90
|
//#region src/links.d.ts
|
|
91
91
|
declare function extractLinks$1(data: DocumentInitParameters['data'] | PDFDocumentProxy): Promise<{
|
|
@@ -115,7 +115,7 @@ interface StructuredTextItem {
|
|
|
115
115
|
height: number;
|
|
116
116
|
/** Font size derived from the transformation matrix. */
|
|
117
117
|
fontSize: number;
|
|
118
|
-
/** Font family
|
|
118
|
+
/** Font family resolved from the page's style table, empty when unknown. */
|
|
119
119
|
fontFamily: string;
|
|
120
120
|
/** Text direction: `"ltr"`, `"rtl"`, or `"ttb"`. */
|
|
121
121
|
dir: string;
|
|
@@ -157,15 +157,15 @@ declare function extractText$1(data: DocumentInitParameters['data'] | PDFDocumen
|
|
|
157
157
|
*
|
|
158
158
|
* await definePDFJSModule(() => import('pdfjs-dist'))
|
|
159
159
|
*/
|
|
160
|
-
declare function definePDFJSModule(pdfjs: () => Promise<any>): Promise<void>;
|
|
160
|
+
export declare function definePDFJSModule(pdfjs: () => Promise<any>): Promise<void>;
|
|
161
161
|
/** @deprecated Use `definePDFJSModule` instead. Will be removed in v2. */
|
|
162
|
-
declare function configureUnPDF(options: {
|
|
162
|
+
export declare function configureUnPDF(options: {
|
|
163
163
|
pdfjs?: () => Promise<any>;
|
|
164
164
|
}): Promise<void>;
|
|
165
165
|
//#endregion
|
|
166
166
|
//#region src/utils.d.ts
|
|
167
167
|
/**
|
|
168
|
-
* Returns a PDFDocumentProxy instance from a given binary data.
|
|
168
|
+
* Returns a `PDFDocumentProxy` instance from a given binary data.
|
|
169
169
|
*
|
|
170
170
|
* Applies the following defaults:
|
|
171
171
|
* - `useSystemFonts: true`
|
|
@@ -175,18 +175,18 @@ declare function configureUnPDF(options: {
|
|
|
175
175
|
* - `standardFontDataUrl` resolved from the local `pdfjs-dist` package
|
|
176
176
|
* - `cMapUrl` and `cMapPacked` resolved from the local `pdfjs-dist` package
|
|
177
177
|
*/
|
|
178
|
-
declare function getDocumentProxy(data: DocumentInitParameters['data'], options?: DocumentInitParameters): Promise<PDFDocumentProxy>;
|
|
179
|
-
declare function getResolvedPDFJS(): Promise<typeof PDFJS>;
|
|
180
|
-
declare function resolvePDFJSImport(pdfjsResolver?: () => Promise<any>, { reload }?: {
|
|
178
|
+
export declare function getDocumentProxy(data: DocumentInitParameters['data'], options?: DocumentInitParameters): Promise<PDFDocumentProxy>;
|
|
179
|
+
export declare function getResolvedPDFJS(): Promise<typeof PDFJS>;
|
|
180
|
+
export declare function resolvePDFJSImport(pdfjsResolver?: () => Promise<any>, { reload }?: {
|
|
181
181
|
reload?: boolean | undefined;
|
|
182
182
|
}): Promise<void>;
|
|
183
183
|
//#endregion
|
|
184
184
|
//#region src/index.d.ts
|
|
185
|
-
declare const getMeta: typeof getMeta$1;
|
|
186
|
-
declare const extractText: typeof extractText$1;
|
|
187
|
-
declare const extractTextItems: typeof extractTextItems$1;
|
|
188
|
-
declare const extractImages: typeof extractImages$1;
|
|
189
|
-
declare const renderPageAsImage: typeof renderPageAsImage$1;
|
|
190
|
-
declare const extractLinks: typeof extractLinks$1;
|
|
185
|
+
export declare const getMeta: typeof getMeta$1;
|
|
186
|
+
export declare const extractText: typeof extractText$1;
|
|
187
|
+
export declare const extractTextItems: typeof extractTextItems$1;
|
|
188
|
+
export declare const extractImages: typeof extractImages$1;
|
|
189
|
+
export declare const renderPageAsImage: typeof renderPageAsImage$1;
|
|
190
|
+
export declare const extractLinks: typeof extractLinks$1;
|
|
191
191
|
//#endregion
|
|
192
|
-
export {
|
|
192
|
+
export type { StructuredTextItem };
|
package/dist/index.mjs
CHANGED
|
@@ -52,7 +52,7 @@ let resolvedModule;
|
|
|
52
52
|
const isNode = globalThis.process?.release?.name === "node";
|
|
53
53
|
const isBrowser = typeof window !== "undefined";
|
|
54
54
|
/**
|
|
55
|
-
* Returns a PDFDocumentProxy instance from a given binary data.
|
|
55
|
+
* Returns a `PDFDocumentProxy` instance from a given binary data.
|
|
56
56
|
*
|
|
57
57
|
* Applies the following defaults:
|
|
58
58
|
* - `useSystemFonts: true`
|