@embedpdf/models 1.0.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/LICENSE +21 -0
- package/README.md +67 -0
- package/dist/index.cjs +947 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2208 -0
- package/dist/index.d.ts +2208 -0
- package/dist/index.js +869 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,947 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
AllLogger: () => AllLogger,
|
|
24
|
+
AppearanceMode: () => AppearanceMode,
|
|
25
|
+
ConsoleLogger: () => ConsoleLogger,
|
|
26
|
+
LevelLogger: () => LevelLogger,
|
|
27
|
+
LogLevel: () => LogLevel,
|
|
28
|
+
MatchFlag: () => MatchFlag,
|
|
29
|
+
NoopLogger: () => NoopLogger,
|
|
30
|
+
PDF_FORM_FIELD_FLAG: () => PDF_FORM_FIELD_FLAG,
|
|
31
|
+
PDF_FORM_FIELD_TYPE: () => PDF_FORM_FIELD_TYPE,
|
|
32
|
+
PdfActionType: () => PdfActionType,
|
|
33
|
+
PdfAnnotationObjectStatus: () => PdfAnnotationObjectStatus,
|
|
34
|
+
PdfAnnotationState: () => PdfAnnotationState,
|
|
35
|
+
PdfAnnotationStateModel: () => PdfAnnotationStateModel,
|
|
36
|
+
PdfAnnotationSubtype: () => PdfAnnotationSubtype,
|
|
37
|
+
PdfAnnotationSubtypeName: () => PdfAnnotationSubtypeName,
|
|
38
|
+
PdfEngineFeature: () => PdfEngineFeature,
|
|
39
|
+
PdfEngineOperation: () => PdfEngineOperation,
|
|
40
|
+
PdfErrorCode: () => PdfErrorCode,
|
|
41
|
+
PdfPageFlattenFlag: () => PdfPageFlattenFlag,
|
|
42
|
+
PdfPageFlattenResult: () => PdfPageFlattenResult,
|
|
43
|
+
PdfPageObjectType: () => PdfPageObjectType,
|
|
44
|
+
PdfPermission: () => PdfPermission,
|
|
45
|
+
PdfSegmentObjectType: () => PdfSegmentObjectType,
|
|
46
|
+
PdfTaskHelper: () => PdfTaskHelper,
|
|
47
|
+
PdfZoomMode: () => PdfZoomMode,
|
|
48
|
+
PerfLogger: () => PerfLogger,
|
|
49
|
+
Rotation: () => Rotation,
|
|
50
|
+
Task: () => Task,
|
|
51
|
+
TaskAbortedError: () => TaskAbortedError,
|
|
52
|
+
TaskRejectedError: () => TaskRejectedError,
|
|
53
|
+
TaskStage: () => TaskStage,
|
|
54
|
+
boundingRect: () => boundingRect,
|
|
55
|
+
calculateAngle: () => calculateAngle,
|
|
56
|
+
calculateDegree: () => calculateDegree,
|
|
57
|
+
compareSearchTarget: () => compareSearchTarget,
|
|
58
|
+
ignore: () => ignore,
|
|
59
|
+
quadToRect: () => quadToRect,
|
|
60
|
+
restoreOffset: () => restoreOffset,
|
|
61
|
+
restorePosition: () => restorePosition,
|
|
62
|
+
restoreRect: () => restoreRect,
|
|
63
|
+
rotatePosition: () => rotatePosition,
|
|
64
|
+
rotateRect: () => rotateRect,
|
|
65
|
+
scalePosition: () => scalePosition,
|
|
66
|
+
scaleRect: () => scaleRect,
|
|
67
|
+
swap: () => swap,
|
|
68
|
+
toIntPos: () => toIntPos,
|
|
69
|
+
toIntRect: () => toIntRect,
|
|
70
|
+
toIntSize: () => toIntSize,
|
|
71
|
+
transformPosition: () => transformPosition,
|
|
72
|
+
transformRect: () => transformRect,
|
|
73
|
+
transformSize: () => transformSize,
|
|
74
|
+
unionFlags: () => unionFlags
|
|
75
|
+
});
|
|
76
|
+
module.exports = __toCommonJS(index_exports);
|
|
77
|
+
|
|
78
|
+
// src/geometry.ts
|
|
79
|
+
var Rotation = /* @__PURE__ */ ((Rotation2) => {
|
|
80
|
+
Rotation2[Rotation2["Degree0"] = 0] = "Degree0";
|
|
81
|
+
Rotation2[Rotation2["Degree90"] = 1] = "Degree90";
|
|
82
|
+
Rotation2[Rotation2["Degree180"] = 2] = "Degree180";
|
|
83
|
+
Rotation2[Rotation2["Degree270"] = 3] = "Degree270";
|
|
84
|
+
return Rotation2;
|
|
85
|
+
})(Rotation || {});
|
|
86
|
+
function toIntPos(p) {
|
|
87
|
+
return { x: Math.floor(p.x), y: Math.floor(p.y) };
|
|
88
|
+
}
|
|
89
|
+
function toIntSize(s) {
|
|
90
|
+
return { width: Math.ceil(s.width), height: Math.ceil(s.height) };
|
|
91
|
+
}
|
|
92
|
+
function toIntRect(r) {
|
|
93
|
+
return {
|
|
94
|
+
origin: toIntPos(r.origin),
|
|
95
|
+
size: toIntSize(r.size)
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function calculateDegree(rotation) {
|
|
99
|
+
switch (rotation) {
|
|
100
|
+
case 0 /* Degree0 */:
|
|
101
|
+
return 0;
|
|
102
|
+
case 1 /* Degree90 */:
|
|
103
|
+
return 90;
|
|
104
|
+
case 2 /* Degree180 */:
|
|
105
|
+
return 180;
|
|
106
|
+
case 3 /* Degree270 */:
|
|
107
|
+
return 270;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function calculateAngle(rotation) {
|
|
111
|
+
return calculateDegree(rotation) * Math.PI / 180;
|
|
112
|
+
}
|
|
113
|
+
function swap(size) {
|
|
114
|
+
const { width, height } = size;
|
|
115
|
+
return {
|
|
116
|
+
width: height,
|
|
117
|
+
height: width
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function transformSize(size, rotation, scaleFactor) {
|
|
121
|
+
size = rotation % 2 === 0 ? size : swap(size);
|
|
122
|
+
return {
|
|
123
|
+
width: size.width * scaleFactor,
|
|
124
|
+
height: size.height * scaleFactor
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function quadToRect(q) {
|
|
128
|
+
const xs = [q.p1.x, q.p2.x, q.p3.x, q.p4.x];
|
|
129
|
+
const ys = [q.p1.y, q.p2.y, q.p3.y, q.p4.y];
|
|
130
|
+
return {
|
|
131
|
+
origin: { x: Math.min(...xs), y: Math.min(...ys) },
|
|
132
|
+
size: {
|
|
133
|
+
width: Math.max(...xs) - Math.min(...xs),
|
|
134
|
+
height: Math.max(...ys) - Math.min(...ys)
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function rotatePosition(containerSize, position, rotation) {
|
|
139
|
+
let x = position.x;
|
|
140
|
+
let y = position.y;
|
|
141
|
+
switch (rotation) {
|
|
142
|
+
case 0 /* Degree0 */:
|
|
143
|
+
x = position.x;
|
|
144
|
+
y = position.y;
|
|
145
|
+
break;
|
|
146
|
+
case 1 /* Degree90 */:
|
|
147
|
+
x = containerSize.height - position.y;
|
|
148
|
+
y = position.x;
|
|
149
|
+
break;
|
|
150
|
+
case 2 /* Degree180 */:
|
|
151
|
+
x = containerSize.width - position.x;
|
|
152
|
+
y = containerSize.height - position.y;
|
|
153
|
+
break;
|
|
154
|
+
case 3 /* Degree270 */:
|
|
155
|
+
x = position.y;
|
|
156
|
+
y = containerSize.width - position.x;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
x,
|
|
161
|
+
y
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function scalePosition(position, scaleFactor) {
|
|
165
|
+
return {
|
|
166
|
+
x: position.x * scaleFactor,
|
|
167
|
+
y: position.y * scaleFactor
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function transformPosition(containerSize, position, rotation, scaleFactor) {
|
|
171
|
+
return scalePosition(rotatePosition(containerSize, position, rotation), scaleFactor);
|
|
172
|
+
}
|
|
173
|
+
function restorePosition(containerSize, position, rotation, scaleFactor) {
|
|
174
|
+
return scalePosition(
|
|
175
|
+
rotatePosition(containerSize, position, (4 - rotation) % 4),
|
|
176
|
+
1 / scaleFactor
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
function rotateRect(containerSize, rect, rotation) {
|
|
180
|
+
let x = rect.origin.x;
|
|
181
|
+
let y = rect.origin.y;
|
|
182
|
+
let size = rect.size;
|
|
183
|
+
switch (rotation) {
|
|
184
|
+
case 0 /* Degree0 */:
|
|
185
|
+
break;
|
|
186
|
+
case 1 /* Degree90 */:
|
|
187
|
+
x = containerSize.height - rect.origin.y - rect.size.height;
|
|
188
|
+
y = rect.origin.x;
|
|
189
|
+
size = swap(rect.size);
|
|
190
|
+
break;
|
|
191
|
+
case 2 /* Degree180 */:
|
|
192
|
+
x = containerSize.width - rect.origin.x - rect.size.width;
|
|
193
|
+
y = containerSize.height - rect.origin.y - rect.size.height;
|
|
194
|
+
break;
|
|
195
|
+
case 3 /* Degree270 */:
|
|
196
|
+
x = rect.origin.y;
|
|
197
|
+
y = containerSize.width - rect.origin.x - rect.size.width;
|
|
198
|
+
size = swap(rect.size);
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
origin: {
|
|
203
|
+
x,
|
|
204
|
+
y
|
|
205
|
+
},
|
|
206
|
+
size: {
|
|
207
|
+
width: size.width,
|
|
208
|
+
height: size.height
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function scaleRect(rect, scaleFactor) {
|
|
213
|
+
return {
|
|
214
|
+
origin: {
|
|
215
|
+
x: rect.origin.x * scaleFactor,
|
|
216
|
+
y: rect.origin.y * scaleFactor
|
|
217
|
+
},
|
|
218
|
+
size: {
|
|
219
|
+
width: rect.size.width * scaleFactor,
|
|
220
|
+
height: rect.size.height * scaleFactor
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function transformRect(containerSize, rect, rotation, scaleFactor) {
|
|
225
|
+
return scaleRect(rotateRect(containerSize, rect, rotation), scaleFactor);
|
|
226
|
+
}
|
|
227
|
+
function restoreRect(containerSize, rect, rotation, scaleFactor) {
|
|
228
|
+
return scaleRect(rotateRect(containerSize, rect, (4 - rotation) % 4), 1 / scaleFactor);
|
|
229
|
+
}
|
|
230
|
+
function restoreOffset(offset, rotation, scaleFactor) {
|
|
231
|
+
let offsetX = offset.x;
|
|
232
|
+
let offsetY = offset.y;
|
|
233
|
+
switch (rotation) {
|
|
234
|
+
case 0 /* Degree0 */:
|
|
235
|
+
offsetX = offset.x / scaleFactor;
|
|
236
|
+
offsetY = offset.y / scaleFactor;
|
|
237
|
+
break;
|
|
238
|
+
case 1 /* Degree90 */:
|
|
239
|
+
offsetX = offset.y / scaleFactor;
|
|
240
|
+
offsetY = -offset.x / scaleFactor;
|
|
241
|
+
break;
|
|
242
|
+
case 2 /* Degree180 */:
|
|
243
|
+
offsetX = -offset.x / scaleFactor;
|
|
244
|
+
offsetY = -offset.y / scaleFactor;
|
|
245
|
+
break;
|
|
246
|
+
case 3 /* Degree270 */:
|
|
247
|
+
offsetX = -offset.y / scaleFactor;
|
|
248
|
+
offsetY = offset.x / scaleFactor;
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
x: offsetX,
|
|
253
|
+
y: offsetY
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
function boundingRect(rects) {
|
|
257
|
+
if (rects.length === 0) return null;
|
|
258
|
+
let minX = rects[0].origin.x, minY = rects[0].origin.y, maxX = rects[0].origin.x + rects[0].size.width, maxY = rects[0].origin.y + rects[0].size.height;
|
|
259
|
+
for (const r of rects) {
|
|
260
|
+
minX = Math.min(minX, r.origin.x);
|
|
261
|
+
minY = Math.min(minY, r.origin.y);
|
|
262
|
+
maxX = Math.max(maxX, r.origin.x + r.size.width);
|
|
263
|
+
maxY = Math.max(maxY, r.origin.y + r.size.height);
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
origin: {
|
|
267
|
+
x: minX,
|
|
268
|
+
y: minY
|
|
269
|
+
},
|
|
270
|
+
size: {
|
|
271
|
+
width: maxX - minX,
|
|
272
|
+
height: maxY - minY
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// src/logger.ts
|
|
278
|
+
var NoopLogger = class {
|
|
279
|
+
/** {@inheritDoc Logger.debug} */
|
|
280
|
+
debug() {
|
|
281
|
+
}
|
|
282
|
+
/** {@inheritDoc Logger.info} */
|
|
283
|
+
info() {
|
|
284
|
+
}
|
|
285
|
+
/** {@inheritDoc Logger.warn} */
|
|
286
|
+
warn() {
|
|
287
|
+
}
|
|
288
|
+
/** {@inheritDoc Logger.error} */
|
|
289
|
+
error() {
|
|
290
|
+
}
|
|
291
|
+
/** {@inheritDoc Logger.perf} */
|
|
292
|
+
perf() {
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
var ConsoleLogger = class {
|
|
296
|
+
/** {@inheritDoc Logger.debug} */
|
|
297
|
+
debug(source, category, ...args) {
|
|
298
|
+
console.debug(`${source}.${category}`, ...args);
|
|
299
|
+
}
|
|
300
|
+
/** {@inheritDoc Logger.info} */
|
|
301
|
+
info(source, category, ...args) {
|
|
302
|
+
console.info(`${source}.${category}`, ...args);
|
|
303
|
+
}
|
|
304
|
+
/** {@inheritDoc Logger.warn} */
|
|
305
|
+
warn(source, category, ...args) {
|
|
306
|
+
console.warn(`${source}.${category}`, ...args);
|
|
307
|
+
}
|
|
308
|
+
/** {@inheritDoc Logger.error} */
|
|
309
|
+
error(source, category, ...args) {
|
|
310
|
+
console.error(`${source}.${category}`, ...args);
|
|
311
|
+
}
|
|
312
|
+
/** {@inheritDoc Logger.perf} */
|
|
313
|
+
perf(source, category, event, phase, ...args) {
|
|
314
|
+
console.info(`${source}.${category}.${event}.${phase}`, ...args);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
318
|
+
LogLevel2[LogLevel2["Debug"] = 0] = "Debug";
|
|
319
|
+
LogLevel2[LogLevel2["Info"] = 1] = "Info";
|
|
320
|
+
LogLevel2[LogLevel2["Warn"] = 2] = "Warn";
|
|
321
|
+
LogLevel2[LogLevel2["Error"] = 3] = "Error";
|
|
322
|
+
return LogLevel2;
|
|
323
|
+
})(LogLevel || {});
|
|
324
|
+
var LevelLogger = class {
|
|
325
|
+
/**
|
|
326
|
+
* create new LevelLogger
|
|
327
|
+
* @param logger - the original logger
|
|
328
|
+
* @param level - log level that used for filtering, all logs lower than this level will be filtered out
|
|
329
|
+
*/
|
|
330
|
+
constructor(logger, level) {
|
|
331
|
+
this.logger = logger;
|
|
332
|
+
this.level = level;
|
|
333
|
+
}
|
|
334
|
+
/** {@inheritDoc Logger.debug} */
|
|
335
|
+
debug(source, category, ...args) {
|
|
336
|
+
if (this.level <= 0 /* Debug */) {
|
|
337
|
+
this.logger.debug(source, category, ...args);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/** {@inheritDoc Logger.info} */
|
|
341
|
+
info(source, category, ...args) {
|
|
342
|
+
if (this.level <= 1 /* Info */) {
|
|
343
|
+
this.logger.info(source, category, ...args);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/** {@inheritDoc Logger.warn} */
|
|
347
|
+
warn(source, category, ...args) {
|
|
348
|
+
if (this.level <= 2 /* Warn */) {
|
|
349
|
+
this.logger.warn(source, category, ...args);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
/** {@inheritDoc Logger.error} */
|
|
353
|
+
error(source, category, ...args) {
|
|
354
|
+
if (this.level <= 3 /* Error */) {
|
|
355
|
+
this.logger.error(source, category, ...args);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
/** {@inheritDoc Logger.perf} */
|
|
359
|
+
perf(source, category, event, phase, ...args) {
|
|
360
|
+
this.logger.perf(source, category, event, phase, ...args);
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
var PerfLogger = class {
|
|
364
|
+
/**
|
|
365
|
+
* create new PerfLogger
|
|
366
|
+
*/
|
|
367
|
+
constructor() {
|
|
368
|
+
}
|
|
369
|
+
/** {@inheritDoc Logger.debug} */
|
|
370
|
+
debug(source, category, ...args) {
|
|
371
|
+
}
|
|
372
|
+
/** {@inheritDoc Logger.info} */
|
|
373
|
+
info(source, category, ...args) {
|
|
374
|
+
}
|
|
375
|
+
/** {@inheritDoc Logger.warn} */
|
|
376
|
+
warn(source, category, ...args) {
|
|
377
|
+
}
|
|
378
|
+
/** {@inheritDoc Logger.error} */
|
|
379
|
+
error(source, category, ...args) {
|
|
380
|
+
}
|
|
381
|
+
/** {@inheritDoc Logger.perf} */
|
|
382
|
+
perf(source, category, event, phase, identifier, ...args) {
|
|
383
|
+
switch (phase) {
|
|
384
|
+
case "Begin":
|
|
385
|
+
window.performance.mark(`${source}.${category}.${event}.${phase}.${identifier}`, {
|
|
386
|
+
detail: args
|
|
387
|
+
});
|
|
388
|
+
break;
|
|
389
|
+
case "End":
|
|
390
|
+
window.performance.mark(`${source}.${category}.${event}.${phase}.${identifier}`, {
|
|
391
|
+
detail: args
|
|
392
|
+
});
|
|
393
|
+
window.performance.measure(
|
|
394
|
+
`${source}.${category}.${event}.Measure.${identifier}`,
|
|
395
|
+
`${source}.${category}.${event}.Begin.${identifier}`,
|
|
396
|
+
`${source}.${category}.${event}.End.${identifier}`
|
|
397
|
+
);
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
var AllLogger = class {
|
|
403
|
+
/**
|
|
404
|
+
* create new PerfLogger
|
|
405
|
+
*/
|
|
406
|
+
constructor(loggers) {
|
|
407
|
+
this.loggers = loggers;
|
|
408
|
+
}
|
|
409
|
+
/** {@inheritDoc Logger.debug} */
|
|
410
|
+
debug(source, category, ...args) {
|
|
411
|
+
for (const logger of this.loggers) {
|
|
412
|
+
logger.debug(source, category, ...args);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
/** {@inheritDoc Logger.info} */
|
|
416
|
+
info(source, category, ...args) {
|
|
417
|
+
for (const logger of this.loggers) {
|
|
418
|
+
logger.info(source, category, ...args);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
/** {@inheritDoc Logger.warn} */
|
|
422
|
+
warn(source, category, ...args) {
|
|
423
|
+
for (const logger of this.loggers) {
|
|
424
|
+
logger.warn(source, category, ...args);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
/** {@inheritDoc Logger.error} */
|
|
428
|
+
error(source, category, ...args) {
|
|
429
|
+
for (const logger of this.loggers) {
|
|
430
|
+
logger.error(source, category, ...args);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
/** {@inheritDoc Logger.perf} */
|
|
434
|
+
perf(source, category, event, phase, ...args) {
|
|
435
|
+
for (const logger of this.loggers) {
|
|
436
|
+
logger.perf(source, category, event, phase, ...args);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
// src/task.ts
|
|
442
|
+
var TaskStage = /* @__PURE__ */ ((TaskStage2) => {
|
|
443
|
+
TaskStage2[TaskStage2["Pending"] = 0] = "Pending";
|
|
444
|
+
TaskStage2[TaskStage2["Resolved"] = 1] = "Resolved";
|
|
445
|
+
TaskStage2[TaskStage2["Rejected"] = 2] = "Rejected";
|
|
446
|
+
TaskStage2[TaskStage2["Aborted"] = 3] = "Aborted";
|
|
447
|
+
return TaskStage2;
|
|
448
|
+
})(TaskStage || {});
|
|
449
|
+
var TaskAbortedError = class extends Error {
|
|
450
|
+
constructor(reason) {
|
|
451
|
+
super(`Task aborted: ${reason}`);
|
|
452
|
+
this.name = "TaskAbortedError";
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
var TaskRejectedError = class extends Error {
|
|
456
|
+
constructor(reason) {
|
|
457
|
+
super(`Task rejected: ${reason}`);
|
|
458
|
+
this.name = "TaskRejectedError";
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
var Task = class {
|
|
462
|
+
constructor() {
|
|
463
|
+
this.state = {
|
|
464
|
+
stage: 0 /* Pending */
|
|
465
|
+
};
|
|
466
|
+
/**
|
|
467
|
+
* callbacks that will be executed when task is resolved
|
|
468
|
+
*/
|
|
469
|
+
this.resolvedCallbacks = [];
|
|
470
|
+
/**
|
|
471
|
+
* callbacks that will be executed when task is rejected
|
|
472
|
+
*/
|
|
473
|
+
this.rejectedCallbacks = [];
|
|
474
|
+
/**
|
|
475
|
+
* Promise that will be resolved when task is settled
|
|
476
|
+
*/
|
|
477
|
+
this._promise = null;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Convert task to promise
|
|
481
|
+
* @returns promise that will be resolved when task is settled
|
|
482
|
+
*/
|
|
483
|
+
toPromise() {
|
|
484
|
+
if (!this._promise) {
|
|
485
|
+
this._promise = new Promise((resolve, reject) => {
|
|
486
|
+
this.wait(
|
|
487
|
+
(result) => resolve(result),
|
|
488
|
+
(error) => {
|
|
489
|
+
if (error.type === "abort") {
|
|
490
|
+
reject(new TaskAbortedError(error.reason));
|
|
491
|
+
} else {
|
|
492
|
+
reject(new TaskRejectedError(error.reason));
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
);
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
return this._promise;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* wait for task to be settled
|
|
502
|
+
* @param resolvedCallback - callback for resolved value
|
|
503
|
+
* @param rejectedCallback - callback for rejected value
|
|
504
|
+
*/
|
|
505
|
+
wait(resolvedCallback, rejectedCallback) {
|
|
506
|
+
switch (this.state.stage) {
|
|
507
|
+
case 0 /* Pending */:
|
|
508
|
+
this.resolvedCallbacks.push(resolvedCallback);
|
|
509
|
+
this.rejectedCallbacks.push(rejectedCallback);
|
|
510
|
+
break;
|
|
511
|
+
case 1 /* Resolved */:
|
|
512
|
+
resolvedCallback(this.state.result);
|
|
513
|
+
break;
|
|
514
|
+
case 2 /* Rejected */:
|
|
515
|
+
rejectedCallback({
|
|
516
|
+
type: "reject",
|
|
517
|
+
reason: this.state.reason
|
|
518
|
+
});
|
|
519
|
+
break;
|
|
520
|
+
case 3 /* Aborted */:
|
|
521
|
+
rejectedCallback({
|
|
522
|
+
type: "abort",
|
|
523
|
+
reason: this.state.reason
|
|
524
|
+
});
|
|
525
|
+
break;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* resolve task with specific result
|
|
530
|
+
* @param result - result value
|
|
531
|
+
*/
|
|
532
|
+
resolve(result) {
|
|
533
|
+
if (this.state.stage === 0 /* Pending */) {
|
|
534
|
+
this.state = {
|
|
535
|
+
stage: 1 /* Resolved */,
|
|
536
|
+
result
|
|
537
|
+
};
|
|
538
|
+
for (const resolvedCallback of this.resolvedCallbacks) {
|
|
539
|
+
try {
|
|
540
|
+
resolvedCallback(result);
|
|
541
|
+
} catch (e) {
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
this.resolvedCallbacks = [];
|
|
545
|
+
this.rejectedCallbacks = [];
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* reject task with specific reason
|
|
550
|
+
* @param reason - abort reason
|
|
551
|
+
*
|
|
552
|
+
*/
|
|
553
|
+
reject(reason) {
|
|
554
|
+
if (this.state.stage === 0 /* Pending */) {
|
|
555
|
+
this.state = {
|
|
556
|
+
stage: 2 /* Rejected */,
|
|
557
|
+
reason
|
|
558
|
+
};
|
|
559
|
+
for (const rejectedCallback of this.rejectedCallbacks) {
|
|
560
|
+
try {
|
|
561
|
+
rejectedCallback({
|
|
562
|
+
type: "reject",
|
|
563
|
+
reason
|
|
564
|
+
});
|
|
565
|
+
} catch (e) {
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
this.resolvedCallbacks = [];
|
|
569
|
+
this.rejectedCallbacks = [];
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* abort task with specific reason
|
|
574
|
+
* @param reason - abort reason
|
|
575
|
+
*/
|
|
576
|
+
abort(reason) {
|
|
577
|
+
if (this.state.stage === 0 /* Pending */) {
|
|
578
|
+
this.state = {
|
|
579
|
+
stage: 3 /* Aborted */,
|
|
580
|
+
reason
|
|
581
|
+
};
|
|
582
|
+
for (const rejectedCallback of this.rejectedCallbacks) {
|
|
583
|
+
try {
|
|
584
|
+
rejectedCallback({
|
|
585
|
+
type: "abort",
|
|
586
|
+
reason
|
|
587
|
+
});
|
|
588
|
+
} catch (e) {
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
this.resolvedCallbacks = [];
|
|
592
|
+
this.rejectedCallbacks = [];
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* fail task with a TaskError from another task
|
|
597
|
+
* This is a convenience method for error propagation between tasks
|
|
598
|
+
* @param error - TaskError from another task
|
|
599
|
+
*/
|
|
600
|
+
fail(error) {
|
|
601
|
+
if (error.type === "abort") {
|
|
602
|
+
this.abort(error.reason);
|
|
603
|
+
} else {
|
|
604
|
+
this.reject(error.reason);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
// src/pdf.ts
|
|
610
|
+
var PdfZoomMode = /* @__PURE__ */ ((PdfZoomMode2) => {
|
|
611
|
+
PdfZoomMode2[PdfZoomMode2["Unknown"] = 0] = "Unknown";
|
|
612
|
+
PdfZoomMode2[PdfZoomMode2["XYZ"] = 1] = "XYZ";
|
|
613
|
+
PdfZoomMode2[PdfZoomMode2["FitPage"] = 2] = "FitPage";
|
|
614
|
+
PdfZoomMode2[PdfZoomMode2["FitHorizontal"] = 3] = "FitHorizontal";
|
|
615
|
+
PdfZoomMode2[PdfZoomMode2["FitVertical"] = 4] = "FitVertical";
|
|
616
|
+
PdfZoomMode2[PdfZoomMode2["FitRectangle"] = 5] = "FitRectangle";
|
|
617
|
+
return PdfZoomMode2;
|
|
618
|
+
})(PdfZoomMode || {});
|
|
619
|
+
var PdfActionType = /* @__PURE__ */ ((PdfActionType2) => {
|
|
620
|
+
PdfActionType2[PdfActionType2["Unsupported"] = 0] = "Unsupported";
|
|
621
|
+
PdfActionType2[PdfActionType2["Goto"] = 1] = "Goto";
|
|
622
|
+
PdfActionType2[PdfActionType2["RemoteGoto"] = 2] = "RemoteGoto";
|
|
623
|
+
PdfActionType2[PdfActionType2["URI"] = 3] = "URI";
|
|
624
|
+
PdfActionType2[PdfActionType2["LaunchAppOrOpenFile"] = 4] = "LaunchAppOrOpenFile";
|
|
625
|
+
return PdfActionType2;
|
|
626
|
+
})(PdfActionType || {});
|
|
627
|
+
var PdfAnnotationSubtype = /* @__PURE__ */ ((PdfAnnotationSubtype2) => {
|
|
628
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["UNKNOWN"] = 0] = "UNKNOWN";
|
|
629
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["TEXT"] = 1] = "TEXT";
|
|
630
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["LINK"] = 2] = "LINK";
|
|
631
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["FREETEXT"] = 3] = "FREETEXT";
|
|
632
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["LINE"] = 4] = "LINE";
|
|
633
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["SQUARE"] = 5] = "SQUARE";
|
|
634
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["CIRCLE"] = 6] = "CIRCLE";
|
|
635
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["POLYGON"] = 7] = "POLYGON";
|
|
636
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["POLYLINE"] = 8] = "POLYLINE";
|
|
637
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["HIGHLIGHT"] = 9] = "HIGHLIGHT";
|
|
638
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["UNDERLINE"] = 10] = "UNDERLINE";
|
|
639
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["SQUIGGLY"] = 11] = "SQUIGGLY";
|
|
640
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["STRIKEOUT"] = 12] = "STRIKEOUT";
|
|
641
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["STAMP"] = 13] = "STAMP";
|
|
642
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["CARET"] = 14] = "CARET";
|
|
643
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["INK"] = 15] = "INK";
|
|
644
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["POPUP"] = 16] = "POPUP";
|
|
645
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["FILEATTACHMENT"] = 17] = "FILEATTACHMENT";
|
|
646
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["SOUND"] = 18] = "SOUND";
|
|
647
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["MOVIE"] = 19] = "MOVIE";
|
|
648
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["WIDGET"] = 20] = "WIDGET";
|
|
649
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["SCREEN"] = 21] = "SCREEN";
|
|
650
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["PRINTERMARK"] = 22] = "PRINTERMARK";
|
|
651
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["TRAPNET"] = 23] = "TRAPNET";
|
|
652
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["WATERMARK"] = 24] = "WATERMARK";
|
|
653
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["THREED"] = 25] = "THREED";
|
|
654
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["RICHMEDIA"] = 26] = "RICHMEDIA";
|
|
655
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["XFAWIDGET"] = 27] = "XFAWIDGET";
|
|
656
|
+
PdfAnnotationSubtype2[PdfAnnotationSubtype2["REDACT"] = 28] = "REDACT";
|
|
657
|
+
return PdfAnnotationSubtype2;
|
|
658
|
+
})(PdfAnnotationSubtype || {});
|
|
659
|
+
var PdfAnnotationSubtypeName = {
|
|
660
|
+
[0 /* UNKNOWN */]: "unknow",
|
|
661
|
+
[1 /* TEXT */]: "text",
|
|
662
|
+
[2 /* LINK */]: "link",
|
|
663
|
+
[3 /* FREETEXT */]: "freetext",
|
|
664
|
+
[4 /* LINE */]: "line",
|
|
665
|
+
[5 /* SQUARE */]: "square",
|
|
666
|
+
[6 /* CIRCLE */]: "circle",
|
|
667
|
+
[7 /* POLYGON */]: "polygon",
|
|
668
|
+
[8 /* POLYLINE */]: "polyline",
|
|
669
|
+
[9 /* HIGHLIGHT */]: "highlight",
|
|
670
|
+
[10 /* UNDERLINE */]: "underline",
|
|
671
|
+
[11 /* SQUIGGLY */]: "squiggly",
|
|
672
|
+
[12 /* STRIKEOUT */]: "strikeout",
|
|
673
|
+
[13 /* STAMP */]: "stamp",
|
|
674
|
+
[14 /* CARET */]: "caret",
|
|
675
|
+
[15 /* INK */]: "ink",
|
|
676
|
+
[16 /* POPUP */]: "popup",
|
|
677
|
+
[17 /* FILEATTACHMENT */]: "fileattachment",
|
|
678
|
+
[18 /* SOUND */]: "sound",
|
|
679
|
+
[19 /* MOVIE */]: "movie",
|
|
680
|
+
[20 /* WIDGET */]: "widget",
|
|
681
|
+
[21 /* SCREEN */]: "screen",
|
|
682
|
+
[22 /* PRINTERMARK */]: "printermark",
|
|
683
|
+
[23 /* TRAPNET */]: "trapnet",
|
|
684
|
+
[24 /* WATERMARK */]: "watermark",
|
|
685
|
+
[25 /* THREED */]: "threed",
|
|
686
|
+
[26 /* RICHMEDIA */]: "richmedia",
|
|
687
|
+
[27 /* XFAWIDGET */]: "xfawidget",
|
|
688
|
+
[28 /* REDACT */]: "redact"
|
|
689
|
+
};
|
|
690
|
+
var PdfAnnotationObjectStatus = /* @__PURE__ */ ((PdfAnnotationObjectStatus2) => {
|
|
691
|
+
PdfAnnotationObjectStatus2[PdfAnnotationObjectStatus2["Created"] = 0] = "Created";
|
|
692
|
+
PdfAnnotationObjectStatus2[PdfAnnotationObjectStatus2["Committed"] = 1] = "Committed";
|
|
693
|
+
return PdfAnnotationObjectStatus2;
|
|
694
|
+
})(PdfAnnotationObjectStatus || {});
|
|
695
|
+
var AppearanceMode = /* @__PURE__ */ ((AppearanceMode2) => {
|
|
696
|
+
AppearanceMode2[AppearanceMode2["Normal"] = 0] = "Normal";
|
|
697
|
+
AppearanceMode2[AppearanceMode2["Rollover"] = 1] = "Rollover";
|
|
698
|
+
AppearanceMode2[AppearanceMode2["Down"] = 2] = "Down";
|
|
699
|
+
return AppearanceMode2;
|
|
700
|
+
})(AppearanceMode || {});
|
|
701
|
+
var PdfAnnotationState = /* @__PURE__ */ ((PdfAnnotationState2) => {
|
|
702
|
+
PdfAnnotationState2["Marked"] = "Marked";
|
|
703
|
+
PdfAnnotationState2["Unmarked"] = "Unmarked";
|
|
704
|
+
PdfAnnotationState2["Accepted"] = "Accepted";
|
|
705
|
+
PdfAnnotationState2["Rejected"] = "Rejected";
|
|
706
|
+
PdfAnnotationState2["Complete"] = "Complete";
|
|
707
|
+
PdfAnnotationState2["Cancelled"] = "Cancelled";
|
|
708
|
+
PdfAnnotationState2["None"] = "None";
|
|
709
|
+
return PdfAnnotationState2;
|
|
710
|
+
})(PdfAnnotationState || {});
|
|
711
|
+
var PdfAnnotationStateModel = /* @__PURE__ */ ((PdfAnnotationStateModel2) => {
|
|
712
|
+
PdfAnnotationStateModel2["Marked"] = "Marked";
|
|
713
|
+
PdfAnnotationStateModel2["Reviewed"] = "Reviewed";
|
|
714
|
+
return PdfAnnotationStateModel2;
|
|
715
|
+
})(PdfAnnotationStateModel || {});
|
|
716
|
+
var PDF_FORM_FIELD_TYPE = /* @__PURE__ */ ((PDF_FORM_FIELD_TYPE2) => {
|
|
717
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["UNKNOWN"] = 0] = "UNKNOWN";
|
|
718
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["PUSHBUTTON"] = 1] = "PUSHBUTTON";
|
|
719
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["CHECKBOX"] = 2] = "CHECKBOX";
|
|
720
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["RADIOBUTTON"] = 3] = "RADIOBUTTON";
|
|
721
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["COMBOBOX"] = 4] = "COMBOBOX";
|
|
722
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["LISTBOX"] = 5] = "LISTBOX";
|
|
723
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["TEXTFIELD"] = 6] = "TEXTFIELD";
|
|
724
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["SIGNATURE"] = 7] = "SIGNATURE";
|
|
725
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA"] = 8] = "XFA";
|
|
726
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA_CHECKBOX"] = 9] = "XFA_CHECKBOX";
|
|
727
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA_COMBOBOX"] = 10] = "XFA_COMBOBOX";
|
|
728
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA_IMAGEFIELD"] = 11] = "XFA_IMAGEFIELD";
|
|
729
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA_LISTBOX"] = 12] = "XFA_LISTBOX";
|
|
730
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA_PUSHBUTTON"] = 13] = "XFA_PUSHBUTTON";
|
|
731
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA_SIGNATURE"] = 14] = "XFA_SIGNATURE";
|
|
732
|
+
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA_TEXTFIELD"] = 15] = "XFA_TEXTFIELD";
|
|
733
|
+
return PDF_FORM_FIELD_TYPE2;
|
|
734
|
+
})(PDF_FORM_FIELD_TYPE || {});
|
|
735
|
+
var PDF_FORM_FIELD_FLAG = /* @__PURE__ */ ((PDF_FORM_FIELD_FLAG2) => {
|
|
736
|
+
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["NONE"] = 0] = "NONE";
|
|
737
|
+
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["READONLY"] = 1] = "READONLY";
|
|
738
|
+
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["REQUIRED"] = 2] = "REQUIRED";
|
|
739
|
+
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["NOEXPORT"] = 4] = "NOEXPORT";
|
|
740
|
+
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["TEXT_MULTIPLINE"] = 4096] = "TEXT_MULTIPLINE";
|
|
741
|
+
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["TEXT_PASSWORD"] = 8192] = "TEXT_PASSWORD";
|
|
742
|
+
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["CHOICE_COMBO"] = 131072] = "CHOICE_COMBO";
|
|
743
|
+
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["CHOICE_EDIT"] = 262144] = "CHOICE_EDIT";
|
|
744
|
+
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["CHOICE_MULTL_SELECT"] = 2097152] = "CHOICE_MULTL_SELECT";
|
|
745
|
+
return PDF_FORM_FIELD_FLAG2;
|
|
746
|
+
})(PDF_FORM_FIELD_FLAG || {});
|
|
747
|
+
var PdfPageObjectType = /* @__PURE__ */ ((PdfPageObjectType2) => {
|
|
748
|
+
PdfPageObjectType2[PdfPageObjectType2["UNKNOWN"] = 0] = "UNKNOWN";
|
|
749
|
+
PdfPageObjectType2[PdfPageObjectType2["TEXT"] = 1] = "TEXT";
|
|
750
|
+
PdfPageObjectType2[PdfPageObjectType2["PATH"] = 2] = "PATH";
|
|
751
|
+
PdfPageObjectType2[PdfPageObjectType2["IMAGE"] = 3] = "IMAGE";
|
|
752
|
+
PdfPageObjectType2[PdfPageObjectType2["SHADING"] = 4] = "SHADING";
|
|
753
|
+
PdfPageObjectType2[PdfPageObjectType2["FORM"] = 5] = "FORM";
|
|
754
|
+
return PdfPageObjectType2;
|
|
755
|
+
})(PdfPageObjectType || {});
|
|
756
|
+
var PdfSegmentObjectType = /* @__PURE__ */ ((PdfSegmentObjectType2) => {
|
|
757
|
+
PdfSegmentObjectType2[PdfSegmentObjectType2["UNKNOWN"] = -1] = "UNKNOWN";
|
|
758
|
+
PdfSegmentObjectType2[PdfSegmentObjectType2["LINETO"] = 0] = "LINETO";
|
|
759
|
+
PdfSegmentObjectType2[PdfSegmentObjectType2["BEZIERTO"] = 1] = "BEZIERTO";
|
|
760
|
+
PdfSegmentObjectType2[PdfSegmentObjectType2["MOVETO"] = 2] = "MOVETO";
|
|
761
|
+
return PdfSegmentObjectType2;
|
|
762
|
+
})(PdfSegmentObjectType || {});
|
|
763
|
+
var PdfEngineFeature = /* @__PURE__ */ ((PdfEngineFeature2) => {
|
|
764
|
+
PdfEngineFeature2[PdfEngineFeature2["RenderPage"] = 0] = "RenderPage";
|
|
765
|
+
PdfEngineFeature2[PdfEngineFeature2["RenderPageRect"] = 1] = "RenderPageRect";
|
|
766
|
+
PdfEngineFeature2[PdfEngineFeature2["Thumbnails"] = 2] = "Thumbnails";
|
|
767
|
+
PdfEngineFeature2[PdfEngineFeature2["Bookmarks"] = 3] = "Bookmarks";
|
|
768
|
+
PdfEngineFeature2[PdfEngineFeature2["Annotations"] = 4] = "Annotations";
|
|
769
|
+
return PdfEngineFeature2;
|
|
770
|
+
})(PdfEngineFeature || {});
|
|
771
|
+
var PdfEngineOperation = /* @__PURE__ */ ((PdfEngineOperation2) => {
|
|
772
|
+
PdfEngineOperation2[PdfEngineOperation2["Create"] = 0] = "Create";
|
|
773
|
+
PdfEngineOperation2[PdfEngineOperation2["Read"] = 1] = "Read";
|
|
774
|
+
PdfEngineOperation2[PdfEngineOperation2["Update"] = 2] = "Update";
|
|
775
|
+
PdfEngineOperation2[PdfEngineOperation2["Delete"] = 3] = "Delete";
|
|
776
|
+
return PdfEngineOperation2;
|
|
777
|
+
})(PdfEngineOperation || {});
|
|
778
|
+
var MatchFlag = /* @__PURE__ */ ((MatchFlag2) => {
|
|
779
|
+
MatchFlag2[MatchFlag2["None"] = 0] = "None";
|
|
780
|
+
MatchFlag2[MatchFlag2["MatchCase"] = 1] = "MatchCase";
|
|
781
|
+
MatchFlag2[MatchFlag2["MatchWholeWord"] = 2] = "MatchWholeWord";
|
|
782
|
+
MatchFlag2[MatchFlag2["MatchConsecutive"] = 4] = "MatchConsecutive";
|
|
783
|
+
return MatchFlag2;
|
|
784
|
+
})(MatchFlag || {});
|
|
785
|
+
function unionFlags(flags) {
|
|
786
|
+
return flags.reduce((flag, currFlag) => {
|
|
787
|
+
return flag | currFlag;
|
|
788
|
+
}, 0 /* None */);
|
|
789
|
+
}
|
|
790
|
+
function compareSearchTarget(targetA, targetB) {
|
|
791
|
+
const flagA = unionFlags(targetA.flags);
|
|
792
|
+
const flagB = unionFlags(targetB.flags);
|
|
793
|
+
return flagA === flagB && targetA.keyword === targetB.keyword;
|
|
794
|
+
}
|
|
795
|
+
var PdfPermission = /* @__PURE__ */ ((PdfPermission2) => {
|
|
796
|
+
PdfPermission2[PdfPermission2["PrintDocument"] = 8] = "PrintDocument";
|
|
797
|
+
PdfPermission2[PdfPermission2["ModifyContent"] = 16] = "ModifyContent";
|
|
798
|
+
PdfPermission2[PdfPermission2["CopyOrExtract"] = 32] = "CopyOrExtract";
|
|
799
|
+
PdfPermission2[PdfPermission2["AddOrModifyTextAnnot"] = 64] = "AddOrModifyTextAnnot";
|
|
800
|
+
PdfPermission2[PdfPermission2["FillInExistingForm"] = 512] = "FillInExistingForm";
|
|
801
|
+
PdfPermission2[PdfPermission2["ExtractTextOrGraphics"] = 1024] = "ExtractTextOrGraphics";
|
|
802
|
+
PdfPermission2[PdfPermission2["AssembleDocument"] = 2048] = "AssembleDocument";
|
|
803
|
+
PdfPermission2[PdfPermission2["PrintHighQuality"] = 4096] = "PrintHighQuality";
|
|
804
|
+
return PdfPermission2;
|
|
805
|
+
})(PdfPermission || {});
|
|
806
|
+
var PdfPageFlattenFlag = /* @__PURE__ */ ((PdfPageFlattenFlag2) => {
|
|
807
|
+
PdfPageFlattenFlag2[PdfPageFlattenFlag2["Display"] = 0] = "Display";
|
|
808
|
+
PdfPageFlattenFlag2[PdfPageFlattenFlag2["Print"] = 1] = "Print";
|
|
809
|
+
return PdfPageFlattenFlag2;
|
|
810
|
+
})(PdfPageFlattenFlag || {});
|
|
811
|
+
var PdfPageFlattenResult = /* @__PURE__ */ ((PdfPageFlattenResult2) => {
|
|
812
|
+
PdfPageFlattenResult2[PdfPageFlattenResult2["Fail"] = 0] = "Fail";
|
|
813
|
+
PdfPageFlattenResult2[PdfPageFlattenResult2["Success"] = 1] = "Success";
|
|
814
|
+
PdfPageFlattenResult2[PdfPageFlattenResult2["NothingToDo"] = 2] = "NothingToDo";
|
|
815
|
+
return PdfPageFlattenResult2;
|
|
816
|
+
})(PdfPageFlattenResult || {});
|
|
817
|
+
var PdfErrorCode = /* @__PURE__ */ ((PdfErrorCode2) => {
|
|
818
|
+
PdfErrorCode2[PdfErrorCode2["Ok"] = 0] = "Ok";
|
|
819
|
+
PdfErrorCode2[PdfErrorCode2["Unknown"] = 1] = "Unknown";
|
|
820
|
+
PdfErrorCode2[PdfErrorCode2["NotFound"] = 2] = "NotFound";
|
|
821
|
+
PdfErrorCode2[PdfErrorCode2["WrongFormat"] = 3] = "WrongFormat";
|
|
822
|
+
PdfErrorCode2[PdfErrorCode2["Password"] = 4] = "Password";
|
|
823
|
+
PdfErrorCode2[PdfErrorCode2["Security"] = 5] = "Security";
|
|
824
|
+
PdfErrorCode2[PdfErrorCode2["PageError"] = 6] = "PageError";
|
|
825
|
+
PdfErrorCode2[PdfErrorCode2["XFALoad"] = 7] = "XFALoad";
|
|
826
|
+
PdfErrorCode2[PdfErrorCode2["XFALayout"] = 8] = "XFALayout";
|
|
827
|
+
PdfErrorCode2[PdfErrorCode2["Cancelled"] = 9] = "Cancelled";
|
|
828
|
+
PdfErrorCode2[PdfErrorCode2["Initialization"] = 10] = "Initialization";
|
|
829
|
+
PdfErrorCode2[PdfErrorCode2["NotReady"] = 11] = "NotReady";
|
|
830
|
+
PdfErrorCode2[PdfErrorCode2["NotSupport"] = 12] = "NotSupport";
|
|
831
|
+
PdfErrorCode2[PdfErrorCode2["LoadDoc"] = 13] = "LoadDoc";
|
|
832
|
+
PdfErrorCode2[PdfErrorCode2["DocNotOpen"] = 14] = "DocNotOpen";
|
|
833
|
+
PdfErrorCode2[PdfErrorCode2["CantCloseDoc"] = 15] = "CantCloseDoc";
|
|
834
|
+
PdfErrorCode2[PdfErrorCode2["CantCreateNewDoc"] = 16] = "CantCreateNewDoc";
|
|
835
|
+
PdfErrorCode2[PdfErrorCode2["CantImportPages"] = 17] = "CantImportPages";
|
|
836
|
+
PdfErrorCode2[PdfErrorCode2["CantCreateAnnot"] = 18] = "CantCreateAnnot";
|
|
837
|
+
PdfErrorCode2[PdfErrorCode2["CantSetAnnotRect"] = 19] = "CantSetAnnotRect";
|
|
838
|
+
PdfErrorCode2[PdfErrorCode2["CantSetAnnotContent"] = 20] = "CantSetAnnotContent";
|
|
839
|
+
PdfErrorCode2[PdfErrorCode2["CantRemoveInkList"] = 21] = "CantRemoveInkList";
|
|
840
|
+
PdfErrorCode2[PdfErrorCode2["CantAddInkStoke"] = 22] = "CantAddInkStoke";
|
|
841
|
+
PdfErrorCode2[PdfErrorCode2["CantReadAttachmentSize"] = 23] = "CantReadAttachmentSize";
|
|
842
|
+
PdfErrorCode2[PdfErrorCode2["CantReadAttachmentContent"] = 24] = "CantReadAttachmentContent";
|
|
843
|
+
PdfErrorCode2[PdfErrorCode2["CantFocusAnnot"] = 25] = "CantFocusAnnot";
|
|
844
|
+
PdfErrorCode2[PdfErrorCode2["CantSelectText"] = 26] = "CantSelectText";
|
|
845
|
+
PdfErrorCode2[PdfErrorCode2["CantSelectOption"] = 27] = "CantSelectOption";
|
|
846
|
+
PdfErrorCode2[PdfErrorCode2["CantCheckField"] = 28] = "CantCheckField";
|
|
847
|
+
return PdfErrorCode2;
|
|
848
|
+
})(PdfErrorCode || {});
|
|
849
|
+
var PdfTaskHelper = class {
|
|
850
|
+
/**
|
|
851
|
+
* Create a task
|
|
852
|
+
* @returns new task
|
|
853
|
+
*/
|
|
854
|
+
static create() {
|
|
855
|
+
return new Task();
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Create a task that has been resolved with value
|
|
859
|
+
* @param result - resolved value
|
|
860
|
+
* @returns resolved task
|
|
861
|
+
*/
|
|
862
|
+
static resolve(result) {
|
|
863
|
+
const task = new Task();
|
|
864
|
+
task.resolve(result);
|
|
865
|
+
return task;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Create a task that has been rejected with error
|
|
869
|
+
* @param reason - rejected error
|
|
870
|
+
* @returns rejected task
|
|
871
|
+
*/
|
|
872
|
+
static reject(reason) {
|
|
873
|
+
const task = new Task();
|
|
874
|
+
task.reject(reason);
|
|
875
|
+
return task;
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Create a task that has been aborted with error
|
|
879
|
+
* @param reason - aborted error
|
|
880
|
+
* @returns aborted task
|
|
881
|
+
*/
|
|
882
|
+
static abort(reason) {
|
|
883
|
+
const task = new Task();
|
|
884
|
+
task.reject(reason);
|
|
885
|
+
return task;
|
|
886
|
+
}
|
|
887
|
+
};
|
|
888
|
+
|
|
889
|
+
// src/index.ts
|
|
890
|
+
function ignore() {
|
|
891
|
+
}
|
|
892
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
893
|
+
0 && (module.exports = {
|
|
894
|
+
AllLogger,
|
|
895
|
+
AppearanceMode,
|
|
896
|
+
ConsoleLogger,
|
|
897
|
+
LevelLogger,
|
|
898
|
+
LogLevel,
|
|
899
|
+
MatchFlag,
|
|
900
|
+
NoopLogger,
|
|
901
|
+
PDF_FORM_FIELD_FLAG,
|
|
902
|
+
PDF_FORM_FIELD_TYPE,
|
|
903
|
+
PdfActionType,
|
|
904
|
+
PdfAnnotationObjectStatus,
|
|
905
|
+
PdfAnnotationState,
|
|
906
|
+
PdfAnnotationStateModel,
|
|
907
|
+
PdfAnnotationSubtype,
|
|
908
|
+
PdfAnnotationSubtypeName,
|
|
909
|
+
PdfEngineFeature,
|
|
910
|
+
PdfEngineOperation,
|
|
911
|
+
PdfErrorCode,
|
|
912
|
+
PdfPageFlattenFlag,
|
|
913
|
+
PdfPageFlattenResult,
|
|
914
|
+
PdfPageObjectType,
|
|
915
|
+
PdfPermission,
|
|
916
|
+
PdfSegmentObjectType,
|
|
917
|
+
PdfTaskHelper,
|
|
918
|
+
PdfZoomMode,
|
|
919
|
+
PerfLogger,
|
|
920
|
+
Rotation,
|
|
921
|
+
Task,
|
|
922
|
+
TaskAbortedError,
|
|
923
|
+
TaskRejectedError,
|
|
924
|
+
TaskStage,
|
|
925
|
+
boundingRect,
|
|
926
|
+
calculateAngle,
|
|
927
|
+
calculateDegree,
|
|
928
|
+
compareSearchTarget,
|
|
929
|
+
ignore,
|
|
930
|
+
quadToRect,
|
|
931
|
+
restoreOffset,
|
|
932
|
+
restorePosition,
|
|
933
|
+
restoreRect,
|
|
934
|
+
rotatePosition,
|
|
935
|
+
rotateRect,
|
|
936
|
+
scalePosition,
|
|
937
|
+
scaleRect,
|
|
938
|
+
swap,
|
|
939
|
+
toIntPos,
|
|
940
|
+
toIntRect,
|
|
941
|
+
toIntSize,
|
|
942
|
+
transformPosition,
|
|
943
|
+
transformRect,
|
|
944
|
+
transformSize,
|
|
945
|
+
unionFlags
|
|
946
|
+
});
|
|
947
|
+
//# sourceMappingURL=index.cjs.map
|