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