unpdf 2.1.0 → 2.2.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 +12 -12
- package/dist/index.mjs +15 -13
- package/dist/pdfjs-jbig2_nowasm_fallback.mjs +1 -1
- package/dist/pdfjs-openjpeg.mjs +1 -1
- package/dist/pdfjs-openjpeg_nowasm_fallback.mjs +1 -2
- package/dist/pdfjs.mjs +39 -39
- package/dist/types/src/core/colorspace.d.ts +7 -0
- package/dist/types/src/core/crypto.d.ts +10 -2
- package/dist/types/src/core/flate_stream.d.ts +6 -1
- package/dist/types/src/core/image_resizer.d.ts +1 -1
- package/dist/types/src/core/image_utils.d.ts +10 -0
- package/dist/types/src/core/jpx.d.ts +0 -1
- package/dist/types/src/core/parser.d.ts +8 -1
- package/dist/types/src/core/pattern.d.ts +0 -4
- package/dist/types/src/core/primitives.d.ts +1 -0
- package/dist/types/src/core/struct_tree.d.ts +2 -0
- package/dist/types/src/core/wasm_image.d.ts +3 -3
- package/dist/types/src/display/annotation_layer.d.ts +9 -2
- package/dist/types/src/display/api.d.ts +38 -2
- package/dist/types/src/display/api_utils.d.ts +10 -0
- package/dist/types/src/display/canvas.d.ts +13 -3
- package/dist/types/src/display/canvas_dependency_tracker.d.ts +20 -10
- package/dist/types/src/display/canvas_factory.d.ts +1 -11
- package/dist/types/src/display/display_utils.d.ts +0 -71
- package/dist/types/src/display/dom_canvas_factory.d.ts +12 -0
- package/dist/types/src/display/dom_filter_factory.d.ts +23 -0
- package/dist/types/src/display/dom_utils.d.ts +68 -0
- package/dist/types/src/display/editor/draw.d.ts +2 -0
- package/dist/types/src/display/editor/drawers/inkdraw.d.ts +14 -17
- package/dist/types/src/display/editor/drawers/input_smoother.d.ts +28 -0
- package/dist/types/src/display/editor/drawers/outline.d.ts +2 -2
- package/dist/types/src/display/editor/ink.d.ts +2 -1
- package/dist/types/src/display/editor/tools.d.ts +2 -1
- package/dist/types/src/display/filter_factory.d.ts +0 -22
- package/dist/types/src/display/object_handler.d.ts +21 -0
- package/dist/types/src/display/pdf_objects.d.ts +10 -1
- package/dist/types/src/display/renderer_worker_proxy.d.ts +131 -0
- package/dist/types/src/display/text_layer.d.ts +1 -6
- package/dist/types/src/display/worker_options.d.ts +24 -0
- package/dist/types/src/pdf.d.ts +12 -12
- package/dist/types/src/shared/message_handler.d.ts +1 -0
- package/dist/types/src/shared/util.d.ts +4 -0
- package/dist/types/web/annotation_layer_builder.d.ts +1 -0
- package/dist/types/web/autolinker.d.ts +4 -4
- package/dist/types/web/base_download_manager.d.ts +3 -2
- package/dist/types/web/download_manager.d.ts +1 -0
- package/dist/types/web/pdf_page_view.d.ts +1 -0
- package/dist/types/web/pdf_scripting_manager.d.ts +1 -1
- package/dist/types/web/pdf_thumbnail_viewer.d.ts +7 -1
- package/package.json +27 -24
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export class ColorScheme {
|
|
2
|
+
static get isDarkMode(): any;
|
|
3
|
+
}
|
|
4
|
+
export class CSSConstants {
|
|
5
|
+
static get commentForegroundColor(): any;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* This file contains helper functions that:
|
|
9
|
+
* - Directly, or indirectly, access the DOM.
|
|
10
|
+
* - Are only invoked from code running in the main-thread.
|
|
11
|
+
*/
|
|
12
|
+
export function fetchData(url: any, type?: string): Promise<any>;
|
|
13
|
+
export function getColorValues(colors: any): void;
|
|
14
|
+
/**
|
|
15
|
+
* Gets the filename from a given URL.
|
|
16
|
+
* @param {string} url
|
|
17
|
+
* @returns {string}
|
|
18
|
+
*/
|
|
19
|
+
export function getFilenameFromUrl(url: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the filename or guessed filename from the url (see issue 3455).
|
|
22
|
+
* @param {string} url - The original PDF location.
|
|
23
|
+
* @param {string} defaultFilename - The value returned if the filename is
|
|
24
|
+
* unknown, or the protocol is unsupported.
|
|
25
|
+
* @returns {string} Guessed PDF filename.
|
|
26
|
+
*/
|
|
27
|
+
export function getPdfFilenameFromUrl(url: string, defaultFilename?: string): string;
|
|
28
|
+
export function isDataScheme(url: any): boolean;
|
|
29
|
+
export function isPdfFile(filename: any): boolean;
|
|
30
|
+
export function isValidFetchUrl(url: any, baseUrl: any): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Event handler to suppress context menu.
|
|
33
|
+
*/
|
|
34
|
+
export function noContextMenu(e: any): void;
|
|
35
|
+
export class PDFDateString {
|
|
36
|
+
static #regex: any;
|
|
37
|
+
/**
|
|
38
|
+
* Convert a PDF date string to a JavaScript `Date` object.
|
|
39
|
+
*
|
|
40
|
+
* The PDF date string format is described in section 7.9.4 of the official
|
|
41
|
+
* PDF 32000-1:2008 specification. However, in the PDF 1.7 reference (sixth
|
|
42
|
+
* edition) Adobe describes the same format including a trailing apostrophe.
|
|
43
|
+
* This syntax in incorrect, but Adobe Acrobat creates PDF files that contain
|
|
44
|
+
* them. We ignore all apostrophes as they are not necessary for date parsing.
|
|
45
|
+
*
|
|
46
|
+
* Moreover, Adobe Acrobat doesn't handle changing the date to universal time
|
|
47
|
+
* and doesn't use the user's time zone (effectively ignoring the HH' and mm'
|
|
48
|
+
* parts of the date string).
|
|
49
|
+
* @param {string} input
|
|
50
|
+
* @returns {Date|null}
|
|
51
|
+
*/
|
|
52
|
+
static toDateObject(input: string): Date | null;
|
|
53
|
+
}
|
|
54
|
+
export function renderRichText({ html, dir, className }: {
|
|
55
|
+
html: any;
|
|
56
|
+
dir: any;
|
|
57
|
+
className: any;
|
|
58
|
+
}, container: any): void;
|
|
59
|
+
/**
|
|
60
|
+
* @param {HTMLDivElement} div
|
|
61
|
+
* @param {PageViewport} viewport
|
|
62
|
+
* @param {boolean} mustFlip
|
|
63
|
+
* @param {boolean} mustRotate
|
|
64
|
+
*/
|
|
65
|
+
export function setLayerDimensions(div: HTMLDivElement, viewport: PageViewport, mustFlip?: boolean, mustRotate?: boolean): void;
|
|
66
|
+
export function stopEvent(e: any): void;
|
|
67
|
+
export const SupportedImageMimeTypes: Set<string>;
|
|
68
|
+
import { PageViewport } from "./page_viewport.js";
|
|
@@ -61,6 +61,7 @@ export class DrawingEditor extends AnnotationEditor {
|
|
|
61
61
|
* @param {number} _params.rotation - The viewport rotation.
|
|
62
62
|
* @param {AnnotationEditorLayer} _params.parent - The parent layer.
|
|
63
63
|
* @param {boolean} _params.isLTR - Whether the direction is left-to-right.
|
|
64
|
+
* @param {number} _params.timeStamp - The timestamp of the pointer event.
|
|
64
65
|
*/
|
|
65
66
|
static createDrawerInstance(_params: {
|
|
66
67
|
x: number;
|
|
@@ -69,6 +70,7 @@ export class DrawingEditor extends AnnotationEditor {
|
|
|
69
70
|
rotation: number;
|
|
70
71
|
parent: AnnotationEditorLayer;
|
|
71
72
|
isLTR: boolean;
|
|
73
|
+
timeStamp: number;
|
|
72
74
|
}): void;
|
|
73
75
|
/**
|
|
74
76
|
* @param {AnnotationEditorLayer} _parent
|
|
@@ -11,14 +11,15 @@ export class InkDrawOutline extends Outline {
|
|
|
11
11
|
get thickness(): any;
|
|
12
12
|
setLastElement(element: any): {
|
|
13
13
|
path: {
|
|
14
|
-
d:
|
|
14
|
+
d: any;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
removeLastElement(): {
|
|
18
18
|
path: {
|
|
19
|
-
d:
|
|
19
|
+
d: any;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
+
toSVGPath(): any;
|
|
22
23
|
serialize([pageX, pageY, pageWidth, pageHeight]: [any, any, any, any], isForCopying: any): {
|
|
23
24
|
lines: any[];
|
|
24
25
|
points: any[];
|
|
@@ -55,7 +56,7 @@ export class InkDrawOutline extends Outline {
|
|
|
55
56
|
path: {
|
|
56
57
|
"transform-origin": string;
|
|
57
58
|
transform: string | null;
|
|
58
|
-
d:
|
|
59
|
+
d: any;
|
|
59
60
|
};
|
|
60
61
|
};
|
|
61
62
|
getPathTranslatedSVGProperties([newX, newY]: [any, any], parentDimensions: any): {
|
|
@@ -63,7 +64,7 @@ export class InkDrawOutline extends Outline {
|
|
|
63
64
|
viewBox: any;
|
|
64
65
|
};
|
|
65
66
|
path: {
|
|
66
|
-
d:
|
|
67
|
+
d: any;
|
|
67
68
|
"transform-origin": string;
|
|
68
69
|
};
|
|
69
70
|
};
|
|
@@ -75,7 +76,7 @@ export class InkDrawOutline extends Outline {
|
|
|
75
76
|
draw: boolean;
|
|
76
77
|
};
|
|
77
78
|
path: {
|
|
78
|
-
d:
|
|
79
|
+
d: any;
|
|
79
80
|
"transform-origin": string;
|
|
80
81
|
transform: string | null;
|
|
81
82
|
};
|
|
@@ -84,41 +85,37 @@ export class InkDrawOutline extends Outline {
|
|
|
84
85
|
#private;
|
|
85
86
|
}
|
|
86
87
|
export class InkDrawOutliner {
|
|
87
|
-
constructor(x: any, y: any, parentWidth: any, parentHeight: any, rotation: any, thickness: any);
|
|
88
|
+
constructor(x: any, y: any, parentWidth: any, parentHeight: any, rotation: any, thickness: any, timeStamp: any);
|
|
88
89
|
updateProperty(name: any, value: any): void;
|
|
89
90
|
isEmpty(): boolean;
|
|
90
91
|
isCancellable(): boolean;
|
|
91
|
-
add(x: any, y: any): {
|
|
92
|
+
add(x: any, y: any, timeStamp: any): {
|
|
92
93
|
path: {
|
|
93
94
|
d: string;
|
|
94
95
|
};
|
|
95
96
|
};
|
|
96
|
-
addPoints(points: any): {
|
|
97
|
+
addPoints(points: any, timeStamps: any): {
|
|
97
98
|
path: {
|
|
98
99
|
d: string;
|
|
99
100
|
};
|
|
100
101
|
};
|
|
101
|
-
end(x: any, y: any): {
|
|
102
|
+
end(x: any, y: any, timeStamp: any): {
|
|
102
103
|
path: {
|
|
103
104
|
d: string;
|
|
104
105
|
};
|
|
105
106
|
};
|
|
106
|
-
startNew(x: any, y: any, parentWidth: any, parentHeight: any, rotation: any): null;
|
|
107
|
-
getLastElement():
|
|
108
|
-
line: any[];
|
|
109
|
-
points: any[];
|
|
110
|
-
} | undefined;
|
|
107
|
+
startNew(x: any, y: any, parentWidth: any, parentHeight: any, rotation: any, timeStamp: any): null;
|
|
108
|
+
getLastElement(): any;
|
|
111
109
|
setLastElement(element: any): {
|
|
112
110
|
path: {
|
|
113
|
-
d:
|
|
111
|
+
d: any;
|
|
114
112
|
};
|
|
115
113
|
};
|
|
116
114
|
removeLastElement(): {
|
|
117
115
|
path: {
|
|
118
|
-
d:
|
|
116
|
+
d: any;
|
|
119
117
|
};
|
|
120
118
|
};
|
|
121
|
-
toSVGPath(): string;
|
|
122
119
|
getOutlines(parentWidth: any, parentHeight: any, scale: any, innerMargin: any): InkDrawOutline;
|
|
123
120
|
get defaultSVGProperties(): {
|
|
124
121
|
root: {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Average pointer positions over a sliding time window to reduce jitter.
|
|
3
|
+
* Based on Google Ink's sliding window input model (https://github.com/google/ink).
|
|
4
|
+
*/
|
|
5
|
+
export class InputSmoother {
|
|
6
|
+
static #HALF_WINDOW: number;
|
|
7
|
+
static #UPSAMPLING_PERIOD: number;
|
|
8
|
+
static #MAX_DIVISIONS: number;
|
|
9
|
+
static #TIME_EPSILON: number;
|
|
10
|
+
constructor(x: any, y: any, timeStamp: any);
|
|
11
|
+
/**
|
|
12
|
+
* @param {number} x
|
|
13
|
+
* @param {number} y
|
|
14
|
+
* @param {number} timeStamp
|
|
15
|
+
* @returns {Array<number>} new stable points as [x, y, ...].
|
|
16
|
+
*/
|
|
17
|
+
add(x: number, y: number, timeStamp: number): Array<number>;
|
|
18
|
+
/**
|
|
19
|
+
* @returns {Array<number>} unstable points as [x, y, ...], ending at the
|
|
20
|
+
* latest sample when nonempty.
|
|
21
|
+
*/
|
|
22
|
+
get pendingPoints(): Array<number>;
|
|
23
|
+
/**
|
|
24
|
+
* @returns {Array<number>} remaining smoothed points as [x, y, ...].
|
|
25
|
+
*/
|
|
26
|
+
end(): Array<number>;
|
|
27
|
+
#private;
|
|
28
|
+
}
|
|
@@ -11,8 +11,8 @@ export class Outline {
|
|
|
11
11
|
static _rescaleAndSwap(src: any, tx: any, ty: any, sx: any, sy: any, dest: any): any;
|
|
12
12
|
static _translate(src: any, tx: any, ty: any, dest: any): any;
|
|
13
13
|
static svgRound(x: any): number;
|
|
14
|
-
static _normalizePoint(x: any, y: any, parentWidth: any, parentHeight: any, rotation: any):
|
|
15
|
-
static createBezierPoints(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any):
|
|
14
|
+
static _normalizePoint(x: any, y: any, parentWidth: any, parentHeight: any, rotation: any, dest?: any[]): any[];
|
|
15
|
+
static createBezierPoints(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, dest?: any[]): any[];
|
|
16
16
|
/** @type {Outline|null} Optional hover/selection outline drawn separately. */
|
|
17
17
|
focusOutline: Outline | null;
|
|
18
18
|
/**
|
|
@@ -17,11 +17,12 @@ export class InkEditor extends DrawingEditor {
|
|
|
17
17
|
/** @inheritdoc */
|
|
18
18
|
static get typesMap(): any;
|
|
19
19
|
/** @inheritdoc */
|
|
20
|
-
static createDrawerInstance({ x, y, box: [, , width, height], rotation }: {
|
|
20
|
+
static createDrawerInstance({ x, y, box: [, , width, height], rotation, timeStamp, }: {
|
|
21
21
|
x: any;
|
|
22
22
|
y: any;
|
|
23
23
|
box: [any, any, any, any];
|
|
24
24
|
rotation: any;
|
|
25
|
+
timeStamp: any;
|
|
25
26
|
}): InkDrawOutliner;
|
|
26
27
|
/** @inheritdoc */
|
|
27
28
|
static deserializeDraw(pageX: any, pageY: any, pageWidth: any, pageHeight: any, innerMargin: any, data: any): any;
|
|
@@ -12,7 +12,7 @@ export class AnnotationEditorUIManager {
|
|
|
12
12
|
static TRANSLATE_SMALL: number;
|
|
13
13
|
static TRANSLATE_BIG: number;
|
|
14
14
|
static get _keyboardManager(): any;
|
|
15
|
-
constructor(container: any, viewer: any, viewerAlert: any, altTextManager: any, commentManager: any, signatureManager: any, eventBus: any, pdfDocument: any, pageColors: any, highlightColors: any, enableHighlightFloatingButton: any, enableUpdatedAddImage: any, enableNewAltTextWhenAddingImage: any, mlManager: any, editorUndoBar: any, supportsPinchToZoom: any);
|
|
15
|
+
constructor(container: any, viewer: any, viewerAlert: any, altTextManager: any, commentManager: any, signatureManager: any, eventBus: any, pdfDocument: any, pageColors: any, highlightColors: any, enableHighlightFloatingButton: any, enableUpdatedAddImage: any, enableNewAltTextWhenAddingImage: any, mlManager: any, editorUndoBar: any, supportsPinchToZoom: any, keepToolbarInPage: any);
|
|
16
16
|
_editorUndoBar: null;
|
|
17
17
|
_signal: AbortSignal;
|
|
18
18
|
_eventBus: any;
|
|
@@ -22,6 +22,7 @@ export class AnnotationEditorUIManager {
|
|
|
22
22
|
};
|
|
23
23
|
isShiftKeyDown: boolean;
|
|
24
24
|
_supportsPinchToZoom: boolean;
|
|
25
|
+
_keepToolbarInPage: boolean;
|
|
25
26
|
destroy(): void;
|
|
26
27
|
combinedSignal(ac: any): AbortSignal;
|
|
27
28
|
get mlManager(): null;
|
|
@@ -29,25 +29,3 @@ export class BaseFilterFactory {
|
|
|
29
29
|
}): Record<string, string> | null;
|
|
30
30
|
destroy(keepHCM?: boolean): void;
|
|
31
31
|
}
|
|
32
|
-
/**
|
|
33
|
-
* FilterFactory aims to create some SVG filters we can use when drawing an
|
|
34
|
-
* image (or whatever) on a canvas.
|
|
35
|
-
* Filters aren't applied with ctx.putImageData because it just overwrites the
|
|
36
|
-
* underlying pixels.
|
|
37
|
-
* With these filters, it's possible for example to apply some transfer maps on
|
|
38
|
-
* an image without the need to apply them on the pixel arrays: the renderer
|
|
39
|
-
* does the magic for us.
|
|
40
|
-
*/
|
|
41
|
-
export class DOMFilterFactory extends BaseFilterFactory {
|
|
42
|
-
constructor({ docId, ownerDocument }: {
|
|
43
|
-
docId: any;
|
|
44
|
-
ownerDocument?: Document | undefined;
|
|
45
|
-
});
|
|
46
|
-
addFilter(maps: any): any;
|
|
47
|
-
addHCMFilter(fgColor: any, bgColor: any): any;
|
|
48
|
-
addAlphaFilter(map: any): any;
|
|
49
|
-
addLuminosityFilter(map: any): any;
|
|
50
|
-
addKnockoutFilter(alpha?: number): any;
|
|
51
|
-
addHighlightHCMFilter(filterName: any, fgColor: any, bgColor: any, newFgColor: any, newBgColor: any): any;
|
|
52
|
-
#private;
|
|
53
|
-
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class ObjectHandler {
|
|
2
|
+
constructor({ messageHandler, commonObjs, fontLoader, pageCache, pdfBug, shouldCreatePageObjs, }: {
|
|
3
|
+
messageHandler: any;
|
|
4
|
+
commonObjs: any;
|
|
5
|
+
fontLoader: any;
|
|
6
|
+
pageCache: any;
|
|
7
|
+
pdfBug?: boolean | undefined;
|
|
8
|
+
shouldCreatePageObjs?: boolean | undefined;
|
|
9
|
+
});
|
|
10
|
+
messageHandler: any;
|
|
11
|
+
commonObjs: any;
|
|
12
|
+
fontLoader: any;
|
|
13
|
+
pageCache: any;
|
|
14
|
+
pdfBug: boolean;
|
|
15
|
+
shouldCreatePageObjs: boolean;
|
|
16
|
+
resolveCommonObject(id: any, type: any, exportedData: any): any;
|
|
17
|
+
/**
|
|
18
|
+
* @returns {boolean} Whether the object was stored.
|
|
19
|
+
*/
|
|
20
|
+
resolveObject(id: any, pageProxyId: any, type: any, exportedData: any): boolean;
|
|
21
|
+
}
|
|
@@ -13,9 +13,12 @@ export class PDFObjects {
|
|
|
13
13
|
* and the object is already resolved, the callback gets called right away.
|
|
14
14
|
* @param {string} objId
|
|
15
15
|
* @param {Function} [callback]
|
|
16
|
+
* @param {Function} [errorCallback] - Called with the rejection reason if the
|
|
17
|
+
* object fails to resolve (e.g. it could never be delivered). Only used
|
|
18
|
+
* together with `callback`.
|
|
16
19
|
* @returns {any}
|
|
17
20
|
*/
|
|
18
|
-
get(objId: string, callback?: Function): any;
|
|
21
|
+
get(objId: string, callback?: Function, errorCallback?: Function): any;
|
|
19
22
|
/**
|
|
20
23
|
* @param {string} objId
|
|
21
24
|
* @returns {boolean}
|
|
@@ -32,6 +35,12 @@ export class PDFObjects {
|
|
|
32
35
|
* @param {any} [data]
|
|
33
36
|
*/
|
|
34
37
|
resolve(objId: string, data?: any): void;
|
|
38
|
+
/**
|
|
39
|
+
* Rejects the object `objId`, signalling that it will never be resolved.
|
|
40
|
+
* @param {string} objId
|
|
41
|
+
* @param {Error} reason
|
|
42
|
+
*/
|
|
43
|
+
reject(objId: string, reason: Error): void;
|
|
35
44
|
clear(): void;
|
|
36
45
|
[Symbol.iterator](): Generator<any[], void, unknown>;
|
|
37
46
|
#private;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export type RendererWorkerParameters = {
|
|
2
|
+
/**
|
|
3
|
+
* - Caller-owned worker; never terminated here.
|
|
4
|
+
*/
|
|
5
|
+
port?: Worker | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* - Logging level from {@link VerbosityLevel}.
|
|
8
|
+
*/
|
|
9
|
+
verbosity?: number | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* - Allow hardware acceleration.
|
|
12
|
+
*/
|
|
13
|
+
enableHWA?: boolean | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* - Initialize WebGPU.
|
|
16
|
+
*/
|
|
17
|
+
enableWebGPU?: boolean | undefined;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {object} RendererWorkerParameters
|
|
21
|
+
* @property {Worker} [port] - Caller-owned worker; never terminated here.
|
|
22
|
+
* @property {number} [verbosity] - Logging level from {@link VerbosityLevel}.
|
|
23
|
+
* @property {boolean} [enableHWA] - Allow hardware acceleration.
|
|
24
|
+
* @property {boolean} [enableWebGPU] - Initialize WebGPU.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Manages a document's renderer worker and render tasks.
|
|
28
|
+
* @param {RendererWorkerParameters} params
|
|
29
|
+
*/
|
|
30
|
+
export class RendererWorker {
|
|
31
|
+
static #connectionId: number;
|
|
32
|
+
static #usedPorts: WeakSet<object>;
|
|
33
|
+
/**
|
|
34
|
+
* Whether worker rendering is configured and browser prerequisites are met.
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
*/
|
|
37
|
+
static get isAvailable(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* @param {object} params
|
|
40
|
+
* @param {Array<Worker>} [params.ports] - Supplied workers; selects the first
|
|
41
|
+
* unused one.
|
|
42
|
+
* @param {number} [params.verbosity] - Logging level.
|
|
43
|
+
* @param {boolean} [params.enableHWA] - Allow hardware acceleration.
|
|
44
|
+
* @param {boolean} [params.enableWebGPU] - Initialize WebGPU.
|
|
45
|
+
* @returns {RendererWorker}
|
|
46
|
+
*/
|
|
47
|
+
static create({ ports, ...params }?: {
|
|
48
|
+
ports?: Worker[] | undefined;
|
|
49
|
+
verbosity?: number | undefined;
|
|
50
|
+
enableHWA?: boolean | undefined;
|
|
51
|
+
enableWebGPU?: boolean | undefined;
|
|
52
|
+
}): RendererWorker;
|
|
53
|
+
constructor({ port, verbosity, enableHWA, enableWebGPU, }?: {
|
|
54
|
+
port?: null | undefined;
|
|
55
|
+
verbosity?: number | undefined;
|
|
56
|
+
enableHWA?: boolean | undefined;
|
|
57
|
+
enableWebGPU?: boolean | undefined;
|
|
58
|
+
});
|
|
59
|
+
destroyed: boolean;
|
|
60
|
+
verbosity: number;
|
|
61
|
+
/**
|
|
62
|
+
* Resolves when ready; rejects on failed or aborted startup.
|
|
63
|
+
* @type {Promise<void>}
|
|
64
|
+
*/
|
|
65
|
+
get promise(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* The worker's message handler, or null.
|
|
68
|
+
* @type {MessageHandler | null}
|
|
69
|
+
*/
|
|
70
|
+
get messageHandler(): MessageHandler | null;
|
|
71
|
+
/**
|
|
72
|
+
* The supplied renderer worker, or `null`.
|
|
73
|
+
* @type {Worker | null}
|
|
74
|
+
*/
|
|
75
|
+
get port(): Worker | null;
|
|
76
|
+
destroy(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Send a request that rejects on worker destruction.
|
|
79
|
+
* @returns {Promise<any>}
|
|
80
|
+
*/
|
|
81
|
+
sendWithPromise(action: any, data: any): Promise<any>;
|
|
82
|
+
sendCommonObj(id: any, type: any, data: any): void;
|
|
83
|
+
sendObj(id: any, pageProxyId: any, type: any, data: any): void;
|
|
84
|
+
cleanup(keepLoadedFonts: any): void;
|
|
85
|
+
cleanupPage(pageProxyId: any): void;
|
|
86
|
+
/**
|
|
87
|
+
* @returns {WorkerRenderTask | null} Null to use main-thread rendering.
|
|
88
|
+
*/
|
|
89
|
+
createRenderTask({ pageProxyId, operatorList, params, pageColors, canvasFactory, annotationCanvasMap, onFrame, onError, }: {
|
|
90
|
+
pageProxyId: any;
|
|
91
|
+
operatorList: any;
|
|
92
|
+
params: any;
|
|
93
|
+
pageColors: any;
|
|
94
|
+
canvasFactory: any;
|
|
95
|
+
annotationCanvasMap: any;
|
|
96
|
+
onFrame: any;
|
|
97
|
+
onError: any;
|
|
98
|
+
}): WorkerRenderTask | null;
|
|
99
|
+
#private;
|
|
100
|
+
}
|
|
101
|
+
import { MessageHandler } from "../shared/message_handler.js";
|
|
102
|
+
/**
|
|
103
|
+
* Renders through the worker and draws returned frames.
|
|
104
|
+
*/
|
|
105
|
+
declare class WorkerRenderTask {
|
|
106
|
+
constructor({ rendererWorker, renderTasks, canvas, canvasFactory, annotationCanvasMap, operatorListState, initParams, onFrame, onError, }: {
|
|
107
|
+
rendererWorker: any;
|
|
108
|
+
renderTasks: any;
|
|
109
|
+
canvas: any;
|
|
110
|
+
canvasFactory: any;
|
|
111
|
+
annotationCanvasMap: any;
|
|
112
|
+
operatorListState: any;
|
|
113
|
+
initParams: any;
|
|
114
|
+
onFrame: any;
|
|
115
|
+
onError: any;
|
|
116
|
+
});
|
|
117
|
+
imageCoordinates: null;
|
|
118
|
+
recordedBBoxes: null;
|
|
119
|
+
/**
|
|
120
|
+
* @returns {Promise<boolean>} False to use main-thread rendering.
|
|
121
|
+
*/
|
|
122
|
+
initialize(transparency: any, optionalContentConfig: any): Promise<boolean>;
|
|
123
|
+
/**
|
|
124
|
+
* @returns {Promise<number>} The next operator index.
|
|
125
|
+
*/
|
|
126
|
+
executeOperatorList(operatorList: any, operatorListIdx: any, operationsFilter: any): Promise<number>;
|
|
127
|
+
cancel(): void;
|
|
128
|
+
drawFrame(frame: any): void;
|
|
129
|
+
#private;
|
|
130
|
+
}
|
|
131
|
+
export {};
|
|
@@ -30,11 +30,6 @@ export type TextLayerUpdateParameters = {
|
|
|
30
30
|
* the text runs.
|
|
31
31
|
*/
|
|
32
32
|
viewport: PageViewport;
|
|
33
|
-
/**
|
|
34
|
-
* - Callback invoked before the textLayer is
|
|
35
|
-
* updated in the DOM.
|
|
36
|
-
*/
|
|
37
|
-
onBefore?: Function | undefined;
|
|
38
33
|
};
|
|
39
34
|
export const DEFAULT_FONT_SIZE: 30;
|
|
40
35
|
export class TextLayer {
|
|
@@ -71,7 +66,7 @@ export class TextLayer {
|
|
|
71
66
|
* @param {TextLayerUpdateParameters} options
|
|
72
67
|
* @returns {undefined}
|
|
73
68
|
*/
|
|
74
|
-
update({ viewport
|
|
69
|
+
update({ viewport }: TextLayerUpdateParameters): undefined;
|
|
75
70
|
/**
|
|
76
71
|
* Cancel rendering of the textLayer.
|
|
77
72
|
* @returns {undefined}
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
export class GlobalWorkerOptions {
|
|
2
2
|
static #port: null;
|
|
3
|
+
static #rendererPorts: any[];
|
|
4
|
+
static #rendererSrc: string;
|
|
3
5
|
static #src: string;
|
|
6
|
+
/**
|
|
7
|
+
* @param {Array<Worker>} val - Caller-owned workers, one document per worker.
|
|
8
|
+
* Uses `rendererSrc` when no supplied worker is available.
|
|
9
|
+
*/
|
|
10
|
+
static set rendererPorts(val: Array<Worker>);
|
|
11
|
+
/**
|
|
12
|
+
* @type {Array<Worker>}
|
|
13
|
+
*/
|
|
14
|
+
static get rendererPorts(): Array<Worker>;
|
|
15
|
+
/**
|
|
16
|
+
* @param {string} val - A string containing the path and
|
|
17
|
+
* filename of the renderer worker file.
|
|
18
|
+
*
|
|
19
|
+
* NOTE: The `rendererSrc` option must be set in order to render pages in a
|
|
20
|
+
* worker thread, unless `rendererPorts` contains an unused worker;
|
|
21
|
+
* otherwise, rendering falls back to the main-thread.
|
|
22
|
+
*/
|
|
23
|
+
static set rendererSrc(val: string);
|
|
24
|
+
/**
|
|
25
|
+
* @type {string}
|
|
26
|
+
*/
|
|
27
|
+
static get rendererSrc(): string;
|
|
4
28
|
/**
|
|
5
29
|
* @param {Worker | null} val - Defines global port for worker process.
|
|
6
30
|
* Overrides the `workerSrc` option.
|
package/dist/types/src/pdf.d.ts
CHANGED
|
@@ -16,48 +16,48 @@ import { applyOpacity } from "./display/display_utils.js";
|
|
|
16
16
|
import { build } from "./display/api.js";
|
|
17
17
|
import { ColorPicker } from "./display/editor/color_picker.js";
|
|
18
18
|
import { createValidAbsoluteUrl } from "./shared/util.js";
|
|
19
|
-
import { CSSConstants } from "./display/
|
|
19
|
+
import { CSSConstants } from "./display/dom_utils.js";
|
|
20
20
|
import { DOMSVGFactory } from "./display/svg_factory.js";
|
|
21
21
|
import { DrawLayer } from "./display/draw_layer.js";
|
|
22
22
|
import { FeatureTest } from "./shared/util.js";
|
|
23
|
-
import { fetchData } from "./display/
|
|
23
|
+
import { fetchData } from "./display/dom_utils.js";
|
|
24
24
|
import { findContrastColor } from "./display/display_utils.js";
|
|
25
25
|
import { getDocument } from "./display/api.js";
|
|
26
|
-
import { getFilenameFromUrl } from "./display/
|
|
27
|
-
import { getPdfFilenameFromUrl } from "./display/
|
|
26
|
+
import { getFilenameFromUrl } from "./display/dom_utils.js";
|
|
27
|
+
import { getPdfFilenameFromUrl } from "./display/dom_utils.js";
|
|
28
28
|
import { getRGB } from "./display/display_utils.js";
|
|
29
29
|
import { getRGBA } from "./display/display_utils.js";
|
|
30
30
|
import { getUuid } from "./shared/util.js";
|
|
31
31
|
import { GlobalWorkerOptions } from "./display/worker_options.js";
|
|
32
32
|
import { ImageKind } from "./shared/util.js";
|
|
33
33
|
import { InvalidPDFException } from "./shared/util.js";
|
|
34
|
-
import { isDataScheme } from "./display/
|
|
35
|
-
import { isPdfFile } from "./display/
|
|
34
|
+
import { isDataScheme } from "./display/dom_utils.js";
|
|
35
|
+
import { isPdfFile } from "./display/dom_utils.js";
|
|
36
36
|
import { isValidExplicitDest } from "./display/api_utils.js";
|
|
37
37
|
import { makeArr } from "./shared/util.js";
|
|
38
38
|
import { makeMap } from "./shared/util.js";
|
|
39
39
|
import { makeObj } from "./shared/util.js";
|
|
40
40
|
import { makeSet } from "./shared/util.js";
|
|
41
41
|
import { MathClamp } from "./shared/math_clamp.js";
|
|
42
|
-
import { noContextMenu } from "./display/
|
|
42
|
+
import { noContextMenu } from "./display/dom_utils.js";
|
|
43
43
|
import { normalizeUnicode } from "./shared/util.js";
|
|
44
44
|
import { OPS } from "./shared/util.js";
|
|
45
45
|
import { OutputScale } from "./display/display_utils.js";
|
|
46
46
|
import { PasswordException } from "./shared/util.js";
|
|
47
47
|
import { PasswordResponses } from "./shared/util.js";
|
|
48
48
|
import { PDFDataRangeTransport } from "./display/api.js";
|
|
49
|
-
import { PDFDateString } from "./display/
|
|
49
|
+
import { PDFDateString } from "./display/dom_utils.js";
|
|
50
50
|
import { PDFWorker } from "./display/api.js";
|
|
51
51
|
import { PermissionFlag } from "./shared/util.js";
|
|
52
52
|
import { PixelsPerInch } from "./display/display_utils.js";
|
|
53
53
|
import { RenderingCancelledException } from "./display/display_utils.js";
|
|
54
|
-
import { renderRichText } from "./display/
|
|
54
|
+
import { renderRichText } from "./display/dom_utils.js";
|
|
55
55
|
import { ResponseException } from "./shared/util.js";
|
|
56
|
-
import { setLayerDimensions } from "./display/
|
|
56
|
+
import { setLayerDimensions } from "./display/dom_utils.js";
|
|
57
57
|
import { shadow } from "./shared/util.js";
|
|
58
58
|
import { SignatureExtractor } from "./display/editor/drawers/signaturedraw.js";
|
|
59
|
-
import { stopEvent } from "./display/
|
|
60
|
-
import { SupportedImageMimeTypes } from "./display/
|
|
59
|
+
import { stopEvent } from "./display/dom_utils.js";
|
|
60
|
+
import { SupportedImageMimeTypes } from "./display/dom_utils.js";
|
|
61
61
|
import { TextLayer } from "./display/text_layer.js";
|
|
62
62
|
import { TextLayerImages } from "./display/text_layer_images.js";
|
|
63
63
|
import { TouchManager } from "./display/touch_manager.js";
|
|
@@ -29,6 +29,7 @@ export class MessageHandler {
|
|
|
29
29
|
*/
|
|
30
30
|
sendWithStream(actionName: string, data: JSON, queueingStrategy: object, transfers?: any[]): ReadableStream;
|
|
31
31
|
destroy(): void;
|
|
32
|
+
get destroyed(): boolean;
|
|
32
33
|
#private;
|
|
33
34
|
}
|
|
34
35
|
export function wrapReason(ex: any): PasswordException | UnknownErrorException | InvalidPDFException | ResponseException | AbortException;
|
|
@@ -162,6 +162,8 @@ export function bytesToString(bytes: any): string;
|
|
|
162
162
|
* @returns {URL | null} Either a valid {@link URL}, or `null` otherwise.
|
|
163
163
|
*/
|
|
164
164
|
export function createValidAbsoluteUrl(url: URL | string, baseUrl?: URL | string, options?: object): URL | null;
|
|
165
|
+
export const DEFAULT_VERTICAL_ADVANCE: 1000;
|
|
166
|
+
export const DEFAULT_VERTICAL_ORIGIN_Y: 880;
|
|
165
167
|
export namespace DocumentActionEventType {
|
|
166
168
|
let WC: string;
|
|
167
169
|
let WS: string;
|
|
@@ -181,6 +183,7 @@ export class FeatureTest {
|
|
|
181
183
|
static get isLittleEndian(): any;
|
|
182
184
|
static get isOffscreenCanvasSupported(): any;
|
|
183
185
|
static get isImageDecoderSupported(): any;
|
|
186
|
+
static get isVideoFrameSupported(): any;
|
|
184
187
|
static get isFloat16ArraySupported(): any;
|
|
185
188
|
static get isSanitizerSupported(): any;
|
|
186
189
|
static get platform(): any;
|
|
@@ -408,6 +411,7 @@ export function utf8StringToString(str: any): string;
|
|
|
408
411
|
export class Util {
|
|
409
412
|
static get hexNums(): any;
|
|
410
413
|
static makeHexColor(r: any, g: any, b: any): string;
|
|
414
|
+
static get identity0to256Map(): any;
|
|
411
415
|
static transform(m1: any, m2: any): any[];
|
|
412
416
|
static multiplyByDOMMatrix(m: any, md: any): any[];
|
|
413
417
|
static applyTransform(p: any, m: any, pos?: number): void;
|
|
@@ -102,6 +102,7 @@ export class AnnotationLayerBuilder {
|
|
|
102
102
|
* are added to the annotation layer.
|
|
103
103
|
*/
|
|
104
104
|
injectLinkAnnotations(inferredLinks: Array<object>): Promise<void>;
|
|
105
|
+
get linksInjected(): boolean;
|
|
105
106
|
#private;
|
|
106
107
|
}
|
|
107
108
|
import { AnnotationLayer } from "../src/pdf.js";
|
|
@@ -12,8 +12,8 @@ export class Autolinker {
|
|
|
12
12
|
rect: any;
|
|
13
13
|
quadPoints?: undefined;
|
|
14
14
|
id: string;
|
|
15
|
-
unsafeUrl:
|
|
16
|
-
url:
|
|
15
|
+
unsafeUrl: string;
|
|
16
|
+
url: string;
|
|
17
17
|
annotationType: number;
|
|
18
18
|
rotation: number;
|
|
19
19
|
} | {
|
|
@@ -21,8 +21,8 @@ export class Autolinker {
|
|
|
21
21
|
quadPoints: any[];
|
|
22
22
|
rect: number[];
|
|
23
23
|
id: string;
|
|
24
|
-
unsafeUrl:
|
|
25
|
-
url:
|
|
24
|
+
unsafeUrl: string;
|
|
25
|
+
url: string;
|
|
26
26
|
annotationType: number;
|
|
27
27
|
rotation: number;
|
|
28
28
|
})[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export class BaseDownloadManager {
|
|
2
|
-
_triggerDownload(blobUrl: any, originalUrl: any, filename: any, isAttachment?: boolean): void;
|
|
2
|
+
_triggerDownload(blobUrl: any, originalUrl: any, filename: any, isAttachment?: boolean, isModified?: boolean): void;
|
|
3
3
|
_getOpenDataUrl(blobUrl: any, filename: any, dest?: null): void;
|
|
4
4
|
/**
|
|
5
5
|
* @param {Uint8Array} data
|
|
@@ -18,7 +18,8 @@ export class BaseDownloadManager {
|
|
|
18
18
|
* @param {Uint8Array} data
|
|
19
19
|
* @param {string} url
|
|
20
20
|
* @param {string} filename
|
|
21
|
+
* @param {boolean} [isModified] - Whether to report the PDF as modified.
|
|
21
22
|
*/
|
|
22
|
-
download(data: Uint8Array, url: string, filename: string): void;
|
|
23
|
+
download(data: Uint8Array, url: string, filename: string, isModified?: boolean): void;
|
|
23
24
|
#private;
|
|
24
25
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export class DownloadManager extends BaseDownloadManager {
|
|
2
|
+
_triggerDownload(blobUrl: any, originalUrl: any, filename: any, isAttachment?: boolean): void;
|
|
2
3
|
_getOpenDataUrl(blobUrl: any, filename: any, dest?: null): string;
|
|
3
4
|
}
|
|
4
5
|
import { BaseDownloadManager } from "./base_download_manager.js";
|