@embedpdf/models 1.0.11 → 1.0.12

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.d.ts CHANGED
@@ -1,2607 +1,3 @@
1
- /**
2
- * Clockwise direction
3
- * @public
4
- */
5
- declare enum Rotation {
6
- Degree0 = 0,
7
- Degree90 = 1,
8
- Degree180 = 2,
9
- Degree270 = 3
10
- }
11
- /** Clamp a Position to device-pixel integers (floor) */
12
- declare function toIntPos(p: Position): Position;
13
- /** Clamp a Size so it never truncates right / bottom (ceil) */
14
- declare function toIntSize(s: Size): Size;
15
- /** Apply both rules to a Rect */
16
- declare function toIntRect(r: Rect): Rect;
17
- /**
18
- * Calculate degree that match the rotation type
19
- * @param rotation - type of rotation
20
- * @returns rotated degree
21
- *
22
- * @public
23
- */
24
- declare function calculateDegree(rotation: Rotation): 0 | 90 | 180 | 270;
25
- /**
26
- * Calculate angle that match the rotation type
27
- * @param rotation - type of rotation
28
- * @returns rotated angle
29
- *
30
- * @public
31
- */
32
- declare function calculateAngle(rotation: Rotation): number;
33
- /**
34
- * Represent the size of object
35
- *
36
- * @public
37
- */
38
- interface Size {
39
- /**
40
- * width of the object
41
- */
42
- width: number;
43
- /**
44
- * height of the object
45
- */
46
- height: number;
47
- }
48
- /**
49
- * Represents a rectangle defined by its left, top, right, and bottom edges
50
- *
51
- * @public
52
- */
53
- interface Box {
54
- /**
55
- * The x-coordinate of the left edge
56
- */
57
- left: number;
58
- /**
59
- * The y-coordinate of the top edge
60
- */
61
- top: number;
62
- /**
63
- * The x-coordinate of the right edge
64
- */
65
- right: number;
66
- /**
67
- * The y-coordinate of the bottom edge
68
- */
69
- bottom: number;
70
- }
71
- /**
72
- * Swap the width and height of the size object
73
- * @param size - the original size
74
- * @returns swapped size
75
- *
76
- * @public
77
- */
78
- declare function swap(size: Size): Size;
79
- /**
80
- * Transform size with specified rotation angle and scale factor
81
- * @param size - orignal size of rect
82
- * @param rotation - rotation angle
83
- * @param scaleFactor - - scale factor
84
- * @returns size that has been transformed
85
- *
86
- * @public
87
- */
88
- declare function transformSize(size: Size, rotation: Rotation, scaleFactor: number): Size;
89
- /**
90
- * position of point
91
- *
92
- * @public
93
- */
94
- interface Position {
95
- /**
96
- * x coordinate
97
- */
98
- x: number;
99
- /**
100
- * y coordinate
101
- */
102
- y: number;
103
- }
104
- /**
105
- * Quadrilateral
106
- *
107
- * @public
108
- */
109
- interface Quad {
110
- p1: Position;
111
- p2: Position;
112
- p3: Position;
113
- p4: Position;
114
- }
115
- /**
116
- * Convert quadrilateral to rectangle
117
- * @param q - quadrilateral
118
- * @returns rectangle
119
- *
120
- * @public
121
- */
122
- declare function quadToRect(q: Quad): Rect;
123
- /**
124
- * Convert rectangle to quadrilateral
125
- * @param r - rectangle
126
- * @returns quadrilateral
127
- *
128
- * @public
129
- */
130
- declare function rectToQuad(r: Rect): Quad;
131
- /**
132
- * Rotate the container and calculate the new position for a point
133
- * in specified position
134
- * @param containerSize - size of the container
135
- * @param position - position of the point
136
- * @param rotation - rotated angle
137
- * @returns new position of the point
138
- *
139
- * @public
140
- */
141
- declare function rotatePosition(containerSize: Size, position: Position, rotation: Rotation): Position;
142
- /**
143
- * Calculate the position of point by scaling the container
144
- * @param position - position of the point
145
- * @param scaleFactor - factor of scaling
146
- * @returns new position of point
147
- *
148
- * @public
149
- */
150
- declare function scalePosition(position: Position, scaleFactor: number): Position;
151
- /**
152
- * Calculate the position of the point by applying the specified transformation
153
- * @param containerSize - size of container
154
- * @param position - position of the point
155
- * @param rotation - rotated angle
156
- * @param scaleFactor - factor of scaling
157
- * @returns new position of point
158
- *
159
- * @public
160
- */
161
- declare function transformPosition(containerSize: Size, position: Position, rotation: Rotation, scaleFactor: number): Position;
162
- /**
163
- * Restore the position in a transformed cotainer
164
- * @param containerSize - size of the container
165
- * @param position - position of the point
166
- * @param rotation - rotated angle
167
- * @param scaleFactor - factor of scaling
168
- * @returns the original position of the point
169
- *
170
- * @public
171
- */
172
- declare function restorePosition(containerSize: Size, position: Position, rotation: Rotation, scaleFactor: number): Position;
173
- /**
174
- * representation of rectangle
175
- *
176
- * @public
177
- */
178
- interface Rect {
179
- /**
180
- * origin of the rectangle
181
- */
182
- origin: Position;
183
- /**
184
- * size of the rectangle
185
- */
186
- size: Size;
187
- }
188
- /**
189
- * Calculate the rect after rotated the container
190
- * @param containerSize - size of container
191
- * @param rect - target rect
192
- * @param rotation - rotation angle
193
- * @returns rotated rect
194
- *
195
- * @public
196
- */
197
- declare function rotateRect(containerSize: Size, rect: Rect, rotation: Rotation): Rect;
198
- /**
199
- * Scale the rectangle
200
- * @param rect - rectangle
201
- * @param scaleFactor - factor of scaling
202
- * @returns new rectangle
203
- *
204
- * @public
205
- */
206
- declare function scaleRect(rect: Rect, scaleFactor: number): Rect;
207
- /**
208
- * Calculate new rectangle after transforming the container
209
- * @param containerSize - size of the container
210
- * @param rect - the target rectangle
211
- * @param rotation - rotated angle
212
- * @param scaleFactor - factor of scaling
213
- * @returns new rectangle after transformation
214
- *
215
- * @public
216
- */
217
- declare function transformRect(containerSize: Size, rect: Rect, rotation: Rotation, scaleFactor: number): Rect;
218
- /**
219
- * Calculate new rectangle before transforming the container
220
- * @param containerSize - size of the container
221
- * @param rect - the target rectangle
222
- * @param rotation - rotated angle
223
- * @param scaleFactor - factor of scaling
224
- * @returns original rectangle before transformation
225
- *
226
- * @public
227
- */
228
- declare function restoreRect(containerSize: Size, rect: Rect, rotation: Rotation, scaleFactor: number): Rect;
229
- /**
230
- * Calculate the original offset in a transformed container
231
- * @param offset - position of the point
232
- * @param rotation - rotated angle
233
- * @param scaleFactor - factor of scaling
234
- * @returns original position of the point
235
- *
236
- * @public
237
- */
238
- declare function restoreOffset(offset: Position, rotation: Rotation, scaleFactor: number): Position;
239
- /**
240
- * Return the smallest rectangle that encloses *all* `rects`.
241
- * If the array is empty, returns `null`.
242
- *
243
- * @param rects - array of rectangles
244
- * @returns smallest rectangle that encloses all the rectangles
245
- *
246
- * @public
247
- */
248
- declare function boundingRect(rects: Rect[]): Rect | null;
249
- interface Matrix {
250
- a: number;
251
- b: number;
252
- c: number;
253
- d: number;
254
- e: number;
255
- f: number;
256
- }
257
- /**
258
- * Build a CTM that maps *PDF-space* inside the annotation
259
- * → *device-space* inside the bitmap, honouring
260
- * zoom (scaleFactor × dpr) **and** page-rotation.
261
- */
262
- /** build the CTM for any page-rotation */
263
- declare const makeMatrix: (rectangle: Rect, rotation: Rotation, scaleFactor: number) => Matrix;
264
-
265
- /**
266
- * logger for logging
267
- *
268
- * @public
269
- */
270
- interface Logger {
271
- /**
272
- * Log debug message
273
- * @param source - source of log
274
- * @param category - category of log
275
- * @param args - parameters of log
276
- * @returns
277
- *
278
- * @public
279
- */
280
- debug: (source: string, category: string, ...args: any) => void;
281
- /**
282
- * Log infor message
283
- * @param source - source of log
284
- * @param category - category of log
285
- * @param args - parameters of log
286
- * @returns
287
- *
288
- * @public
289
- */
290
- info: (source: string, category: string, ...args: any) => void;
291
- /**
292
- * Log warning message
293
- * @param source - source of log
294
- * @param category - category of log
295
- * @param args - parameters of log
296
- * @returns
297
- *
298
- * @public
299
- */
300
- warn: (source: string, category: string, ...args: any) => void;
301
- /**
302
- * Log error message
303
- * @param source - source of log
304
- * @param category - category of log
305
- * @param args - parameters of log
306
- * @returns
307
- *
308
- * @public
309
- */
310
- error: (source: string, category: string, ...args: any) => void;
311
- /**
312
- * Log performance log
313
- * @param source - source of log
314
- * @param category - category of log
315
- * @param event - event of log
316
- * @param phase - event phase of log
317
- * @param args - parameters of log
318
- * @returns
319
- *
320
- * @public
321
- */
322
- perf: (source: string, category: string, event: string, phase: 'Begin' | 'End', ...args: any) => void;
323
- }
324
- /**
325
- * Logger that log nothing, it will ignore all the logs
326
- *
327
- * @public
328
- */
329
- declare class NoopLogger implements Logger {
330
- /** {@inheritDoc Logger.debug} */
331
- debug(): void;
332
- /** {@inheritDoc Logger.info} */
333
- info(): void;
334
- /** {@inheritDoc Logger.warn} */
335
- warn(): void;
336
- /** {@inheritDoc Logger.error} */
337
- error(): void;
338
- /** {@inheritDoc Logger.perf} */
339
- perf(): void;
340
- }
341
- /**
342
- * Logger that use console as the output
343
- *
344
- * @public
345
- */
346
- declare class ConsoleLogger implements Logger {
347
- /** {@inheritDoc Logger.debug} */
348
- debug(source: string, category: string, ...args: any): void;
349
- /** {@inheritDoc Logger.info} */
350
- info(source: string, category: string, ...args: any): void;
351
- /** {@inheritDoc Logger.warn} */
352
- warn(source: string, category: string, ...args: any): void;
353
- /** {@inheritDoc Logger.error} */
354
- error(source: string, category: string, ...args: any): void;
355
- /** {@inheritDoc Logger.perf} */
356
- perf(source: string, category: string, event: string, phase: 'Begin' | 'End', ...args: any): void;
357
- }
358
- /**
359
- * Level of log
360
- *
361
- * @public
362
- */
363
- declare enum LogLevel {
364
- Debug = 0,
365
- Info = 1,
366
- Warn = 2,
367
- Error = 3
368
- }
369
- /**
370
- * Logger that support filtering by log level
371
- *
372
- * @public
373
- */
374
- declare class LevelLogger implements Logger {
375
- private logger;
376
- private level;
377
- /**
378
- * create new LevelLogger
379
- * @param logger - the original logger
380
- * @param level - log level that used for filtering, all logs lower than this level will be filtered out
381
- */
382
- constructor(logger: Logger, level: LogLevel);
383
- /** {@inheritDoc Logger.debug} */
384
- debug(source: string, category: string, ...args: any): void;
385
- /** {@inheritDoc Logger.info} */
386
- info(source: string, category: string, ...args: any): void;
387
- /** {@inheritDoc Logger.warn} */
388
- warn(source: string, category: string, ...args: any): void;
389
- /** {@inheritDoc Logger.error} */
390
- error(source: string, category: string, ...args: any): void;
391
- /** {@inheritDoc Logger.perf} */
392
- perf(source: string, category: string, event: string, phase: 'Begin' | 'End', ...args: any): void;
393
- }
394
- /**
395
- * Logger for performance tracking
396
- *
397
- * @public
398
- */
399
- declare class PerfLogger implements Logger {
400
- /**
401
- * create new PerfLogger
402
- */
403
- constructor();
404
- /** {@inheritDoc Logger.debug} */
405
- debug(source: string, category: string, ...args: any): void;
406
- /** {@inheritDoc Logger.info} */
407
- info(source: string, category: string, ...args: any): void;
408
- /** {@inheritDoc Logger.warn} */
409
- warn(source: string, category: string, ...args: any): void;
410
- /** {@inheritDoc Logger.error} */
411
- error(source: string, category: string, ...args: any): void;
412
- /** {@inheritDoc Logger.perf} */
413
- perf(source: string, category: string, event: string, phase: 'Begin' | 'End', identifier: string, ...args: any): void;
414
- }
415
- /**
416
- * Logger that will track and call child loggers
417
- *
418
- * @public
419
- */
420
- declare class AllLogger implements Logger {
421
- private loggers;
422
- /**
423
- * create new PerfLogger
424
- */
425
- constructor(loggers: Logger[]);
426
- /** {@inheritDoc Logger.debug} */
427
- debug(source: string, category: string, ...args: any): void;
428
- /** {@inheritDoc Logger.info} */
429
- info(source: string, category: string, ...args: any): void;
430
- /** {@inheritDoc Logger.warn} */
431
- warn(source: string, category: string, ...args: any): void;
432
- /** {@inheritDoc Logger.error} */
433
- error(source: string, category: string, ...args: any): void;
434
- /** {@inheritDoc Logger.perf} */
435
- perf(source: string, category: string, event: string, phase: 'Begin' | 'End', ...args: any): void;
436
- }
437
-
438
- interface WebAlphaColor {
439
- color: string;
440
- opacity: number;
441
- }
442
- /**
443
- * Convert a {@link PdfAlphaColor} to a CSS-style colour definition.
444
- *
445
- * @param c - the colour coming from PDFium (0-255 per channel)
446
- * @returns
447
- * hex – #RRGGBB (no alpha channel)
448
- * opacity – 0-1 float suitable for CSS `opacity`/`rgba()`
449
- */
450
- declare function pdfAlphaColorToWebAlphaColor(c: PdfAlphaColor): WebAlphaColor;
451
- /**
452
- * Convert a CSS hex colour + opacity back into {@link PdfAlphaColor}
453
- *
454
- * @param hex - #RGB, #RRGGBB, or #rrggbb
455
- * @param opacity - 0-1 float (values outside clamp automatically)
456
- */
457
- declare function webAlphaColorToPdfAlphaColor({ color, opacity }: WebAlphaColor): PdfAlphaColor;
458
-
459
- /**
460
- * Stage of task
461
- *
462
- * @public
463
- */
464
- declare enum TaskStage {
465
- /**
466
- * Task is pending, means it just start executing
467
- */
468
- Pending = 0,
469
- /**
470
- * Task is succeed
471
- */
472
- Resolved = 1,
473
- /**
474
- * Task is failed
475
- */
476
- Rejected = 2,
477
- /**
478
- * Task is aborted
479
- */
480
- Aborted = 3
481
- }
482
- interface TaskError<D> {
483
- /**
484
- * task error type
485
- */
486
- type: 'reject' | 'abort';
487
- /**
488
- * task error
489
- */
490
- reason: D;
491
- }
492
- /**
493
- * callback that will be called when task is resolved
494
- *
495
- * @public
496
- */
497
- type ResolvedCallback<R> = (r: R) => void;
498
- /**
499
- * callback that will be called when task is rejected
500
- *
501
- * @public
502
- */
503
- type RejectedCallback<D> = (e: TaskError<D>) => void;
504
- /**
505
- * Task state in different stage
506
- *
507
- * @public
508
- */
509
- type TaskState<R, D> = {
510
- stage: TaskStage.Pending;
511
- } | {
512
- stage: TaskStage.Resolved;
513
- result: R;
514
- } | {
515
- stage: TaskStage.Rejected;
516
- reason: D;
517
- } | {
518
- stage: TaskStage.Aborted;
519
- reason: D;
520
- };
521
- /**
522
- * Result type for allSettled
523
- *
524
- * @public
525
- */
526
- type TaskSettledResult<R, D> = {
527
- status: 'resolved';
528
- value: R;
529
- } | {
530
- status: 'rejected';
531
- reason: D;
532
- } | {
533
- status: 'aborted';
534
- reason: D;
535
- };
536
- declare class TaskAbortedError<D> extends Error {
537
- constructor(reason: D);
538
- }
539
- declare class TaskRejectedError<D> extends Error {
540
- constructor(reason: D);
541
- }
542
- /**
543
- * Base class of task
544
- *
545
- * @public
546
- */
547
- declare class Task<R, D> {
548
- state: TaskState<R, D>;
549
- /**
550
- * callbacks that will be executed when task is resolved
551
- */
552
- resolvedCallbacks: ResolvedCallback<R>[];
553
- /**
554
- * callbacks that will be executed when task is rejected
555
- */
556
- rejectedCallbacks: RejectedCallback<D>[];
557
- /**
558
- * Promise that will be resolved when task is settled
559
- */
560
- private _promise;
561
- /**
562
- * Convert task to promise
563
- * @returns promise that will be resolved when task is settled
564
- */
565
- toPromise(): Promise<R>;
566
- /**
567
- * wait for task to be settled
568
- * @param resolvedCallback - callback for resolved value
569
- * @param rejectedCallback - callback for rejected value
570
- */
571
- wait(resolvedCallback: ResolvedCallback<R>, rejectedCallback: RejectedCallback<D>): void;
572
- /**
573
- * resolve task with specific result
574
- * @param result - result value
575
- */
576
- resolve(result: R): void;
577
- /**
578
- * reject task with specific reason
579
- * @param reason - abort reason
580
- *
581
- */
582
- reject(reason: D): void;
583
- /**
584
- * abort task with specific reason
585
- * @param reason - abort reason
586
- */
587
- abort(reason: D): void;
588
- /**
589
- * fail task with a TaskError from another task
590
- * This is a convenience method for error propagation between tasks
591
- * @param error - TaskError from another task
592
- */
593
- fail(error: TaskError<D>): void;
594
- /**
595
- * Static method to wait for all tasks to resolve
596
- * Returns a new task that resolves with an array of all results
597
- * Rejects immediately if any task fails
598
- *
599
- * @param tasks - array of tasks to wait for
600
- * @returns new task that resolves when all input tasks resolve
601
- * @public
602
- */
603
- static all<R extends readonly Task<any, any>[]>(tasks: R): Task<{
604
- [K in keyof R]: R[K] extends Task<infer U, any> ? U : never;
605
- }, any>;
606
- /**
607
- * Static method to wait for all tasks to settle (resolve, reject, or abort)
608
- * Always resolves with an array of settlement results
609
- *
610
- * @param tasks - array of tasks to wait for
611
- * @returns new task that resolves when all input tasks settle
612
- * @public
613
- */
614
- static allSettled<R extends readonly Task<any, any>[]>(tasks: R): Task<{
615
- [K in keyof R]: R[K] extends Task<infer U, infer E> ? TaskSettledResult<U, E> : never;
616
- }, never>;
617
- /**
618
- * Static method that resolves/rejects with the first task that settles
619
- *
620
- * @param tasks - array of tasks to race
621
- * @returns new task that settles with the first input task that settles
622
- * @public
623
- */
624
- static race<R extends readonly Task<any, any>[]>(tasks: R): Task<R[number] extends Task<infer U, any> ? U : never, R[number] extends Task<any, infer E> ? E : never>;
625
- /**
626
- * Utility to track progress of multiple tasks
627
- *
628
- * @param tasks - array of tasks to track
629
- * @param onProgress - callback called when any task completes
630
- * @returns new task that resolves when all input tasks resolve
631
- * @public
632
- */
633
- static withProgress<R extends readonly Task<any, any>[]>(tasks: R, onProgress?: (completed: number, total: number) => void): Task<{
634
- [K in keyof R]: R[K] extends Task<infer U, any> ? U : never;
635
- }, any>;
636
- }
637
- /**
638
- * Type that represent the result of executing task
639
- */
640
- type TaskReturn<T extends Task<any, any>> = T extends Task<infer R, infer E> ? {
641
- type: 'result';
642
- value: R;
643
- } | {
644
- type: 'error';
645
- value: TaskError<E>;
646
- } : never;
647
-
648
- /**
649
- * Representation of pdf page
650
- *
651
- * @public
652
- */
653
- interface PdfPageObject {
654
- /**
655
- * Index of this page, starts from 0
656
- */
657
- index: number;
658
- /**
659
- * Orignal size of this page
660
- */
661
- size: Size;
662
- }
663
- /**
664
- * Representation of pdf page with rotated size
665
- *
666
- * @public
667
- */
668
- interface PdfPageObjectWithRotatedSize extends PdfPageObject {
669
- /**
670
- * Rotated size of this page
671
- */
672
- rotatedSize: Size;
673
- }
674
- /**
675
- * Representation of pdf document
676
- *
677
- * @public
678
- */
679
- interface PdfDocumentObject {
680
- /**
681
- * Identity of document
682
- */
683
- id: string;
684
- /**
685
- * Count of pages in this document
686
- */
687
- pageCount: number;
688
- /**
689
- * Pages in this document
690
- */
691
- pages: PdfPageObject[];
692
- }
693
- /**
694
- * metadata of pdf document
695
- *
696
- * @public
697
- */
698
- interface PdfMetadataObject {
699
- /**
700
- * title of the document
701
- */
702
- title: string;
703
- /**
704
- * author of the document
705
- */
706
- author: string;
707
- /**
708
- * subject of the document
709
- */
710
- subject: string;
711
- /**
712
- * keywords of the document
713
- */
714
- keywords: string;
715
- /**
716
- * producer of the document
717
- */
718
- producer: string;
719
- /**
720
- * creator of the document
721
- */
722
- creator: string;
723
- /**
724
- * creation date of the document
725
- */
726
- creationDate: string;
727
- /**
728
- * modification date of the document
729
- */
730
- modificationDate: string;
731
- }
732
- /**
733
- * Unicode **soft-hyphen** marker (`U+00AD`).
734
- * Often embedded by PDF generators as discretionary hyphens.
735
- *
736
- * @public
737
- */
738
- declare const PdfSoftHyphenMarker = "\u00AD";
739
- /**
740
- * Unicode **zero-width space** (`U+200B`).
741
- *
742
- * @public
743
- */
744
- declare const PdfZeroWidthSpace = "\u200B";
745
- /**
746
- * Unicode **word-joiner** (`U+2060`) – zero-width no-break.
747
- *
748
- * @public
749
- */
750
- declare const PdfWordJoiner = "\u2060";
751
- /**
752
- * Unicode **byte-order mark / zero-width&nbsp;no-break space** (`U+FEFF`).
753
- *
754
- * @public
755
- */
756
- declare const PdfBomOrZwnbsp = "\uFEFF";
757
- /**
758
- * Unicode non-character `U+FFFE`.
759
- *
760
- * @public
761
- */
762
- declare const PdfNonCharacterFFFE = "\uFFFE";
763
- /**
764
- * Unicode non-character `U+FFFF`.
765
- *
766
- * @public
767
- */
768
- declare const PdfNonCharacterFFFF = "\uFFFF";
769
- /**
770
- * **Frozen list** of all unwanted markers in canonical order.
771
- *
772
- * @public
773
- */
774
- declare const PdfUnwantedTextMarkers: readonly ["­", "​", "⁠", "", "￾", "￿"];
775
- /**
776
- * Compiled regular expression that matches any unwanted marker.
777
- *
778
- * @public
779
- */
780
- declare const PdfUnwantedTextRegex: RegExp;
781
- /**
782
- * Remove all {@link PdfUnwantedTextMarkers | unwanted markers} from *text*.
783
- *
784
- * @param text - raw text extracted from PDF
785
- * @returns cleaned text
786
- *
787
- * @public
788
- */
789
- declare function stripPdfUnwantedMarkers(text: string): string;
790
- /**
791
- * zoom mode
792
- *
793
- * @public
794
- */
795
- declare enum PdfZoomMode {
796
- Unknown = 0,
797
- /**
798
- * Zoom level with specified offset.
799
- */
800
- XYZ = 1,
801
- /**
802
- * Fit both the width and height of the page (whichever smaller).
803
- */
804
- FitPage = 2,
805
- /**
806
- * Fit the page width.
807
- */
808
- FitHorizontal = 3,
809
- /**
810
- * Fit the page height.
811
- */
812
- FitVertical = 4,
813
- /**
814
- * Fit a specific rectangle area within the window.
815
- */
816
- FitRectangle = 5
817
- }
818
- /**
819
- * Representation of the linked destination
820
- *
821
- * @public
822
- */
823
- interface PdfDestinationObject {
824
- /**
825
- * Index of target page
826
- */
827
- pageIndex: number;
828
- /**
829
- * zoom config for target destination
830
- */
831
- zoom: {
832
- mode: PdfZoomMode.Unknown;
833
- } | {
834
- mode: PdfZoomMode.XYZ;
835
- params: {
836
- x: number;
837
- y: number;
838
- zoom: number;
839
- };
840
- } | {
841
- mode: PdfZoomMode.FitPage;
842
- } | {
843
- mode: PdfZoomMode.FitHorizontal;
844
- } | {
845
- mode: PdfZoomMode.FitVertical;
846
- } | {
847
- mode: PdfZoomMode.FitRectangle;
848
- };
849
- view: number[];
850
- }
851
- /**
852
- * Type of pdf action
853
- *
854
- * @public
855
- */
856
- declare enum PdfActionType {
857
- Unsupported = 0,
858
- /**
859
- * Goto specified position in this document
860
- */
861
- Goto = 1,
862
- /**
863
- * Goto specified position in another document
864
- */
865
- RemoteGoto = 2,
866
- /**
867
- * Goto specified URI
868
- */
869
- URI = 3,
870
- /**
871
- * Launch specifed application
872
- */
873
- LaunchAppOrOpenFile = 4
874
- }
875
- type PdfImage = {
876
- data: Uint8ClampedArray;
877
- width: number;
878
- height: number;
879
- };
880
- /**
881
- * Representation of pdf action
882
- *
883
- * @public
884
- */
885
- type PdfActionObject = {
886
- type: PdfActionType.Unsupported;
887
- } | {
888
- type: PdfActionType.Goto;
889
- destination: PdfDestinationObject;
890
- } | {
891
- type: PdfActionType.RemoteGoto;
892
- destination: PdfDestinationObject;
893
- } | {
894
- type: PdfActionType.URI;
895
- uri: string;
896
- } | {
897
- type: PdfActionType.LaunchAppOrOpenFile;
898
- path: string;
899
- };
900
- /**
901
- * target of pdf link
902
- *
903
- * @public
904
- */
905
- type PdfLinkTarget = {
906
- type: 'action';
907
- action: PdfActionObject;
908
- } | {
909
- type: 'destination';
910
- destination: PdfDestinationObject;
911
- };
912
- /**
913
- * PDF bookmark
914
- *
915
- * @public
916
- */
917
- interface PdfBookmarkObject {
918
- /**
919
- * title of bookmark
920
- */
921
- title: string;
922
- /**
923
- * target of bookmark
924
- */
925
- target?: PdfLinkTarget | undefined;
926
- /**
927
- * bookmarks in the next level
928
- */
929
- children?: PdfBookmarkObject[];
930
- }
931
- /**
932
- * Pdf Signature
933
- *
934
- * @public
935
- */
936
- interface PdfSignatureObject {
937
- /**
938
- * contents of signature
939
- */
940
- contents: ArrayBuffer;
941
- /**
942
- * byte range of signature
943
- */
944
- byteRange: ArrayBuffer;
945
- /**
946
- * sub filters of signature
947
- */
948
- subFilter: ArrayBuffer;
949
- /**
950
- * reason of signature
951
- */
952
- reason: string;
953
- /**
954
- * creation time of signature
955
- */
956
- time: string;
957
- /**
958
- * MDP
959
- */
960
- docMDP: number;
961
- }
962
- /**
963
- * Bookmark tree of pdf
964
- *
965
- * @public
966
- */
967
- interface PdfBookmarksObject {
968
- bookmarks: PdfBookmarkObject[];
969
- }
970
- /**
971
- * Text rectangle in pdf page
972
- *
973
- * @public
974
- */
975
- interface PdfTextRectObject {
976
- /**
977
- * Font of the text
978
- */
979
- font: {
980
- /**
981
- * font family
982
- */
983
- family: string;
984
- /**
985
- * font size
986
- */
987
- size: number;
988
- };
989
- /**
990
- * content in this rectangle area
991
- */
992
- content: string;
993
- /**
994
- * rectangle of the text
995
- */
996
- rect: Rect;
997
- }
998
- /**
999
- * Color
1000
- *
1001
- * @public
1002
- */
1003
- interface PdfAlphaColor {
1004
- /**
1005
- * red
1006
- */
1007
- red: number;
1008
- /**
1009
- * green
1010
- */
1011
- green: number;
1012
- /**
1013
- * blue
1014
- */
1015
- blue: number;
1016
- /**
1017
- * alpha
1018
- */
1019
- alpha: number;
1020
- }
1021
- /**
1022
- * Annotation type
1023
- *
1024
- * @public
1025
- */
1026
- declare enum PdfAnnotationSubtype {
1027
- UNKNOWN = 0,
1028
- TEXT = 1,
1029
- LINK = 2,
1030
- FREETEXT = 3,
1031
- LINE = 4,
1032
- SQUARE = 5,
1033
- CIRCLE = 6,
1034
- POLYGON = 7,
1035
- POLYLINE = 8,
1036
- HIGHLIGHT = 9,
1037
- UNDERLINE = 10,
1038
- SQUIGGLY = 11,
1039
- STRIKEOUT = 12,
1040
- STAMP = 13,
1041
- CARET = 14,
1042
- INK = 15,
1043
- POPUP = 16,
1044
- FILEATTACHMENT = 17,
1045
- SOUND = 18,
1046
- MOVIE = 19,
1047
- WIDGET = 20,
1048
- SCREEN = 21,
1049
- PRINTERMARK = 22,
1050
- TRAPNET = 23,
1051
- WATERMARK = 24,
1052
- THREED = 25,
1053
- RICHMEDIA = 26,
1054
- XFAWIDGET = 27,
1055
- REDACT = 28
1056
- }
1057
- /**
1058
- * Name of annotation type
1059
- *
1060
- * @public
1061
- */
1062
- declare const PdfAnnotationSubtypeName: Record<PdfAnnotationSubtype, string>;
1063
- /**
1064
- * Status of pdf annotation
1065
- *
1066
- * @public
1067
- */
1068
- declare enum PdfAnnotationObjectStatus {
1069
- /**
1070
- * Annotation is created
1071
- */
1072
- Created = 0,
1073
- /**
1074
- * Annotation is committed to PDF file
1075
- */
1076
- Committed = 1
1077
- }
1078
- /**
1079
- * Appearance mode
1080
- *
1081
- * @public
1082
- */
1083
- declare enum AppearanceMode {
1084
- Normal = 0,
1085
- Rollover = 1,
1086
- Down = 2
1087
- }
1088
- /**
1089
- * State of pdf annotation
1090
- *
1091
- * @public
1092
- */
1093
- declare enum PdfAnnotationState {
1094
- /**
1095
- * Annotation is active
1096
- */
1097
- Marked = "Marked",
1098
- /**
1099
- * Annotation is unmarked
1100
- */
1101
- Unmarked = "Unmarked",
1102
- /**
1103
- * Annotation is ink
1104
- */
1105
- Accepted = "Accepted",
1106
- /**
1107
- * Annotation is rejected
1108
- */
1109
- Rejected = "Rejected",
1110
- /**
1111
- * Annotation is complete
1112
- */
1113
- Complete = "Complete",
1114
- /**
1115
- * Annotation is cancelled
1116
- */
1117
- Cancelled = "Cancelled",
1118
- /**
1119
- * Annotation is none
1120
- */
1121
- None = "None"
1122
- }
1123
- /**
1124
- * State model of pdf annotation
1125
- *
1126
- * @public
1127
- */
1128
- declare enum PdfAnnotationStateModel {
1129
- /**
1130
- * Annotation is marked
1131
- */
1132
- Marked = "Marked",
1133
- /**
1134
- * Annotation is reviewed
1135
- */
1136
- Reviewed = "Reviewed"
1137
- }
1138
- /**
1139
- * Basic information of pdf annotation
1140
- *
1141
- * @public
1142
- */
1143
- interface PdfAnnotationObjectBase {
1144
- /**
1145
- * Author of the annotation
1146
- */
1147
- author?: string;
1148
- /**
1149
- * Modified date of the annotation
1150
- */
1151
- modified?: Date;
1152
- /**
1153
- * Sub type of annotation
1154
- */
1155
- type: PdfAnnotationSubtype;
1156
- /**
1157
- * The index of page that this annotation belong to
1158
- */
1159
- pageIndex: number;
1160
- /**
1161
- * id of the annotation
1162
- */
1163
- id: number;
1164
- /**
1165
- * Rectangle of the annotation
1166
- */
1167
- rect: Rect;
1168
- }
1169
- /**
1170
- * Popup annotation
1171
- *
1172
- * @public
1173
- */
1174
- interface PdfPopupAnnoObject extends PdfAnnotationObjectBase {
1175
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1176
- type: PdfAnnotationSubtype.POPUP;
1177
- /**
1178
- * Contents of the popup
1179
- */
1180
- contents: string;
1181
- /**
1182
- * Whether the popup is opened or not
1183
- */
1184
- open: boolean;
1185
- /**
1186
- * In reply to id
1187
- */
1188
- inReplyToId?: number;
1189
- }
1190
- /**
1191
- * Pdf Link annotation
1192
- *
1193
- * @public
1194
- */
1195
- interface PdfLinkAnnoObject extends PdfAnnotationObjectBase {
1196
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1197
- type: PdfAnnotationSubtype.LINK;
1198
- /**
1199
- * Text of the link
1200
- */
1201
- text: string;
1202
- /**
1203
- * target of the link
1204
- */
1205
- target: PdfLinkTarget | undefined;
1206
- }
1207
- /**
1208
- * Pdf Text annotation
1209
- *
1210
- * @public
1211
- */
1212
- interface PdfTextAnnoObject extends PdfAnnotationObjectBase {
1213
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1214
- type: PdfAnnotationSubtype.TEXT;
1215
- /**
1216
- * Text contents of the annotation
1217
- */
1218
- contents: string;
1219
- /**
1220
- * color of text annotation
1221
- */
1222
- color?: string;
1223
- /**
1224
- * opacity of text annotation
1225
- */
1226
- opacity?: number;
1227
- /**
1228
- * In reply to id
1229
- */
1230
- inReplyToId?: number;
1231
- /**
1232
- * State of the text annotation
1233
- */
1234
- state?: PdfAnnotationState;
1235
- /**
1236
- * State model of the text annotation
1237
- */
1238
- stateModel?: PdfAnnotationStateModel;
1239
- }
1240
- /**
1241
- * Type of form field
1242
- *
1243
- * @public
1244
- */
1245
- declare enum PDF_FORM_FIELD_TYPE {
1246
- /**
1247
- * Unknow
1248
- */
1249
- UNKNOWN = 0,
1250
- /**
1251
- * push button type
1252
- */
1253
- PUSHBUTTON = 1,
1254
- /**
1255
- * check box type.
1256
- */
1257
- CHECKBOX = 2,
1258
- /**
1259
- * radio button type.
1260
- */
1261
- RADIOBUTTON = 3,
1262
- /**
1263
- * combo box type.
1264
- */
1265
- COMBOBOX = 4,
1266
- /**
1267
- * list box type.
1268
- */
1269
- LISTBOX = 5,
1270
- /**
1271
- * text field type
1272
- */
1273
- TEXTFIELD = 6,
1274
- /**
1275
- * signature field type.
1276
- */
1277
- SIGNATURE = 7,
1278
- /**
1279
- * Generic XFA type.
1280
- */
1281
- XFA = 8,
1282
- /**
1283
- * XFA check box type.
1284
- */
1285
- XFA_CHECKBOX = 9,
1286
- /**
1287
- * XFA combo box type.
1288
- */
1289
- XFA_COMBOBOX = 10,
1290
- /**
1291
- * XFA image field type.
1292
- */
1293
- XFA_IMAGEFIELD = 11,
1294
- /**
1295
- * XFA list box type.
1296
- */
1297
- XFA_LISTBOX = 12,
1298
- /**
1299
- * XFA push button type.
1300
- */
1301
- XFA_PUSHBUTTON = 13,
1302
- /**
1303
- * XFA signture field type.
1304
- */
1305
- XFA_SIGNATURE = 14,
1306
- /**
1307
- * XFA text field type.
1308
- */
1309
- XFA_TEXTFIELD = 15
1310
- }
1311
- declare enum PdfAnnotationColorType {
1312
- Color = 0,
1313
- InteriorColor = 1
1314
- }
1315
- /**
1316
- * Border style of pdf annotation
1317
- *
1318
- * @public
1319
- */
1320
- declare enum PdfAnnotationBorderStyle {
1321
- UNKNOWN = 0,
1322
- SOLID = 1,
1323
- DASHED = 2,
1324
- BEVELED = 3,
1325
- INSET = 4,
1326
- UNDERLINE = 5,
1327
- CLOUDY = 6
1328
- }
1329
- /**
1330
- * Flag of pdf annotation
1331
- *
1332
- * @public
1333
- */
1334
- declare enum PdfAnnotationFlags {
1335
- NONE = 0,
1336
- INVISIBLE = 1,
1337
- HIDDEN = 2,
1338
- PRINT = 4,
1339
- NO_ZOOM = 8,
1340
- NO_ROTATE = 16,
1341
- NO_VIEW = 32,
1342
- READ_ONLY = 64,
1343
- LOCKED = 128,
1344
- TOGGLE_NOVIEW = 256
1345
- }
1346
- /**
1347
- * Flag of form field
1348
- *
1349
- * @public
1350
- */
1351
- declare enum PDF_FORM_FIELD_FLAG {
1352
- NONE = 0,
1353
- READONLY = 1,
1354
- REQUIRED = 2,
1355
- NOEXPORT = 4,
1356
- TEXT_MULTIPLINE = 4096,
1357
- TEXT_PASSWORD = 8192,
1358
- CHOICE_COMBO = 131072,
1359
- CHOICE_EDIT = 262144,
1360
- CHOICE_MULTL_SELECT = 2097152
1361
- }
1362
- /**
1363
- * Type of pdf object
1364
- *
1365
- * @public
1366
- */
1367
- declare enum PdfPageObjectType {
1368
- UNKNOWN = 0,
1369
- TEXT = 1,
1370
- PATH = 2,
1371
- IMAGE = 3,
1372
- SHADING = 4,
1373
- FORM = 5
1374
- }
1375
- /**
1376
- * Options of pdf widget annotation
1377
- *
1378
- * @public
1379
- */
1380
- interface PdfWidgetAnnoOption {
1381
- label: string;
1382
- isSelected: boolean;
1383
- }
1384
- type FlagMap = Partial<Record<Exclude<PdfAnnotationFlags, PdfAnnotationFlags.NONE>, PdfAnnotationFlagName>>;
1385
- type PdfAnnotationFlagName = 'invisible' | 'hidden' | 'print' | 'noZoom' | 'noRotate' | 'noView' | 'readOnly' | 'locked' | 'toggleNoView';
1386
- declare const PdfAnnotationFlagName: Readonly<FlagMap>;
1387
- /**
1388
- * Convert the raw bit-mask coming from `FPDFAnnot_GetFlags()` into
1389
- * an array of human-readable flag names (“invisible”, “print”…).
1390
- */
1391
- declare function flagsToNames(raw: number): PdfAnnotationFlagName[];
1392
- /**
1393
- * Convert an array of flag-names back into the numeric mask that
1394
- * PDFium expects for `FPDFAnnot_SetFlags()`.
1395
- */
1396
- declare function namesToFlags(names: readonly PdfAnnotationFlagName[]): PdfAnnotationFlags;
1397
- /**
1398
- * Field of PDF widget annotation
1399
- *
1400
- * @public
1401
- */
1402
- interface PdfWidgetAnnoField {
1403
- /**
1404
- * flag of field
1405
- */
1406
- flag: PDF_FORM_FIELD_FLAG;
1407
- /**
1408
- * name of field
1409
- */
1410
- name: string;
1411
- /**
1412
- * alternate name of field
1413
- */
1414
- alternateName: string;
1415
- /**
1416
- * type of field
1417
- */
1418
- type: PDF_FORM_FIELD_TYPE;
1419
- /**
1420
- * value of field
1421
- */
1422
- value: string;
1423
- /**
1424
- * whether field is checked
1425
- */
1426
- isChecked: boolean;
1427
- /**
1428
- * options of field
1429
- */
1430
- options: PdfWidgetAnnoOption[];
1431
- }
1432
- /**
1433
- * PDF widget object
1434
- *
1435
- * @public
1436
- */
1437
- interface PdfWidgetAnnoObject extends PdfAnnotationObjectBase {
1438
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1439
- type: PdfAnnotationSubtype.WIDGET;
1440
- /**
1441
- * Field of pdf widget object
1442
- */
1443
- field: PdfWidgetAnnoField;
1444
- }
1445
- /**
1446
- * Pdf file attachments annotation
1447
- *
1448
- * @public
1449
- */
1450
- interface PdfFileAttachmentAnnoObject extends PdfAnnotationObjectBase {
1451
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1452
- type: PdfAnnotationSubtype.FILEATTACHMENT;
1453
- }
1454
- /**
1455
- * ink list in pdf ink annotation
1456
- *
1457
- * @public
1458
- */
1459
- interface PdfInkListObject {
1460
- points: Position[];
1461
- }
1462
- /**
1463
- * Pdf ink annotation
1464
- *
1465
- * @public
1466
- */
1467
- interface PdfInkAnnoObject extends PdfAnnotationObjectBase {
1468
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1469
- type: PdfAnnotationSubtype.INK;
1470
- /**
1471
- * ink list of annotation
1472
- */
1473
- inkList: PdfInkListObject[];
1474
- /**
1475
- * color of ink annotation
1476
- */
1477
- color: string;
1478
- /**
1479
- * opacity of ink annotation
1480
- */
1481
- opacity: number;
1482
- /**
1483
- * stroke-width of ink annotation
1484
- */
1485
- strokeWidth: number;
1486
- }
1487
- /**
1488
- * Pdf polygon annotation
1489
- *
1490
- * @public
1491
- */
1492
- interface PdfPolygonAnnoObject extends PdfAnnotationObjectBase {
1493
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1494
- type: PdfAnnotationSubtype.POLYGON;
1495
- /**
1496
- * vertices of annotation
1497
- */
1498
- vertices: Position[];
1499
- }
1500
- /**
1501
- * PDF polyline annotation
1502
- *
1503
- * @public
1504
- */
1505
- interface PdfPolylineAnnoObject extends PdfAnnotationObjectBase {
1506
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1507
- type: PdfAnnotationSubtype.POLYLINE;
1508
- /**
1509
- * vertices of annotation
1510
- */
1511
- vertices: Position[];
1512
- }
1513
- /**
1514
- * PDF line annotation
1515
- *
1516
- * @public
1517
- */
1518
- interface PdfLineAnnoObject extends PdfAnnotationObjectBase {
1519
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1520
- type: PdfAnnotationSubtype.LINE;
1521
- /**
1522
- * start point of line
1523
- */
1524
- startPoint: Position;
1525
- /**
1526
- * end point of line
1527
- */
1528
- endPoint: Position;
1529
- }
1530
- /**
1531
- * PDF highlight annotation
1532
- *
1533
- * @public
1534
- */
1535
- interface PdfHighlightAnnoObject extends PdfAnnotationObjectBase {
1536
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1537
- type: PdfAnnotationSubtype.HIGHLIGHT;
1538
- /**
1539
- * Text contents of the highlight annotation
1540
- */
1541
- contents?: string;
1542
- /**
1543
- * color of highlight annotation
1544
- */
1545
- color: string;
1546
- /**
1547
- * opacity of highlight annotation
1548
- */
1549
- opacity: number;
1550
- /**
1551
- * quads of highlight area
1552
- */
1553
- segmentRects: Rect[];
1554
- }
1555
- /**
1556
- * Matrix for transformation, in the form [a b c d e f], equivalent to:
1557
- * | a b 0 |
1558
- * | c d 0 |
1559
- * | e f 1 |
1560
- *
1561
- * Translation is performed with [1 0 0 1 tx ty].
1562
- * Scaling is performed with [sx 0 0 sy 0 0].
1563
- * See PDF Reference 1.7, 4.2.2 Common Transformations for more.
1564
- */
1565
- interface PdfTransformMatrix {
1566
- a: number;
1567
- b: number;
1568
- c: number;
1569
- d: number;
1570
- e: number;
1571
- f: number;
1572
- }
1573
- /**
1574
- * type of segment type in pdf path object
1575
- *
1576
- * @public
1577
- */
1578
- declare enum PdfSegmentObjectType {
1579
- UNKNOWN = -1,
1580
- LINETO = 0,
1581
- BEZIERTO = 1,
1582
- MOVETO = 2
1583
- }
1584
- /**
1585
- * segment of path object
1586
- *
1587
- * @public
1588
- */
1589
- interface PdfSegmentObject {
1590
- type: PdfSegmentObjectType;
1591
- /**
1592
- * point of the segment
1593
- */
1594
- point: Position;
1595
- /**
1596
- * whether this segment close the path
1597
- */
1598
- isClosed: boolean;
1599
- }
1600
- /**
1601
- * Pdf path object
1602
- *
1603
- * @public
1604
- */
1605
- interface PdfPathObject {
1606
- type: PdfPageObjectType.PATH;
1607
- /**
1608
- * bound that contains the path
1609
- */
1610
- bounds: {
1611
- left: number;
1612
- bottom: number;
1613
- right: number;
1614
- top: number;
1615
- };
1616
- /**
1617
- * segments of the path
1618
- */
1619
- segments: PdfSegmentObject[];
1620
- /**
1621
- * transform matrix
1622
- */
1623
- matrix: PdfTransformMatrix;
1624
- }
1625
- /**
1626
- * Pdf image object
1627
- *
1628
- * @public
1629
- */
1630
- interface PdfImageObject {
1631
- type: PdfPageObjectType.IMAGE;
1632
- /**
1633
- * data of the image
1634
- */
1635
- imageData: ImageData;
1636
- /**
1637
- * transform matrix
1638
- */
1639
- matrix: PdfTransformMatrix;
1640
- }
1641
- /**
1642
- * Pdf form object
1643
- *
1644
- * @public
1645
- */
1646
- interface PdfFormObject {
1647
- type: PdfPageObjectType.FORM;
1648
- /**
1649
- * objects that in this form object
1650
- */
1651
- objects: (PdfImageObject | PdfPathObject | PdfFormObject)[];
1652
- /**
1653
- * transform matrix
1654
- */
1655
- matrix: PdfTransformMatrix;
1656
- }
1657
- /**
1658
- * Contents type of pdf stamp annotation
1659
- *
1660
- * @public
1661
- */
1662
- type PdfStampAnnoObjectContents = Array<PdfPathObject | PdfImageObject | PdfFormObject>;
1663
- /**
1664
- * Pdf stamp annotation
1665
- *
1666
- * @public
1667
- */
1668
- interface PdfStampAnnoObject extends PdfAnnotationObjectBase {
1669
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1670
- type: PdfAnnotationSubtype.STAMP;
1671
- /**
1672
- * contents in this stamp annotation
1673
- */
1674
- contents: PdfStampAnnoObjectContents;
1675
- }
1676
- /**
1677
- * Pdf circle annotation
1678
- *
1679
- * @public
1680
- */
1681
- interface PdfCircleAnnoObject extends PdfAnnotationObjectBase {
1682
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1683
- type: PdfAnnotationSubtype.CIRCLE;
1684
- /**
1685
- * flags of circle annotation
1686
- */
1687
- flags: PdfAnnotationFlagName[];
1688
- /**
1689
- * color of circle annotation
1690
- */
1691
- color: string;
1692
- /**
1693
- * opacity of circle annotation
1694
- */
1695
- opacity: number;
1696
- /**
1697
- * stroke-width of circle annotation
1698
- */
1699
- strokeWidth: number;
1700
- /**
1701
- * stroke color of circle annotation
1702
- */
1703
- strokeColor: string;
1704
- /**
1705
- * stroke style of circle annotation
1706
- */
1707
- strokeStyle: PdfAnnotationBorderStyle;
1708
- /**
1709
- * stroke dash array of circle annotation
1710
- */
1711
- strokeDashArray?: number[];
1712
- /**
1713
- * cloudy border intensity of circle annotation
1714
- */
1715
- cloudyBorderIntensity?: number;
1716
- /**
1717
- * cloudy border inset of circle annotation
1718
- */
1719
- cloudyBorderInset?: number[];
1720
- }
1721
- /**
1722
- * Pdf square annotation
1723
- *
1724
- * @public
1725
- */
1726
- interface PdfSquareAnnoObject extends PdfAnnotationObjectBase {
1727
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1728
- type: PdfAnnotationSubtype.SQUARE;
1729
- /**
1730
- * flags of square annotation
1731
- */
1732
- flags: PdfAnnotationFlagName[];
1733
- /**
1734
- * color of square annotation
1735
- */
1736
- color: string;
1737
- /**
1738
- * opacity of square annotation
1739
- */
1740
- opacity: number;
1741
- /**
1742
- * stroke-width of square annotation
1743
- */
1744
- strokeWidth: number;
1745
- /**
1746
- * stroke color of square annotation
1747
- */
1748
- strokeColor: string;
1749
- /**
1750
- * stroke style of square annotation
1751
- */
1752
- strokeStyle: PdfAnnotationBorderStyle;
1753
- /**
1754
- * stroke dash array of square annotation
1755
- */
1756
- strokeDashArray?: number[];
1757
- /**
1758
- * cloudy border intensity of circle annotation
1759
- */
1760
- cloudyBorderIntensity?: number;
1761
- /**
1762
- * cloudy border inset of circle annotation
1763
- */
1764
- cloudyBorderInset?: number[];
1765
- }
1766
- /**
1767
- * Pdf squiggly annotation
1768
- *
1769
- * @public
1770
- */
1771
- interface PdfSquigglyAnnoObject extends PdfAnnotationObjectBase {
1772
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1773
- type: PdfAnnotationSubtype.SQUIGGLY;
1774
- /**
1775
- * Text contents of the highlight annotation
1776
- */
1777
- contents?: string;
1778
- /**
1779
- * color of strike out annotation
1780
- */
1781
- color: string;
1782
- /**
1783
- * opacity of strike out annotation
1784
- */
1785
- opacity: number;
1786
- /**
1787
- * quads of highlight area
1788
- */
1789
- segmentRects: Rect[];
1790
- }
1791
- /**
1792
- * Pdf underline annotation
1793
- *
1794
- * @public
1795
- */
1796
- interface PdfUnderlineAnnoObject extends PdfAnnotationObjectBase {
1797
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1798
- type: PdfAnnotationSubtype.UNDERLINE;
1799
- /**
1800
- * Text contents of the highlight annotation
1801
- */
1802
- contents?: string;
1803
- /**
1804
- * color of strike out annotation
1805
- */
1806
- color: string;
1807
- /**
1808
- * opacity of strike out annotation
1809
- */
1810
- opacity: number;
1811
- /**
1812
- * quads of highlight area
1813
- */
1814
- segmentRects: Rect[];
1815
- }
1816
- /**
1817
- * Pdf strike out annotation
1818
- *
1819
- * @public
1820
- */
1821
- interface PdfStrikeOutAnnoObject extends PdfAnnotationObjectBase {
1822
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1823
- type: PdfAnnotationSubtype.STRIKEOUT;
1824
- /**
1825
- * Text contents of the strike out annotation
1826
- */
1827
- contents?: string;
1828
- /**
1829
- * color of strike out annotation
1830
- */
1831
- color: string;
1832
- /**
1833
- * opacity of strike out annotation
1834
- */
1835
- opacity: number;
1836
- /**
1837
- * quads of highlight area
1838
- */
1839
- segmentRects: Rect[];
1840
- }
1841
- /**
1842
- * Pdf caret annotation
1843
- *
1844
- * @public
1845
- */
1846
- interface PdfCaretAnnoObject extends PdfAnnotationObjectBase {
1847
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1848
- type: PdfAnnotationSubtype.CARET;
1849
- }
1850
- /**
1851
- * Pdf free text annotation
1852
- *
1853
- * @public
1854
- */
1855
- interface PdfFreeTextAnnoObject extends PdfAnnotationObjectBase {
1856
- /** {@inheritDoc PdfAnnotationObjectBase.type} */
1857
- type: PdfAnnotationSubtype.FREETEXT;
1858
- contents: string;
1859
- }
1860
- /**
1861
- * All annotation that support
1862
- *
1863
- * @public
1864
- */
1865
- type PdfSupportedAnnoObject = PdfInkAnnoObject | PdfTextAnnoObject | PdfLinkAnnoObject | PdfPolygonAnnoObject | PdfPolylineAnnoObject | PdfHighlightAnnoObject | PdfLineAnnoObject | PdfWidgetAnnoObject | PdfFileAttachmentAnnoObject | PdfStampAnnoObject | PdfSquareAnnoObject | PdfCircleAnnoObject | PdfSquigglyAnnoObject | PdfUnderlineAnnoObject | PdfStrikeOutAnnoObject | PdfCaretAnnoObject | PdfFreeTextAnnoObject;
1866
- /**
1867
- * Pdf annotation that does not support
1868
- *
1869
- * @public
1870
- */
1871
- interface PdfUnsupportedAnnoObject extends PdfAnnotationObjectBase {
1872
- type: Exclude<PdfAnnotationSubtype, PdfSupportedAnnoObject['type']>;
1873
- }
1874
- /**
1875
- * all annotations
1876
- *
1877
- * @public
1878
- */
1879
- type PdfAnnotationObject = PdfSupportedAnnoObject | PdfUnsupportedAnnoObject;
1880
- /**
1881
- * Pdf attachment
1882
- *
1883
- * @public
1884
- */
1885
- interface PdfAttachmentObject {
1886
- index: number;
1887
- name: string;
1888
- creationDate: string;
1889
- checksum: string;
1890
- }
1891
- /**
1892
- * Pdf engine features
1893
- *
1894
- * @public
1895
- */
1896
- declare enum PdfEngineFeature {
1897
- RenderPage = 0,
1898
- RenderPageRect = 1,
1899
- Thumbnails = 2,
1900
- Bookmarks = 3,
1901
- Annotations = 4
1902
- }
1903
- /**
1904
- * All operations for this engine
1905
- *
1906
- * @public
1907
- */
1908
- declare enum PdfEngineOperation {
1909
- Create = 0,
1910
- Read = 1,
1911
- Update = 2,
1912
- Delete = 3
1913
- }
1914
- /**
1915
- * flags to match the text during searching
1916
- *
1917
- * @public
1918
- */
1919
- declare enum MatchFlag {
1920
- None = 0,
1921
- MatchCase = 1,
1922
- MatchWholeWord = 2,
1923
- MatchConsecutive = 4
1924
- }
1925
- /**
1926
- * Union all the flags
1927
- * @param flags - all the flags
1928
- * @returns union of flags
1929
- *
1930
- * @public
1931
- */
1932
- declare function unionFlags(flags: MatchFlag[]): MatchFlag;
1933
- /**
1934
- * Image conversion types
1935
- *
1936
- * @public
1937
- */
1938
- type ImageConversionTypes = 'image/webp' | 'image/png' | 'image/jpeg';
1939
- /**
1940
- * Targe for searching
1941
- *
1942
- * @public
1943
- */
1944
- interface SearchTarget {
1945
- keyword: string;
1946
- flags: MatchFlag[];
1947
- }
1948
- /**
1949
- * compare 2 search target
1950
- * @param targetA - first target for search
1951
- * @param targetB - second target for search
1952
- * @returns whether 2 search target are the same
1953
- *
1954
- * @public
1955
- */
1956
- declare function compareSearchTarget(targetA: SearchTarget, targetB: SearchTarget): boolean;
1957
- /** Context of one hit */
1958
- interface TextContext {
1959
- /** Complete words that come *before* the hit (no ellipsis) */
1960
- before: string;
1961
- /** Exactly the text that matched (case-preserved) */
1962
- match: string;
1963
- /** Complete words that come *after* the hit (no ellipsis) */
1964
- after: string;
1965
- /** `true` ⇢ there were more words on the left that we cut off */
1966
- truncatedLeft: boolean;
1967
- /** `true` ⇢ there were more words on the right that we cut off */
1968
- truncatedRight: boolean;
1969
- }
1970
- /**
1971
- * Text slice
1972
- *
1973
- * @public
1974
- */
1975
- interface PageTextSlice {
1976
- /**
1977
- * Index of the pdf page
1978
- */
1979
- pageIndex: number;
1980
- /**
1981
- * Index of the first character
1982
- */
1983
- charIndex: number;
1984
- /**
1985
- * Count of the characters
1986
- */
1987
- charCount: number;
1988
- }
1989
- /**
1990
- * search result
1991
- *
1992
- * @public
1993
- */
1994
- interface SearchResult {
1995
- /**
1996
- * Index of the pdf page
1997
- */
1998
- pageIndex: number;
1999
- /**
2000
- * index of the first character
2001
- */
2002
- charIndex: number;
2003
- /**
2004
- * count of the characters
2005
- */
2006
- charCount: number;
2007
- /**
2008
- * highlight rects
2009
- */
2010
- rects: Rect[];
2011
- /**
2012
- * context of the hit
2013
- */
2014
- context: TextContext;
2015
- }
2016
- /**
2017
- * Results of searching through the entire document
2018
- */
2019
- interface SearchAllPagesResult {
2020
- /**
2021
- * Array of all search results across all pages
2022
- */
2023
- results: SearchResult[];
2024
- /**
2025
- * Total number of results found
2026
- */
2027
- total: number;
2028
- }
2029
- /**
2030
- * Glyph object
2031
- *
2032
- * @public
2033
- */
2034
- interface PdfGlyphObject {
2035
- /**
2036
- * Origin of the glyph
2037
- */
2038
- origin: {
2039
- x: number;
2040
- y: number;
2041
- };
2042
- /**
2043
- * Size of the glyph
2044
- */
2045
- size: {
2046
- width: number;
2047
- height: number;
2048
- };
2049
- /**
2050
- * Whether the glyph is a space
2051
- */
2052
- isSpace?: boolean;
2053
- /**
2054
- * Whether the glyph is a empty
2055
- */
2056
- isEmpty?: boolean;
2057
- }
2058
- /**
2059
- * Glyph object
2060
- *
2061
- * @public
2062
- */
2063
- interface PdfGlyphSlim {
2064
- /**
2065
- * X coordinate of the glyph
2066
- */
2067
- x: number;
2068
- /**
2069
- * Y coordinate of the glyph
2070
- */
2071
- y: number;
2072
- /**
2073
- * Width of the glyph
2074
- */
2075
- width: number;
2076
- /**
2077
- * Height of the glyph
2078
- */
2079
- height: number;
2080
- /**
2081
- * Flags of the glyph
2082
- */
2083
- flags: number;
2084
- }
2085
- /**
2086
- * Run object
2087
- *
2088
- * @public
2089
- */
2090
- interface PdfRun {
2091
- /**
2092
- * Rectangle of the run
2093
- */
2094
- rect: {
2095
- x: number;
2096
- y: number;
2097
- width: number;
2098
- height: number;
2099
- };
2100
- /**
2101
- * Start index of the run
2102
- */
2103
- charStart: number;
2104
- /**
2105
- * Glyphs of the run
2106
- */
2107
- glyphs: PdfGlyphSlim[];
2108
- }
2109
- /**
2110
- * Page geometry
2111
- *
2112
- * @public
2113
- */
2114
- interface PdfPageGeometry {
2115
- /**
2116
- * Runs of the page
2117
- */
2118
- runs: PdfRun[];
2119
- }
2120
- /**
2121
- * form field value
2122
- * @public
2123
- */
2124
- type FormFieldValue = {
2125
- kind: 'text';
2126
- text: string;
2127
- } | {
2128
- kind: 'selection';
2129
- index: number;
2130
- isSelected: boolean;
2131
- } | {
2132
- kind: 'checked';
2133
- isChecked: boolean;
2134
- };
2135
- /**
2136
- * Transformation that will be applied to annotation
2137
- *
2138
- * @public
2139
- */
2140
- interface PdfAnnotationTransformation {
2141
- /**
2142
- * Translated offset
2143
- */
2144
- offset: Position;
2145
- /**
2146
- * Scaled factors
2147
- */
2148
- scale: Size;
2149
- }
2150
- /**
2151
- * Render options
2152
- *
2153
- * @public
2154
- */
2155
- interface PdfRenderOptions {
2156
- /**
2157
- * Whether needs to render the page with annotations
2158
- */
2159
- withAnnotations: boolean;
2160
- }
2161
- /**
2162
- * source can be byte array contains pdf content
2163
- *
2164
- * @public
2165
- */
2166
- type PdfFileContent = ArrayBuffer;
2167
- declare enum PdfPermission {
2168
- PrintDocument = 8,
2169
- ModifyContent = 16,
2170
- CopyOrExtract = 32,
2171
- AddOrModifyTextAnnot = 64,
2172
- FillInExistingForm = 512,
2173
- ExtractTextOrGraphics = 1024,
2174
- AssembleDocument = 2048,
2175
- PrintHighQuality = 4096
2176
- }
2177
- declare enum PdfPageFlattenFlag {
2178
- Display = 0,
2179
- Print = 1
2180
- }
2181
- declare enum PdfPageFlattenResult {
2182
- Fail = 0,
2183
- Success = 1,
2184
- NothingToDo = 2
2185
- }
2186
- /**
2187
- * Pdf File without content
2188
- *
2189
- * @public
2190
- */
2191
- interface PdfFileWithoutContent {
2192
- /**
2193
- * id of file
2194
- */
2195
- id: string;
2196
- }
2197
- interface PdfFileLoader extends PdfFileWithoutContent {
2198
- /**
2199
- * length of file
2200
- */
2201
- fileLength: number;
2202
- /**
2203
- * read block of file
2204
- * @param offset - offset of file
2205
- * @param length - length of file
2206
- * @returns block of file
2207
- */
2208
- callback: (offset: number, length: number) => Uint8Array;
2209
- }
2210
- /**
2211
- * Pdf File
2212
- *
2213
- * @public
2214
- */
2215
- interface PdfFile extends PdfFileWithoutContent {
2216
- /**
2217
- * content of file
2218
- */
2219
- content: PdfFileContent;
2220
- }
2221
- interface PdfFileUrl extends PdfFileWithoutContent {
2222
- url: string;
2223
- }
2224
- interface PdfUrlOptions {
2225
- mode?: 'auto' | 'range-request' | 'full-fetch';
2226
- password?: string;
2227
- }
2228
- declare enum PdfErrorCode {
2229
- Ok = 0,// #define FPDF_ERR_SUCCESS 0 // No error.
2230
- Unknown = 1,// #define FPDF_ERR_UNKNOWN 1 // Unknown error.
2231
- NotFound = 2,// #define FPDF_ERR_FILE 2 // File not found or could not be opened.
2232
- WrongFormat = 3,// #define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
2233
- Password = 4,// #define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
2234
- Security = 5,// #define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
2235
- PageError = 6,// #define FPDF_ERR_PAGE 6 // Page not found or content error.
2236
- XFALoad = 7,// #ifdef PDF_ENABLE_XFA
2237
- XFALayout = 8,//
2238
- Cancelled = 9,
2239
- Initialization = 10,
2240
- NotReady = 11,
2241
- NotSupport = 12,
2242
- LoadDoc = 13,
2243
- DocNotOpen = 14,
2244
- CantCloseDoc = 15,
2245
- CantCreateNewDoc = 16,
2246
- CantImportPages = 17,
2247
- CantCreateAnnot = 18,
2248
- CantSetAnnotRect = 19,
2249
- CantSetAnnotContent = 20,
2250
- CantRemoveInkList = 21,
2251
- CantAddInkStoke = 22,
2252
- CantReadAttachmentSize = 23,
2253
- CantReadAttachmentContent = 24,
2254
- CantFocusAnnot = 25,
2255
- CantSelectText = 26,
2256
- CantSelectOption = 27,
2257
- CantCheckField = 28
2258
- }
2259
- interface PdfErrorReason {
2260
- code: PdfErrorCode;
2261
- message: string;
2262
- }
2263
- type PdfEngineError = TaskError<PdfErrorReason>;
2264
- type PdfTask<R> = Task<R, PdfErrorReason>;
2265
- declare class PdfTaskHelper {
2266
- /**
2267
- * Create a task
2268
- * @returns new task
2269
- */
2270
- static create<R>(): Task<R, PdfErrorReason>;
2271
- /**
2272
- * Create a task that has been resolved with value
2273
- * @param result - resolved value
2274
- * @returns resolved task
2275
- */
2276
- static resolve<R>(result: R): Task<R, PdfErrorReason>;
2277
- /**
2278
- * Create a task that has been rejected with error
2279
- * @param reason - rejected error
2280
- * @returns rejected task
2281
- */
2282
- static reject<T = any>(reason: PdfErrorReason): Task<T, PdfErrorReason>;
2283
- /**
2284
- * Create a task that has been aborted with error
2285
- * @param reason - aborted error
2286
- * @returns aborted task
2287
- */
2288
- static abort<T = any>(reason: PdfErrorReason): Task<T, PdfErrorReason>;
2289
- }
2290
- /**
2291
- * Pdf engine
2292
- *
2293
- * @public
2294
- */
2295
- interface PdfEngine<T = Blob> {
2296
- /**
2297
- * Check whether pdf engine supports this feature
2298
- * @param feature - which feature want to check
2299
- * @returns support or not
2300
- */
2301
- isSupport?: (feature: PdfEngineFeature) => PdfTask<PdfEngineOperation[]>;
2302
- /**
2303
- * Initialize the engine
2304
- * @returns task that indicate whether initialization is successful
2305
- */
2306
- initialize?: () => PdfTask<boolean>;
2307
- /**
2308
- * Destroy the engine
2309
- * @returns task that indicate whether destroy is successful
2310
- */
2311
- destroy?: () => PdfTask<boolean>;
2312
- /**
2313
- * Open a PDF from a URL with specified mode
2314
- * @param url - The PDF file URL
2315
- * @param options - Additional options including mode (auto, range-request, full-fetch) and password
2316
- * @returns Task that resolves with the PdfDocumentObject or an error
2317
- */
2318
- openDocumentUrl: (file: PdfFileUrl, options?: PdfUrlOptions) => PdfTask<PdfDocumentObject>;
2319
- /**
2320
- * Open pdf document from buffer
2321
- * @param file - pdf file
2322
- * @param password - protected password for this file
2323
- * @returns task that contains the file or error
2324
- */
2325
- openDocumentFromBuffer: (file: PdfFile, password: string) => PdfTask<PdfDocumentObject>;
2326
- /**
2327
- * Open pdf document from loader
2328
- * @param file - pdf file
2329
- * @param password - protected password for this file
2330
- * @returns task that contains the file or error
2331
- */
2332
- openDocumentFromLoader: (file: PdfFileLoader, password: string) => PdfTask<PdfDocumentObject>;
2333
- /**
2334
- * Get the metadata of the file
2335
- * @param doc - pdf document
2336
- * @returns task that contains the metadata or error
2337
- */
2338
- getMetadata: (doc: PdfDocumentObject) => PdfTask<PdfMetadataObject>;
2339
- /**
2340
- * Get permissions of the file
2341
- * @param doc - pdf document
2342
- * @returns task that contains a 32-bit integer indicating permission flags
2343
- */
2344
- getDocPermissions: (doc: PdfDocumentObject) => PdfTask<number>;
2345
- /**
2346
- * Get the user permissions of the file
2347
- * @param doc - pdf document
2348
- * @returns task that contains a 32-bit integer indicating permission flags
2349
- */
2350
- getDocUserPermissions: (doc: PdfDocumentObject) => PdfTask<number>;
2351
- /**
2352
- * Get the signatures of the file
2353
- * @param doc - pdf document
2354
- * @returns task that contains the signatures or error
2355
- */
2356
- getSignatures: (doc: PdfDocumentObject) => PdfTask<PdfSignatureObject[]>;
2357
- /**
2358
- * Get the bookmarks of the file
2359
- * @param doc - pdf document
2360
- * @returns task that contains the bookmarks or error
2361
- */
2362
- getBookmarks: (doc: PdfDocumentObject) => PdfTask<PdfBookmarksObject>;
2363
- /**
2364
- * Render the specified pdf page
2365
- * @param doc - pdf document
2366
- * @param page - pdf page
2367
- * @param scaleFactor - factor of scaling
2368
- * @param rotation - rotated angle
2369
- * @param dpr - devicePixelRatio
2370
- * @param options - render options
2371
- * @returns task contains the rendered image or error
2372
- */
2373
- renderPage: (doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation, dpr: number, options: PdfRenderOptions, imageType?: ImageConversionTypes) => PdfTask<T>;
2374
- /**
2375
- * Render the specified rect of pdf page
2376
- * @param doc - pdf document
2377
- * @param page - pdf page
2378
- * @param scaleFactor - factor of scaling
2379
- * @param rotation - rotated angle
2380
- * @param dpr - devicePixelRatio
2381
- * @param rect - target rect
2382
- * @param options - render options
2383
- * @returns task contains the rendered image or error
2384
- */
2385
- renderPageRect: (doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation, dpr: number, rect: Rect, options: PdfRenderOptions, imageType?: ImageConversionTypes) => PdfTask<T>;
2386
- /**
2387
- * Render a single annotation into an ImageData blob.
2388
- *
2389
- * Note: • honours Display-Matrix, page rotation & DPR
2390
- * • you decide whether to include the page background
2391
- * @param doc - pdf document
2392
- * @param page - pdf page
2393
- * @param annotation - the annotation to render
2394
- * @param scaleFactor - factor of scaling
2395
- * @param rotation - rotated angle
2396
- * @param dpr - devicePixelRatio
2397
- * @param mode - appearance mode
2398
- */
2399
- renderAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, scaleFactor: number, rotation: Rotation, dpr: number, mode: AppearanceMode, imageType: ImageConversionTypes): PdfTask<T>;
2400
- /**
2401
- * Get annotations of pdf page
2402
- * @param doc - pdf document
2403
- * @param page - pdf page
2404
- * @param scaleFactor - factor of scaling
2405
- * @param rotation - rotated angle
2406
- * @returns task contains the annotations or error
2407
- */
2408
- getPageAnnotations: (doc: PdfDocumentObject, page: PdfPageObject) => PdfTask<PdfAnnotationObject[]>;
2409
- /**
2410
- * Change the visible colour (and opacity) of an existing annotation.
2411
- * @param doc - pdf document
2412
- * @param page - pdf page
2413
- * @param annotation - the annotation to recolour
2414
- * @param colour - RGBA color values (0-255 per channel)
2415
- * @param which - 0 = stroke/fill colour (PDFium's "colourType" param)
2416
- * @returns task that indicates whether the operation succeeded
2417
- */
2418
- updateAnnotationColor: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObjectBase, color: WebAlphaColor, which?: number) => PdfTask<boolean>;
2419
- /**
2420
- * Create a annotation on specified page
2421
- * @param doc - pdf document
2422
- * @param page - pdf page
2423
- * @param annotation - new annotations
2424
- * @returns task whether the annotations is created successfully
2425
- */
2426
- createPageAnnotation: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject) => PdfTask<number>;
2427
- /**
2428
- * Update a annotation on specified page
2429
- * @param doc - pdf document
2430
- * @param page - pdf page
2431
- * @param annotation - new annotations
2432
- * @returns task that indicates whether the operation succeeded
2433
- */
2434
- updatePageAnnotation: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject) => PdfTask<boolean>;
2435
- /**
2436
- * Remove a annotation on specified page
2437
- * @param doc - pdf document
2438
- * @param page - pdf page
2439
- * @param annotation - new annotations
2440
- * @returns task whether the annotations is removed successfully
2441
- */
2442
- removePageAnnotation: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject) => PdfTask<boolean>;
2443
- /**
2444
- * get all text rects in pdf page
2445
- * @param doc - pdf document
2446
- * @param page - pdf page
2447
- * @param scaleFactor - factor of scaling
2448
- * @param rotation - rotated angle
2449
- * @returns task contains the text rects or error
2450
- */
2451
- getPageTextRects: (doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation) => PdfTask<PdfTextRectObject[]>;
2452
- /**
2453
- * Render the thumbnail of specified pdf page
2454
- * @param doc - pdf document
2455
- * @param page - pdf page
2456
- * @param scaleFactor - factor of scaling
2457
- * @param rotation - rotated angle
2458
- * @param dpr - devicePixelRatio
2459
- * @param options - render options
2460
- * @returns task contains the rendered image or error
2461
- */
2462
- renderThumbnail: (doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation, dpr: number) => PdfTask<T>;
2463
- /**
2464
- * Search across all pages in the document
2465
- * @param doc - pdf document
2466
- * @param keyword - search keyword
2467
- * @param flags - match flags for search
2468
- * @returns Task contains all search results throughout the document
2469
- */
2470
- searchAllPages: (doc: PdfDocumentObject, keyword: string, flags?: MatchFlag[]) => PdfTask<SearchAllPagesResult>;
2471
- /**
2472
- * Get all annotations in this file
2473
- * @param doc - pdf document
2474
- * @returns task that contains the annotations or error
2475
- */
2476
- getAllAnnotations: (doc: PdfDocumentObject) => PdfTask<Record<number, PdfAnnotationObject[]>>;
2477
- /**
2478
- * Get all attachments in this file
2479
- * @param doc - pdf document
2480
- * @returns task that contains the attachments or error
2481
- */
2482
- getAttachments: (doc: PdfDocumentObject) => PdfTask<PdfAttachmentObject[]>;
2483
- /**
2484
- * Read content of pdf attachment
2485
- * @param doc - pdf document
2486
- * @param attachment - pdf attachments
2487
- * @returns task that contains the content of specified attachment or error
2488
- */
2489
- readAttachmentContent: (doc: PdfDocumentObject, attachment: PdfAttachmentObject) => PdfTask<ArrayBuffer>;
2490
- /**
2491
- * Set form field value
2492
- * @param doc - pdf document
2493
- * @param page - pdf page
2494
- * @param annotation - pdf annotation
2495
- * @param text - text value
2496
- */
2497
- setFormFieldValue: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfWidgetAnnoObject, value: FormFieldValue) => PdfTask<boolean>;
2498
- /**
2499
- * Flatten annotations and form fields into the page contents.
2500
- * @param doc - pdf document
2501
- * @param page - pdf page
2502
- * @param flag - flatten flag
2503
- */
2504
- flattenPage: (doc: PdfDocumentObject, page: PdfPageObject, flag: PdfPageFlattenFlag) => PdfTask<PdfPageFlattenResult>;
2505
- /**
2506
- * Extract pdf pages to a new file
2507
- * @param doc - pdf document
2508
- * @param pageIndexes - indexes of pdf pages
2509
- * @returns task contains the new pdf file content
2510
- */
2511
- extractPages: (doc: PdfDocumentObject, pageIndexes: number[]) => PdfTask<ArrayBuffer>;
2512
- /**
2513
- * Extract text on specified pdf pages
2514
- * @param doc - pdf document
2515
- * @param pageIndexes - indexes of pdf pages
2516
- * @returns task contains the text
2517
- */
2518
- extractText: (doc: PdfDocumentObject, pageIndexes: number[]) => PdfTask<string>;
2519
- /**
2520
- * Extract text on specified pdf pages
2521
- * @param doc - pdf document
2522
- * @param pageIndexes - indexes of pdf pages
2523
- * @returns task contains the text
2524
- */
2525
- getTextSlices: (doc: PdfDocumentObject, slices: PageTextSlice[]) => PdfTask<string[]>;
2526
- /**
2527
- * Get all glyphs in the specified pdf page
2528
- * @param doc - pdf document
2529
- * @param page - pdf page
2530
- * @returns task contains the glyphs
2531
- */
2532
- getPageGlyphs: (doc: PdfDocumentObject, page: PdfPageObject) => PdfTask<PdfGlyphObject[]>;
2533
- /**
2534
- * Get the geometry of the specified pdf page
2535
- * @param doc - pdf document
2536
- * @param page - pdf page
2537
- * @returns task contains the geometry
2538
- */
2539
- getPageGeometry: (doc: PdfDocumentObject, page: PdfPageObject) => PdfTask<PdfPageGeometry>;
2540
- /**
2541
- * Merge multiple pdf documents
2542
- * @param files - all the pdf files
2543
- * @returns task contains the merged pdf file
2544
- */
2545
- merge: (files: PdfFile[]) => PdfTask<PdfFile>;
2546
- /**
2547
- * Merge specific pages from multiple PDF documents in a custom order
2548
- * @param mergeConfigs Array of configurations specifying which pages to merge from which documents
2549
- * @returns A PdfTask that resolves with the merged PDF file
2550
- * @public
2551
- */
2552
- mergePages: (mergeConfigs: Array<{
2553
- docId: string;
2554
- pageIndices: number[];
2555
- }>) => PdfTask<PdfFile>;
2556
- /**
2557
- * Save a copy of pdf document
2558
- * @param doc - pdf document
2559
- * @returns task contains the new pdf file content
2560
- */
2561
- saveAsCopy: (doc: PdfDocumentObject) => PdfTask<ArrayBuffer>;
2562
- /**
2563
- * Close pdf document
2564
- * @param doc - pdf document
2565
- * @returns task that file is closed or not
2566
- */
2567
- closeDocument: (doc: PdfDocumentObject) => PdfTask<boolean>;
2568
- }
2569
- /**
2570
- * Method name of PdfEngine interface
2571
- *
2572
- * @public
2573
- */
2574
- type PdfEngineMethodName = keyof Required<PdfEngine>;
2575
- /**
2576
- * Arguments of PdfEngine method
2577
- *
2578
- * @public
2579
- */
2580
- type PdfEngineMethodArgs<P extends PdfEngineMethodName> = Readonly<Parameters<Required<PdfEngine>[P]>>;
2581
- /**
2582
- * Return type of PdfEngine method
2583
- *
2584
- * @public
2585
- */
2586
- type PdfEngineMethodReturnType<P extends PdfEngineMethodName> = ReturnType<Required<PdfEngine>[P]>;
2587
-
2588
- /**
2589
- * Parse a PDF date string **D:YYYYMMDDHHmmSSOHH'mm'** to ISO-8601.
2590
- *
2591
- * Returns `undefined` if the input is malformed.
2592
- *
2593
- * @public
2594
- */
2595
- declare function pdfDateToDate(pdf?: string): Date | undefined;
2596
- /**
2597
- * Convert a date to a PDF date string
2598
- * @param date - date to convert
2599
- * @returns PDF date string
2600
- *
2601
- * @public
2602
- */
2603
- declare function dateToPdfDate(date?: Date): string;
2604
-
2605
1
  /**
2606
2
  * Library contains the common definitions of data types and logic
2607
3
  *
@@ -2611,12 +7,15 @@ declare function dateToPdfDate(date?: Date): string;
2611
7
  *
2612
8
  * @packageDocumentation
2613
9
  */
2614
-
10
+ export * from './geometry';
11
+ export * from './logger';
12
+ export * from './pdf';
13
+ export * from './task';
14
+ export * from './color';
15
+ export * from './date';
2615
16
  /**
2616
17
  * ignore will do nothing when called.
2617
18
  *
2618
19
  * @public
2619
20
  */
2620
- declare function ignore(): void;
2621
-
2622
- export { AllLogger, AppearanceMode, type Box, ConsoleLogger, type FormFieldValue, type ImageConversionTypes, LevelLogger, LogLevel, type Logger, MatchFlag, type Matrix, NoopLogger, PDF_FORM_FIELD_FLAG, PDF_FORM_FIELD_TYPE, type PageTextSlice, type PdfActionObject, PdfActionType, type PdfAlphaColor, PdfAnnotationBorderStyle, PdfAnnotationColorType, PdfAnnotationFlagName, PdfAnnotationFlags, type PdfAnnotationObject, type PdfAnnotationObjectBase, PdfAnnotationObjectStatus, PdfAnnotationState, PdfAnnotationStateModel, PdfAnnotationSubtype, PdfAnnotationSubtypeName, type PdfAnnotationTransformation, type PdfAttachmentObject, PdfBomOrZwnbsp, type PdfBookmarkObject, type PdfBookmarksObject, type PdfCaretAnnoObject, type PdfCircleAnnoObject, type PdfDestinationObject, type PdfDocumentObject, type PdfEngine, type PdfEngineError, PdfEngineFeature, type PdfEngineMethodArgs, type PdfEngineMethodName, type PdfEngineMethodReturnType, PdfEngineOperation, PdfErrorCode, type PdfErrorReason, type PdfFile, type PdfFileAttachmentAnnoObject, type PdfFileContent, type PdfFileLoader, type PdfFileUrl, type PdfFileWithoutContent, type PdfFormObject, type PdfFreeTextAnnoObject, type PdfGlyphObject, type PdfGlyphSlim, type PdfHighlightAnnoObject, type PdfImage, type PdfImageObject, type PdfInkAnnoObject, type PdfInkListObject, type PdfLineAnnoObject, type PdfLinkAnnoObject, type PdfLinkTarget, type PdfMetadataObject, PdfNonCharacterFFFE, PdfNonCharacterFFFF, PdfPageFlattenFlag, PdfPageFlattenResult, type PdfPageGeometry, type PdfPageObject, PdfPageObjectType, type PdfPageObjectWithRotatedSize, type PdfPathObject, PdfPermission, type PdfPolygonAnnoObject, type PdfPolylineAnnoObject, type PdfPopupAnnoObject, type PdfRenderOptions, type PdfRun, type PdfSegmentObject, PdfSegmentObjectType, type PdfSignatureObject, PdfSoftHyphenMarker, type PdfSquareAnnoObject, type PdfSquigglyAnnoObject, type PdfStampAnnoObject, type PdfStampAnnoObjectContents, type PdfStrikeOutAnnoObject, type PdfSupportedAnnoObject, type PdfTask, PdfTaskHelper, type PdfTextAnnoObject, type PdfTextRectObject, type PdfTransformMatrix, type PdfUnderlineAnnoObject, type PdfUnsupportedAnnoObject, PdfUnwantedTextMarkers, PdfUnwantedTextRegex, type PdfUrlOptions, type PdfWidgetAnnoField, type PdfWidgetAnnoObject, type PdfWidgetAnnoOption, PdfWordJoiner, PdfZeroWidthSpace, PdfZoomMode, PerfLogger, type Position, type Quad, type Rect, type RejectedCallback, type ResolvedCallback, Rotation, type SearchAllPagesResult, type SearchResult, type SearchTarget, type Size, Task, TaskAbortedError, type TaskError, TaskRejectedError, type TaskReturn, type TaskSettledResult, TaskStage, type TaskState, type TextContext, type WebAlphaColor, boundingRect, calculateAngle, calculateDegree, compareSearchTarget, dateToPdfDate, flagsToNames, ignore, makeMatrix, namesToFlags, pdfAlphaColorToWebAlphaColor, pdfDateToDate, quadToRect, rectToQuad, restoreOffset, restorePosition, restoreRect, rotatePosition, rotateRect, scalePosition, scaleRect, stripPdfUnwantedMarkers, swap, toIntPos, toIntRect, toIntSize, transformPosition, transformRect, transformSize, unionFlags, webAlphaColorToPdfAlphaColor };
21
+ export declare function ignore(): void;