unpdf 1.3.2 → 1.5.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.
Files changed (84) hide show
  1. package/README.md +22 -38
  2. package/dist/index.d.cts +1 -1
  3. package/dist/index.d.mts +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/pdfjs.mjs +107 -1
  6. package/dist/types/src/display/annotation_layer.d.ts +42 -17
  7. package/dist/types/src/display/annotation_storage.d.ts +10 -8
  8. package/dist/types/src/display/api.d.ts +93 -63
  9. package/dist/types/src/display/api_utils.d.ts +1 -1
  10. package/dist/types/src/display/binary_data_factory.d.ts +26 -0
  11. package/dist/types/src/display/canvas.d.ts +19 -16
  12. package/dist/types/src/display/canvas_dependency_tracker.d.ts +99 -27
  13. package/dist/types/src/display/canvas_factory.d.ts +3 -1
  14. package/dist/types/src/display/display_utils.d.ts +25 -2
  15. package/dist/types/src/display/draw_layer.d.ts +2 -6
  16. package/dist/types/src/display/editor/alt_text.d.ts +1 -1
  17. package/dist/types/src/display/editor/annotation_editor_layer.d.ts +11 -14
  18. package/dist/types/src/display/editor/color_picker.d.ts +2 -2
  19. package/dist/types/src/display/editor/comment.d.ts +32 -5
  20. package/dist/types/src/display/editor/draw.d.ts +3 -7
  21. package/dist/types/src/display/editor/drawers/freedraw.d.ts +4 -3
  22. package/dist/types/src/display/editor/drawers/highlight.d.ts +2 -1
  23. package/dist/types/src/display/editor/drawers/signaturedraw.d.ts +13 -13
  24. package/dist/types/src/display/editor/editor.d.ts +81 -26
  25. package/dist/types/src/display/editor/freetext.d.ts +3 -3
  26. package/dist/types/src/display/editor/highlight.d.ts +6 -4
  27. package/dist/types/src/display/editor/ink.d.ts +2 -1
  28. package/dist/types/src/display/editor/signature.d.ts +0 -5
  29. package/dist/types/src/display/editor/toolbar.d.ts +5 -3
  30. package/dist/types/src/display/editor/tools.d.ts +58 -4
  31. package/dist/types/src/display/fetch_stream.d.ts +3 -56
  32. package/dist/types/src/display/font_loader.d.ts +28 -1
  33. package/dist/types/src/display/network.d.ts +14 -80
  34. package/dist/types/src/display/network_stream.d.ts +2 -0
  35. package/dist/types/src/display/network_utils.d.ts +3 -3
  36. package/dist/types/src/display/node_stream.d.ts +2 -52
  37. package/dist/types/src/display/node_utils.d.ts +5 -19
  38. package/dist/types/src/display/obj_bin_transform_display.d.ts +67 -0
  39. package/dist/types/src/display/pages_mapper.d.ts +72 -0
  40. package/dist/types/src/display/pattern_helper.d.ts +9 -4
  41. package/dist/types/src/display/text_layer.d.ts +16 -10
  42. package/dist/types/src/display/text_layer_images.d.ts +10 -0
  43. package/dist/types/src/display/transport_stream.d.ts +8 -64
  44. package/dist/types/src/display/webgpu_mesh.d.ts +3 -0
  45. package/dist/types/src/display/worker_options.d.ts +2 -2
  46. package/dist/types/src/display/xfa_layer.d.ts +3 -3
  47. package/dist/types/src/pdf.d.ts +9 -1
  48. package/dist/types/src/{interfaces.d.ts → shared/base_pdf_stream.d.ts} +26 -27
  49. package/dist/types/src/shared/obj_bin_transform_utils.d.ts +26 -0
  50. package/dist/types/src/shared/util.d.ts +14 -5
  51. package/dist/types/web/annotation_editor_layer_builder.d.ts +7 -8
  52. package/dist/types/web/annotation_layer_builder.d.ts +15 -23
  53. package/dist/types/web/app_options.d.ts +1 -1
  54. package/dist/types/web/autolinker.d.ts +3 -2
  55. package/dist/types/web/base_download_manager.d.ts +24 -0
  56. package/dist/types/web/base_pdf_page_view.d.ts +6 -6
  57. package/dist/types/web/comment_manager.d.ts +20 -0
  58. package/dist/types/web/download_manager.d.ts +3 -12
  59. package/dist/types/web/draw_layer_builder.d.ts +0 -12
  60. package/dist/types/web/genericl10n.d.ts +6 -10
  61. package/dist/types/web/l10n.d.ts +3 -6
  62. package/dist/types/web/menu.d.ts +11 -0
  63. package/dist/types/web/pdf_find_controller.d.ts +9 -11
  64. package/dist/types/web/pdf_history.d.ts +3 -3
  65. package/dist/types/web/pdf_link_service.d.ts +4 -8
  66. package/dist/types/web/pdf_page_detail_view.d.ts +1 -7
  67. package/dist/types/web/pdf_page_view.d.ts +23 -12
  68. package/dist/types/web/pdf_rendering_queue.d.ts +10 -14
  69. package/dist/types/web/pdf_thumbnail_view.d.ts +18 -42
  70. package/dist/types/web/pdf_thumbnail_viewer.d.ts +57 -13
  71. package/dist/types/web/pdf_viewer.component.d.ts +1 -1
  72. package/dist/types/web/pdf_viewer.d.ts +40 -28
  73. package/dist/types/web/renderable_view.d.ts +33 -0
  74. package/dist/types/web/sidebar.d.ts +65 -0
  75. package/dist/types/web/struct_tree_layer_builder.d.ts +1 -1
  76. package/dist/types/web/text_accessibility.d.ts +1 -1
  77. package/dist/types/web/text_layer_builder.d.ts +11 -6
  78. package/dist/types/web/ui_utils.d.ts +3 -11
  79. package/dist/types/web/xfa_layer_builder.d.ts +4 -4
  80. package/package.json +25 -20
  81. package/dist/types/src/display/cmap_reader_factory.d.ts +0 -25
  82. package/dist/types/src/display/standard_fontdata_factory.d.ts +0 -20
  83. package/dist/types/src/display/wasm_factory.d.ts +0 -20
  84. package/dist/types/web/interfaces.d.ts +0 -174
@@ -1,15 +1,16 @@
1
1
  export type PDFPageProxy = import("./api").PDFPageProxy;
2
2
  export type PageViewport = import("./display_utils").PageViewport;
3
3
  export type TextAccessibilityManager = import("../../web/text_accessibility.js").TextAccessibilityManager;
4
- export type IDownloadManager = import("../../web/interfaces").IDownloadManager;
5
- export type IPDFLinkService = import("../../web/interfaces").IPDFLinkService;
6
4
  export type AnnotationEditorUIManager = any;
7
5
  export type StructTreeLayerBuilder = import("../../web/struct_tree_layer_builder.js").StructTreeLayerBuilder;
6
+ export type CommentManager = import("../../web/comment_manager.js").CommentManager;
7
+ export type PDFLinkService = import("../../web/pdf_link_service.js").PDFLinkService;
8
+ export type BaseDownloadManager = import("../../web/base_download_manager.js").BaseDownloadManager;
8
9
  export type AnnotationElementParameters = {
9
10
  data: Object;
10
11
  layer: HTMLDivElement;
11
- linkService: IPDFLinkService;
12
- downloadManager?: import("../../web/interfaces").IDownloadManager | undefined;
12
+ linkService: PDFLinkService;
13
+ downloadManager?: import("../../web/base_download_manager.js").BaseDownloadManager | undefined;
13
14
  annotationStorage?: AnnotationStorage | undefined;
14
15
  /**
15
16
  * - Path for image resources, mainly
@@ -27,8 +28,8 @@ export type AnnotationLayerParameters = {
27
28
  div: HTMLDivElement;
28
29
  annotations: any[];
29
30
  page: PDFPageProxy;
30
- linkService: IPDFLinkService;
31
- downloadManager?: import("../../web/interfaces").IDownloadManager | undefined;
31
+ linkService: PDFLinkService;
32
+ downloadManager?: import("../../web/base_download_manager.js").BaseDownloadManager | undefined;
32
33
  annotationStorage?: AnnotationStorage | undefined;
33
34
  /**
34
35
  * - Path for image resources, mainly
@@ -52,6 +53,10 @@ export type AnnotationLayerParameters = {
52
53
  accessibilityManager?: import("../../web/text_accessibility.js").TextAccessibilityManager | undefined;
53
54
  annotationEditorUIManager?: AnnotationEditorUIManager;
54
55
  structTreeLayer?: import("../../web/struct_tree_layer_builder.js").StructTreeLayerBuilder | undefined;
56
+ /**
57
+ * - The comment manager instance.
58
+ */
59
+ commentManager?: import("../../web/comment_manager.js").CommentManager | undefined;
55
60
  };
56
61
  /**
57
62
  * @typedef {Object} AnnotationLayerParameters
@@ -59,8 +64,8 @@ export type AnnotationLayerParameters = {
59
64
  * @property {HTMLDivElement} div
60
65
  * @property {Array} annotations
61
66
  * @property {PDFPageProxy} page
62
- * @property {IPDFLinkService} linkService
63
- * @property {IDownloadManager} [downloadManager]
67
+ * @property {PDFLinkService} linkService
68
+ * @property {BaseDownloadManager} [downloadManager]
64
69
  * @property {AnnotationStorage} [annotationStorage]
65
70
  * @property {string} [imageResourcesPath] - Path for image resources, mainly
66
71
  * for annotation icons. Include trailing slash.
@@ -73,6 +78,7 @@ export type AnnotationLayerParameters = {
73
78
  * @property {TextAccessibilityManager} [accessibilityManager]
74
79
  * @property {AnnotationEditorUIManager} [annotationEditorUIManager]
75
80
  * @property {StructTreeLayerBuilder} [structTreeLayer]
81
+ * @property {CommentManager} [commentManager] - The comment manager instance.
76
82
  */
77
83
  /**
78
84
  * Manage the layer containing all the annotations.
@@ -82,7 +88,7 @@ export class AnnotationLayer {
82
88
  * @private
83
89
  */
84
90
  private static get _defaultBorderStyle();
85
- constructor({ div, accessibilityManager, annotationCanvasMap, annotationEditorUIManager, page, viewport, structTreeLayer, }: {
91
+ constructor({ div, accessibilityManager, annotationCanvasMap, annotationEditorUIManager, page, viewport, structTreeLayer, commentManager, linkService, annotationStorage, }: {
86
92
  div: any;
87
93
  accessibilityManager: any;
88
94
  annotationCanvasMap: any;
@@ -90,12 +96,16 @@ export class AnnotationLayer {
90
96
  page: any;
91
97
  viewport: any;
92
98
  structTreeLayer: any;
99
+ commentManager: any;
100
+ linkService: any;
101
+ annotationStorage: any;
93
102
  });
94
103
  div: any;
95
104
  page: any;
96
105
  viewport: any;
97
106
  zIndex: number;
98
107
  _annotationEditorUIManager: any;
108
+ _commentManager: any;
99
109
  popupShow: any[] | undefined;
100
110
  hasEditableAnnotations(): boolean;
101
111
  /**
@@ -109,10 +119,8 @@ export class AnnotationLayer {
109
119
  * Add link annotations to the annotation layer.
110
120
  *
111
121
  * @param {Array<Object>} annotations
112
- * @param {IPDFLinkService} linkService
113
- * @memberof AnnotationLayer
114
122
  */
115
- addLinkAnnotations(annotations: Array<Object>, linkService: IPDFLinkService): Promise<void>;
123
+ addLinkAnnotations(annotations: Array<Object>): Promise<void>;
116
124
  /**
117
125
  * Update the annotation elements on existing annotation layer.
118
126
  *
@@ -120,8 +128,12 @@ export class AnnotationLayer {
120
128
  * @memberof AnnotationLayer
121
129
  */
122
130
  update({ viewport }: AnnotationLayerParameters): void;
123
- getEditableAnnotations(): any[];
131
+ getEditableAnnotations(): MapIterator<any>;
124
132
  getEditableAnnotation(id: any): any;
133
+ addFakeAnnotation(editor: any): EditorAnnotationElement;
134
+ removeAnnotation(id: any): void;
135
+ updateFakeAnnotations(editors: any): void;
136
+ togglePointerEvents(enabled?: boolean): void;
125
137
  #private;
126
138
  }
127
139
  export class FreeTextAnnotationElement extends AnnotationElement {
@@ -151,6 +163,13 @@ export class StampAnnotationElement extends AnnotationElement {
151
163
  render(): HTMLElement | undefined;
152
164
  }
153
165
  import { AnnotationStorage } from "./annotation_storage.js";
166
+ declare class EditorAnnotationElement extends AnnotationElement {
167
+ constructor(parameters: any);
168
+ editor: any;
169
+ render(): HTMLElement | undefined;
170
+ createOrUpdatePopup(): void;
171
+ remove(): void;
172
+ }
154
173
  declare class AnnotationElement {
155
174
  static _hasPopupData({ contentsObj, richText }: {
156
175
  contentsObj: any;
@@ -175,15 +194,20 @@ declare class AnnotationElement {
175
194
  hasJSActions: any;
176
195
  _fieldObjects: any;
177
196
  parent: any;
197
+ hasOwnCommentButton: boolean;
198
+ contentElement: HTMLElement | undefined;
178
199
  container: HTMLElement | undefined;
179
200
  get _isEditable(): any;
180
- get hasPopupData(): boolean;
201
+ get hasPopupData(): any;
202
+ get commentData(): any;
181
203
  get hasCommentButton(): any;
182
- get commentButtonPosition(): any[] | null;
183
- get commentButtonColor(): string | null;
204
+ get commentButtonPosition(): any;
184
205
  _normalizePoint(point: any): any;
185
- updateEdited(params: any): void;
206
+ set commentText(text: any);
207
+ get commentText(): any;
208
+ removePopup(): void;
186
209
  popup: any;
210
+ updateEdited(params: any): void;
187
211
  resetEdited(): void;
188
212
  /**
189
213
  * Create an empty container for the annotation's HTML element.
@@ -217,6 +241,7 @@ declare class AnnotationElement {
217
241
  */
218
242
  private _createPopup;
219
243
  get hasPopupElement(): boolean;
244
+ get extraPopupElement(): null;
220
245
  /**
221
246
  * Render the annotation's HTML element(s).
222
247
  *
@@ -2,9 +2,9 @@
2
2
  * Key/value storage for annotation data in forms.
3
3
  */
4
4
  export class AnnotationStorage {
5
- onSetModified: any;
6
- onResetModified: any;
7
- onAnnotationEditor: any;
5
+ onSetModified: null;
6
+ onResetModified: null;
7
+ onAnnotationEditor: null;
8
8
  /**
9
9
  * Get the value for a given key if it exists, or return the default value.
10
10
  * @param {string} key
@@ -56,6 +56,8 @@ export class AnnotationStorage {
56
56
  };
57
57
  get editorStats(): any;
58
58
  resetModifiedIds(): void;
59
+ updateEditor(annotationId: any, data: any): boolean;
60
+ getEditor(annotationId: any): any;
59
61
  /**
60
62
  * @returns {{ids: Set<string>, hash: string}}
61
63
  */
@@ -77,11 +79,11 @@ export class PrintAnnotationStorage extends AnnotationStorage {
77
79
  * PLEASE NOTE: Only intended for usage within the API itself.
78
80
  * @ignore
79
81
  */
80
- get serializable(): {
81
- map: any;
82
- hash: any;
83
- transfer: any;
84
- };
82
+ get serializable(): Readonly<{
83
+ map: null;
84
+ hash: "";
85
+ transfer: undefined;
86
+ }>;
85
87
  get modifiedIds(): any;
86
88
  #private;
87
89
  }
@@ -36,11 +36,6 @@ export type DocumentInitParameters = {
36
36
  * - For decrypting password-protected PDFs.
37
37
  */
38
38
  password?: string | undefined;
39
- /**
40
- * - The PDF file length. It's used for progress
41
- * reports and range requests operations.
42
- */
43
- length?: number | undefined;
44
39
  /**
45
40
  * - Allows for using a custom range
46
41
  * transport implementation.
@@ -77,12 +72,6 @@ export type DocumentInitParameters = {
77
72
  * packed or not. The default value is `true`.
78
73
  */
79
74
  cMapPacked?: boolean | undefined;
80
- /**
81
- * - The factory that will be used when
82
- * reading built-in CMap files.
83
- * The default value is {DOMCMapReaderFactory}.
84
- */
85
- CMapReaderFactory?: Object | undefined;
86
75
  /**
87
76
  * - The URL where the predefined ICC profiles are
88
77
  * located. Include the trailing slash.
@@ -101,28 +90,15 @@ export type DocumentInitParameters = {
101
90
  * files are located. Include the trailing slash.
102
91
  */
103
92
  standardFontDataUrl?: string | undefined;
104
- /**
105
- * - The factory that will be used
106
- * when reading the standard font files.
107
- * The default value is {DOMStandardFontDataFactory}.
108
- */
109
- StandardFontDataFactory?: Object | undefined;
110
93
  /**
111
94
  * - The URL where the wasm files are located.
112
95
  * Include the trailing slash.
113
96
  */
114
97
  wasmUrl?: string | undefined;
115
- /**
116
- * - The factory that will be used
117
- * when reading the wasm files.
118
- * The default value is {DOMWasmFactory}.
119
- */
120
- WasmFactory?: Object | undefined;
121
98
  /**
122
99
  * - Enable using the Fetch API in the
123
- * worker-thread when reading CMap and standard font files. When `true`,
124
- * the `CMapReaderFactory`, `StandardFontDataFactory`, and `WasmFactory`
125
- * options are ignored.
100
+ * worker-thread when reading built-in CMap files, standard font files,
101
+ * and wasm files. If `true`, the `BinaryDataFactory` option is ignored.
126
102
  * The default value is `true` in web environments and `false` in Node.js.
127
103
  */
128
104
  useWorkerFetch?: boolean | undefined;
@@ -246,11 +222,24 @@ export type DocumentInitParameters = {
246
222
  * The default value is {DOMFilterFactory}.
247
223
  */
248
224
  FilterFactory?: Object | undefined;
225
+ /**
226
+ * - The factory that will be used when
227
+ * falling back to reading built-in CMap files, standard font files,
228
+ * and wasm files in the main-thread.
229
+ * The default value is {DOMBinaryDataFactory}.
230
+ */
231
+ BinaryDataFactory?: Object | undefined;
249
232
  /**
250
233
  * - Enables hardware acceleration for
251
234
  * rendering. The default value is `false`.
252
235
  */
253
236
  enableHWA?: boolean | undefined;
237
+ /**
238
+ * - The pages mapper that will be used to map
239
+ * page ids and page numbers. It's used when the page order is changed or some
240
+ * pages are removed, cloned, etc.
241
+ */
242
+ pagesMapper?: Object | undefined;
254
243
  };
255
244
  export type OnProgressParameters = {
256
245
  /**
@@ -261,6 +250,11 @@ export type OnProgressParameters = {
261
250
  * - Total number of bytes in the PDF file.
262
251
  */
263
252
  total: number;
253
+ /**
254
+ * - Currently loaded percentage, as an integer value
255
+ * in the [0, 100] range. If `total` is undefined, the percentage is `NaN`.
256
+ */
257
+ percent: number;
264
258
  };
265
259
  /**
266
260
  * Page getViewport parameters.
@@ -492,17 +486,22 @@ export type RenderParameters = {
492
486
  * - Render the page in editing mode.
493
487
  */
494
488
  isEditing?: boolean | undefined;
489
+ /**
490
+ * - Record the location of images in the PDF
491
+ */
492
+ recordImages?: boolean | undefined;
495
493
  /**
496
494
  * - Record the dependencies and bounding
497
495
  * boxes of all PDF operations that render onto the canvas.
498
496
  */
499
497
  recordOperations?: boolean | undefined;
500
498
  /**
501
- * - If provided, only run
502
- * the PDF operations that are included in this set.
499
+ * - If provided, only
500
+ * run for which this function returns `true`.
503
501
  */
504
- filteredOperationIndexes?: Set<number> | undefined;
502
+ operationsFilter?: OperationsFilter | undefined;
505
503
  };
504
+ export type OperationsFilter = (index: number) => boolean;
506
505
  /**
507
506
  * Page getOperatorList parameters.
508
507
  */
@@ -623,8 +622,6 @@ export const build: string;
623
622
  * cross-site Access-Control requests should be made using credentials such
624
623
  * as cookies or authorization headers. The default is `false`.
625
624
  * @property {string} [password] - For decrypting password-protected PDFs.
626
- * @property {number} [length] - The PDF file length. It's used for progress
627
- * reports and range requests operations.
628
625
  * @property {PDFDataRangeTransport} [range] - Allows for using a custom range
629
626
  * transport implementation.
630
627
  * @property {number} [rangeChunkSize] - Specify maximum number of bytes fetched
@@ -640,9 +637,6 @@ export const build: string;
640
637
  * located. Include the trailing slash.
641
638
  * @property {boolean} [cMapPacked] - Specifies if the Adobe CMaps are binary
642
639
  * packed or not. The default value is `true`.
643
- * @property {Object} [CMapReaderFactory] - The factory that will be used when
644
- * reading built-in CMap files.
645
- * The default value is {DOMCMapReaderFactory}.
646
640
  * @property {string} [iccUrl] - The URL where the predefined ICC profiles are
647
641
  * located. Include the trailing slash.
648
642
  * @property {boolean} [useSystemFonts] - When `true`, fonts that aren't
@@ -652,18 +646,11 @@ export const build: string;
652
646
  * regardless of the environment (to prevent completely broken fonts).
653
647
  * @property {string} [standardFontDataUrl] - The URL where the standard font
654
648
  * files are located. Include the trailing slash.
655
- * @property {Object} [StandardFontDataFactory] - The factory that will be used
656
- * when reading the standard font files.
657
- * The default value is {DOMStandardFontDataFactory}.
658
649
  * @property {string} [wasmUrl] - The URL where the wasm files are located.
659
650
  * Include the trailing slash.
660
- * @property {Object} [WasmFactory] - The factory that will be used
661
- * when reading the wasm files.
662
- * The default value is {DOMWasmFactory}.
663
651
  * @property {boolean} [useWorkerFetch] - Enable using the Fetch API in the
664
- * worker-thread when reading CMap and standard font files. When `true`,
665
- * the `CMapReaderFactory`, `StandardFontDataFactory`, and `WasmFactory`
666
- * options are ignored.
652
+ * worker-thread when reading built-in CMap files, standard font files,
653
+ * and wasm files. If `true`, the `BinaryDataFactory` option is ignored.
667
654
  * The default value is `true` in web environments and `false` in Node.js.
668
655
  * @property {boolean} [useWasm] - Attempt to use WebAssembly in order to
669
656
  * improve e.g. image decoding performance.
@@ -735,8 +722,15 @@ export const build: string;
735
722
  * @property {Object} [FilterFactory] - The factory that will be used to
736
723
  * create SVG filters when rendering some images on the main canvas.
737
724
  * The default value is {DOMFilterFactory}.
725
+ * @property {Object} [BinaryDataFactory] - The factory that will be used when
726
+ * falling back to reading built-in CMap files, standard font files,
727
+ * and wasm files in the main-thread.
728
+ * The default value is {DOMBinaryDataFactory}.
738
729
  * @property {boolean} [enableHWA] - Enables hardware acceleration for
739
730
  * rendering. The default value is `false`.
731
+ * @property {Object} [pagesMapper] - The pages mapper that will be used to map
732
+ * page ids and page numbers. It's used when the page order is changed or some
733
+ * pages are removed, cloned, etc.
740
734
  */
741
735
  /**
742
736
  * This is the main entry point for loading a PDF and interacting with it.
@@ -774,10 +768,6 @@ export class PDFDataRangeTransport {
774
768
  * @param {function} listener
775
769
  */
776
770
  addRangeListener(listener: Function): void;
777
- /**
778
- * @param {function} listener
779
- */
780
- addProgressListener(listener: Function): void;
781
771
  /**
782
772
  * @param {function} listener
783
773
  */
@@ -791,11 +781,6 @@ export class PDFDataRangeTransport {
791
781
  * @param {Uint8Array|null} chunk
792
782
  */
793
783
  onDataRange(begin: number, chunk: Uint8Array | null): void;
794
- /**
795
- * @param {number} loaded
796
- * @param {number|undefined} total
797
- */
798
- onDataProgress(loaded: number, total: number | undefined): void;
799
784
  /**
800
785
  * @param {Uint8Array|null} chunk
801
786
  */
@@ -814,6 +799,8 @@ export class PDFDataRangeTransport {
814
799
  * @typedef {Object} OnProgressParameters
815
800
  * @property {number} loaded - Currently loaded number of bytes.
816
801
  * @property {number} total - Total number of bytes in the PDF file.
802
+ * @property {number} percent - Currently loaded percentage, as an integer value
803
+ * in the [0, 100] range. If `total` is undefined, the percentage is `NaN`.
817
804
  */
818
805
  /**
819
806
  * The loading task controls the operations required to load a PDF document
@@ -821,7 +808,7 @@ export class PDFDataRangeTransport {
821
808
  * after which individual pages can be rendered.
822
809
  */
823
810
  export class PDFDocumentLoadingTask {
824
- static #docId: number;
811
+ static "__#private@#docId": number;
825
812
  /**
826
813
  * @private
827
814
  */
@@ -884,6 +871,10 @@ export class PDFDocumentProxy {
884
871
  constructor(pdfInfo: any, transport: any);
885
872
  _pdfInfo: any;
886
873
  _transport: any;
874
+ /**
875
+ * @type {PagesMapper} The pages mapper instance.
876
+ */
877
+ get pagesMapper(): PagesMapper;
887
878
  /**
888
879
  * @type {AnnotationStorage} Storage for annotation data in forms.
889
880
  */
@@ -1099,6 +1090,30 @@ export class PDFDocumentProxy {
1099
1090
  * {Uint8Array} containing the full data of the saved document.
1100
1091
  */
1101
1092
  saveDocument(): Promise<Uint8Array>;
1093
+ /**
1094
+ * @typedef {Object} PageInfo
1095
+ * @property {null|Uint8Array} document
1096
+ * @property {Array<Array<number>|number>} [includePages]
1097
+ * included ranges or indices.
1098
+ * @property {Array<Array<number>|number>} [excludePages]
1099
+ * excluded ranges or indices.
1100
+ */
1101
+ /**
1102
+ * @param {Array<PageInfo>} pageInfos - The pages to extract.
1103
+ * @returns {Promise<Uint8Array>} A promise that is resolved with a
1104
+ * {Uint8Array} containing the full data of the saved document.
1105
+ */
1106
+ extractPages(pageInfos: Array<{
1107
+ document: null | Uint8Array;
1108
+ /**
1109
+ * included ranges or indices.
1110
+ */
1111
+ includePages?: (number | number[])[] | undefined;
1112
+ /**
1113
+ * excluded ranges or indices.
1114
+ */
1115
+ excludePages?: (number | number[])[] | undefined;
1116
+ }>): Promise<Uint8Array>;
1102
1117
  /**
1103
1118
  * @returns {Promise<{ length: number }>} A promise that is resolved when the
1104
1119
  * document's data is loaded. It is resolved with an {Object} that contains
@@ -1107,6 +1122,7 @@ export class PDFDocumentProxy {
1107
1122
  getDownloadInfo(): Promise<{
1108
1123
  length: number;
1109
1124
  }>;
1125
+ getRawData(data: any): any;
1110
1126
  /**
1111
1127
  * Cleans up resources allocated by the document on both the main and worker
1112
1128
  * threads.
@@ -1282,10 +1298,16 @@ export class PDFDocumentProxy {
1282
1298
  * annotation ids with canvases used to render them.
1283
1299
  * @property {PrintAnnotationStorage} [printAnnotationStorage]
1284
1300
  * @property {boolean} [isEditing] - Render the page in editing mode.
1301
+ * @property {boolean} [recordImages] - Record the location of images in the PDF
1285
1302
  * @property {boolean} [recordOperations] - Record the dependencies and bounding
1286
1303
  * boxes of all PDF operations that render onto the canvas.
1287
- * @property {Set<number>} [filteredOperationIndexes] - If provided, only run
1288
- * the PDF operations that are included in this set.
1304
+ * @property {OperationsFilter} [operationsFilter] - If provided, only
1305
+ * run for which this function returns `true`.
1306
+ */
1307
+ /**
1308
+ * @callback OperationsFilter
1309
+ * @param {number} index - The index of the operation.
1310
+ * @returns {boolean} If false, the operation is ignored.
1289
1311
  */
1290
1312
  /**
1291
1313
  * Page getOperatorList parameters.
@@ -1337,7 +1359,7 @@ export class PDFDocumentProxy {
1337
1359
  * Proxy to a `PDFPage` in the worker thread.
1338
1360
  */
1339
1361
  export class PDFPageProxy {
1340
- constructor(pageIndex: any, pageInfo: any, transport: any, pdfBug?: boolean);
1362
+ constructor(pageIndex: any, pageInfo: any, transport: any, pagesMapper: any, pdfBug?: boolean);
1341
1363
  _pageIndex: any;
1342
1364
  _pageInfo: any;
1343
1365
  _transport: any;
@@ -1348,7 +1370,13 @@ export class PDFPageProxy {
1348
1370
  objs: PDFObjects;
1349
1371
  _intentStates: Map<any, any>;
1350
1372
  destroyed: boolean;
1351
- recordedGroups: any;
1373
+ recordedBBoxes: any;
1374
+ imageCoordinates: any;
1375
+ clone(id: any): PDFPageProxy;
1376
+ /**
1377
+ * @param {number} value - The page number to set. First page is 1.
1378
+ */
1379
+ set pageNumber(value: number);
1352
1380
  /**
1353
1381
  * @type {number} Page number of the page. First page is 1.
1354
1382
  */
@@ -1409,7 +1437,7 @@ export class PDFPageProxy {
1409
1437
  * @returns {RenderTask} An object that contains a promise that is
1410
1438
  * resolved when the page finishes rendering.
1411
1439
  */
1412
- render({ canvasContext, canvas, viewport, intent, annotationMode, transform, background, optionalContentConfigPromise, annotationCanvasMap, pageColors, printAnnotationStorage, isEditing, recordOperations, filteredOperationIndexes, }: RenderParameters): RenderTask;
1440
+ render({ canvasContext, canvas, viewport, intent, annotationMode, transform, background, optionalContentConfigPromise, annotationCanvasMap, pageColors, printAnnotationStorage, isEditing, recordImages, recordOperations, operationsFilter, }: RenderParameters): RenderTask;
1413
1441
  /**
1414
1442
  * @param {GetOperatorListParameters} params - Page getOperatorList
1415
1443
  * parameters.
@@ -1492,9 +1520,9 @@ export class PDFPageProxy {
1492
1520
  * @param {PDFWorkerParameters} params - The worker initialization parameters.
1493
1521
  */
1494
1522
  export class PDFWorker {
1495
- static #fakeWorkerId: number;
1496
- static #isWorkerDisabled: boolean;
1497
- static #workerPorts: WeakMap<object, any>;
1523
+ static "__#private@#fakeWorkerId": number;
1524
+ static "__#private@#isWorkerDisabled": boolean;
1525
+ static "__#private@#workerPorts": WeakMap<object, any>;
1498
1526
  /**
1499
1527
  * @param {PDFWorkerParameters} params - The worker initialization parameters.
1500
1528
  * @returns {PDFWorker}
@@ -1505,7 +1533,7 @@ export class PDFWorker {
1505
1533
  * @type {string}
1506
1534
  */
1507
1535
  static get workerSrc(): string;
1508
- static get #mainThreadWorkerMessageHandler(): any;
1536
+ static get "__#private@#mainThreadWorkerMessageHandler"(): any;
1509
1537
  static get _setupFakeWorkerGlobal(): any;
1510
1538
  constructor({ name, port, verbosity, }?: {
1511
1539
  name?: null | undefined;
@@ -1541,6 +1569,7 @@ export class PDFWorker {
1541
1569
  */
1542
1570
  export class RenderTask {
1543
1571
  constructor(internalRenderTask: any);
1572
+ _internalRenderTask: null;
1544
1573
  /**
1545
1574
  * Callback for incremental rendering -- a function that will be called
1546
1575
  * each time the rendering is paused. To continue rendering call the
@@ -1575,13 +1604,14 @@ export class RenderTask {
1575
1604
  * @type {boolean}
1576
1605
  */
1577
1606
  get separateAnnots(): boolean;
1578
- #private;
1607
+ get imageCoordinates(): any;
1579
1608
  }
1580
1609
  /** @type {string} */
1581
1610
  export const version: string;
1582
1611
  import { PageViewport } from "./display_utils.js";
1583
1612
  import { OptionalContentConfig } from "./optional_content_config.js";
1584
1613
  import { PrintAnnotationStorage } from "./annotation_storage.js";
1614
+ import { PagesMapper } from "./pages_mapper.js";
1585
1615
  import { AnnotationStorage } from "./annotation_storage.js";
1586
1616
  import { Metadata } from "./metadata.js";
1587
1617
  import { StatTimer } from "./display_utils.js";
@@ -1,6 +1,6 @@
1
1
  export function getDataProp(val: any): Uint8Array<any>;
2
2
  export function getFactoryUrlProp(val: any): string | null;
3
- export function getUrlProp(val: any): string | null;
3
+ export function getUrlProp(val: any): URL | null;
4
4
  export function isNameProxy(v: any): boolean;
5
5
  export function isRefProxy(v: any): boolean;
6
6
  export const isValidExplicitDest: (dest?: any) => boolean;
@@ -0,0 +1,26 @@
1
+ export class BaseBinaryDataFactory {
2
+ constructor({ cMapUrl, standardFontDataUrl, wasmUrl }: {
3
+ cMapUrl?: null | undefined;
4
+ standardFontDataUrl?: null | undefined;
5
+ wasmUrl?: null | undefined;
6
+ });
7
+ cMapUrl: any;
8
+ standardFontDataUrl: any;
9
+ wasmUrl: any;
10
+ fetch({ kind, filename }: {
11
+ kind: any;
12
+ filename: any;
13
+ }): Promise<Uint8Array<ArrayBufferLike>>;
14
+ /**
15
+ * @ignore
16
+ * @returns {Promise<Uint8Array>}
17
+ */
18
+ _fetch(url: any, kind: any): Promise<Uint8Array>;
19
+ #private;
20
+ }
21
+ export class DOMBinaryDataFactory extends BaseBinaryDataFactory {
22
+ /**
23
+ * @ignore
24
+ */
25
+ _fetch(url: any, kind: any): Promise<Uint8Array<any>>;
26
+ }