unpdf 1.8.0 → 1.9.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 (94) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.d.cts +15 -15
  4. package/dist/index.d.mts +15 -15
  5. package/dist/index.mjs +1 -1
  6. package/dist/pdfjs.mjs +37 -37
  7. package/dist/types/external/qcms/qcms.d.ts +11 -7
  8. package/dist/types/external/qcms/qcms_utils.d.ts +1 -6
  9. package/dist/types/src/core/base_stream.d.ts +8 -1
  10. package/dist/types/src/core/catalog.d.ts +12 -12
  11. package/dist/types/src/core/colorspace.d.ts +6 -15
  12. package/dist/types/src/core/core_utils.d.ts +18 -14
  13. package/dist/types/src/core/crypto.d.ts +0 -1
  14. package/dist/types/src/core/file_spec.d.ts +4 -9
  15. package/dist/types/src/core/icc_colorspace.d.ts +0 -1
  16. package/dist/types/src/core/image_resizer.d.ts +24 -0
  17. package/dist/types/src/core/image_utils.d.ts +4 -4
  18. package/dist/types/src/core/jpeg_stream.d.ts +1 -1
  19. package/dist/types/src/core/jpg.d.ts +9 -13
  20. package/dist/types/src/core/parser.d.ts +0 -2
  21. package/dist/types/src/core/pattern.d.ts +0 -2
  22. package/dist/types/src/core/primitives.d.ts +30 -16
  23. package/dist/types/src/core/sasl_prep.d.ts +1 -0
  24. package/dist/types/src/core/sound.d.ts +39 -0
  25. package/dist/types/src/core/string_utils.d.ts +1 -1
  26. package/dist/types/src/core/struct_tree.d.ts +3 -3
  27. package/dist/types/src/core/xml_parser.d.ts +1 -2
  28. package/dist/types/src/core/xref.d.ts +2 -15
  29. package/dist/types/src/display/annotation_layer.d.ts +9 -20
  30. package/dist/types/src/display/annotation_storage.d.ts +7 -7
  31. package/dist/types/src/display/api.d.ts +155 -108
  32. package/dist/types/src/display/canvas.d.ts +2 -1
  33. package/dist/types/src/display/canvas_dependency_tracker.d.ts +8 -3
  34. package/dist/types/src/display/content_disposition.d.ts +0 -1
  35. package/dist/types/src/display/display_utils.d.ts +2 -2
  36. package/dist/types/src/display/draw_layer.d.ts +2 -6
  37. package/dist/types/src/display/editor/annotation_editor_layer.d.ts +18 -19
  38. package/dist/types/src/display/editor/color_picker.d.ts +1 -1
  39. package/dist/types/src/display/editor/comment.d.ts +1 -1
  40. package/dist/types/src/display/editor/draw.d.ts +78 -27
  41. package/dist/types/src/display/editor/drawers/freedraw.d.ts +11 -9
  42. package/dist/types/src/display/editor/drawers/highlight.d.ts +99 -15
  43. package/dist/types/src/display/editor/drawers/inkdraw.d.ts +7 -2
  44. package/dist/types/src/display/editor/drawers/outline.d.ts +65 -2
  45. package/dist/types/src/display/editor/editor.d.ts +24 -22
  46. package/dist/types/src/display/editor/freetext.d.ts +1 -1
  47. package/dist/types/src/display/editor/highlight.d.ts +44 -35
  48. package/dist/types/src/display/editor/ink.d.ts +7 -2
  49. package/dist/types/src/display/editor/stamp.d.ts +1 -1
  50. package/dist/types/src/display/editor/tools.d.ts +21 -19
  51. package/dist/types/src/display/filter_factory.d.ts +1 -3
  52. package/dist/types/src/display/font_loader.d.ts +1 -15
  53. package/dist/types/src/display/network_utils.d.ts +1 -0
  54. package/dist/types/src/display/obj_bin_transform_display.d.ts +25 -38
  55. package/dist/types/src/display/page_viewport.d.ts +5 -5
  56. package/dist/types/src/display/pages_mapper.d.ts +10 -4
  57. package/dist/types/src/display/pattern_helper.d.ts +4 -3
  58. package/dist/types/src/display/pdf_objects.d.ts +1 -3
  59. package/dist/types/src/display/text_layer.d.ts +2 -0
  60. package/dist/types/src/display/touch_manager.d.ts +46 -9
  61. package/dist/types/src/display/worker_options.d.ts +2 -2
  62. package/dist/types/src/display/xfa_layer.d.ts +7 -12
  63. package/dist/types/src/display/xfa_text.d.ts +2 -5
  64. package/dist/types/src/pdf.d.ts +2 -1
  65. package/dist/types/src/shared/base_pdf_stream.d.ts +6 -7
  66. package/dist/types/src/shared/css_utils.d.ts +8 -0
  67. package/dist/types/src/shared/message_handler.d.ts +2 -11
  68. package/dist/types/src/shared/obj_bin_transform_utils.d.ts +4 -3
  69. package/dist/types/src/shared/util.d.ts +4 -6
  70. package/dist/types/web/annotation_editor_layer_builder.d.ts +5 -3
  71. package/dist/types/web/annotation_layer_builder.d.ts +8 -12
  72. package/dist/types/web/draw_layer_builder.d.ts +7 -9
  73. package/dist/types/web/event_utils.d.ts +12 -13
  74. package/dist/types/web/genericl10n.d.ts +2 -2
  75. package/dist/types/web/l10n.d.ts +1 -1
  76. package/dist/types/web/pdf_find_controller.d.ts +5 -6
  77. package/dist/types/web/pdf_find_utils.d.ts +8 -14
  78. package/dist/types/web/pdf_history.d.ts +1 -1
  79. package/dist/types/web/pdf_link_service.d.ts +5 -7
  80. package/dist/types/web/pdf_page_view.d.ts +3 -3
  81. package/dist/types/web/pdf_rendering_queue.d.ts +4 -5
  82. package/dist/types/web/pdf_scripting_manager.d.ts +4 -4
  83. package/dist/types/web/pdf_thumbnail_view.d.ts +2 -2
  84. package/dist/types/web/pdf_thumbnail_viewer.d.ts +14 -15
  85. package/dist/types/web/pdf_viewer.d.ts +36 -16
  86. package/dist/types/web/renderable_view.d.ts +1 -1
  87. package/dist/types/web/sidebar.d.ts +3 -3
  88. package/dist/types/web/struct_tree_layer_builder.d.ts +20 -6
  89. package/dist/types/web/text_accessibility.d.ts +4 -2
  90. package/dist/types/web/text_highlighter.d.ts +1 -2
  91. package/dist/types/web/text_layer_builder.d.ts +5 -5
  92. package/dist/types/web/ui_utils.d.ts +8 -13
  93. package/dist/types/web/xfa_layer_builder.d.ts +7 -7
  94. package/package.json +11 -11
@@ -25,7 +25,7 @@ export type DocumentInitParameters = {
25
25
  /**
26
26
  * - Basic authentication headers.
27
27
  */
28
- httpHeaders?: Object | undefined;
28
+ httpHeaders?: object | undefined;
29
29
  /**
30
30
  * - Indicates whether or not
31
31
  * cross-site Access-Control requests should be made using credentials such
@@ -199,20 +199,20 @@ export type DocumentInitParameters = {
199
199
  * - The factory that will be used when
200
200
  * creating canvases. The default value is {DOMCanvasFactory}.
201
201
  */
202
- CanvasFactory?: Object | undefined;
202
+ CanvasFactory?: object | undefined;
203
203
  /**
204
204
  * - The factory that will be used to
205
205
  * create SVG filters when rendering some images on the main canvas.
206
206
  * The default value is {DOMFilterFactory}.
207
207
  */
208
- FilterFactory?: Object | undefined;
208
+ FilterFactory?: object | undefined;
209
209
  /**
210
210
  * - The factory that will be used when
211
211
  * falling back to reading built-in CMap files, standard font files,
212
212
  * and wasm files in the main-thread.
213
213
  * The default value is {DOMBinaryDataFactory}.
214
214
  */
215
- BinaryDataFactory?: Object | undefined;
215
+ BinaryDataFactory?: object | undefined;
216
216
  /**
217
217
  * - Enables hardware acceleration for
218
218
  * rendering. The default value is `false`.
@@ -223,7 +223,7 @@ export type DocumentInitParameters = {
223
223
  * page ids and page numbers. It's used when the page order is changed or some
224
224
  * pages are removed, cloned, etc.
225
225
  */
226
- pagesMapper?: Object | undefined;
226
+ pagesMapper?: object | undefined;
227
227
  };
228
228
  export type OnProgressParameters = {
229
229
  /**
@@ -298,9 +298,7 @@ export type TextContent = {
298
298
  * - {@link TextStyle} objects,
299
299
  * indexed by font name.
300
300
  */
301
- styles: {
302
- [x: string]: TextStyle;
303
- };
301
+ styles: Record<string, TextStyle>;
304
302
  /**
305
303
  * - The document /Lang attribute.
306
304
  */
@@ -452,7 +450,7 @@ export type RenderParameters = {
452
450
  * with user defined ones in order to improve readability in high contrast
453
451
  * mode.
454
452
  */
455
- pageColors?: Object | undefined;
453
+ pageColors?: object | undefined;
456
454
  /**
457
455
  * -
458
456
  * A promise that should resolve with an {@link OptionalContentConfig}created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,
@@ -485,7 +483,7 @@ export type RenderParameters = {
485
483
  */
486
484
  operationsFilter?: OperationsFilter | undefined;
487
485
  };
488
- export type OperationsFilter = (index: number) => boolean;
486
+ export type OperationsFilter = (index: number, operatorList: PDFOperatorList) => boolean;
489
487
  /**
490
488
  * Page getOperatorList parameters.
491
489
  */
@@ -530,6 +528,39 @@ export type StructTreeNode = {
530
528
  * in the PDF.
531
529
  */
532
530
  role: string;
531
+ /**
532
+ * - A table header's structure element
533
+ * identifier, i.e. its `ID` entry. Note that this is unrelated to the `id`
534
+ * property of a {@link StructTreeContent} object.
535
+ */
536
+ structId?: string | undefined;
537
+ /**
538
+ * - The number of rows spanned by a table cell.
539
+ */
540
+ rowSpan?: number | undefined;
541
+ /**
542
+ * - The number of columns spanned by a table cell.
543
+ */
544
+ colSpan?: number | undefined;
545
+ /**
546
+ * - The `structId` values of the table
547
+ * headers associated with a table cell.
548
+ */
549
+ headers?: string[] | undefined;
550
+ /**
551
+ * - The cells to which a table
552
+ * header applies.
553
+ */
554
+ scope?: "Row" | "Column" | "Both" | undefined;
555
+ /**
556
+ * - An abbreviated version of a table header's
557
+ * content.
558
+ */
559
+ short?: string | undefined;
560
+ /**
561
+ * - A summary of a table's purpose and structure.
562
+ */
563
+ summary?: string | undefined;
533
564
  };
534
565
  /**
535
566
  * Structure tree content.
@@ -590,14 +621,13 @@ export const build: string;
590
621
  * } TypedArray
591
622
  */
592
623
  /**
593
- * @typedef {Object} RefProxy
624
+ * @typedef {object} RefProxy
594
625
  * @property {number} num
595
626
  * @property {number} gen
596
627
  */
597
628
  /**
598
629
  * Document initialization / loading parameters object.
599
- *
600
- * @typedef {Object} DocumentInitParameters
630
+ * @typedef {object} DocumentInitParameters
601
631
  * @property {string | URL} [url] - The URL of the PDF.
602
632
  * @property {TypedArray | ArrayBuffer | Array<number> | string} [data] -
603
633
  * Binary PDF data.
@@ -607,7 +637,7 @@ export const build: string;
607
637
  * NOTE: If TypedArrays are used they will generally be transferred to the
608
638
  * worker-thread. This will help reduce main-thread memory usage, however
609
639
  * it will take ownership of the TypedArrays.
610
- * @property {Object} [httpHeaders] - Basic authentication headers.
640
+ * @property {object} [httpHeaders] - Basic authentication headers.
611
641
  * @property {boolean} [withCredentials] - Indicates whether or not
612
642
  * cross-site Access-Control requests should be made using credentials such
613
643
  * as cookies or authorization headers. The default is `false`.
@@ -693,18 +723,18 @@ export const build: string;
693
723
  * disabling of pre-fetching to work correctly.
694
724
  * @property {boolean} [pdfBug] - Enables special hooks for debugging PDF.js
695
725
  * (see `web/debugger.js`). The default value is `false`.
696
- * @property {Object} [CanvasFactory] - The factory that will be used when
726
+ * @property {object} [CanvasFactory] - The factory that will be used when
697
727
  * creating canvases. The default value is {DOMCanvasFactory}.
698
- * @property {Object} [FilterFactory] - The factory that will be used to
728
+ * @property {object} [FilterFactory] - The factory that will be used to
699
729
  * create SVG filters when rendering some images on the main canvas.
700
730
  * The default value is {DOMFilterFactory}.
701
- * @property {Object} [BinaryDataFactory] - The factory that will be used when
731
+ * @property {object} [BinaryDataFactory] - The factory that will be used when
702
732
  * falling back to reading built-in CMap files, standard font files,
703
733
  * and wasm files in the main-thread.
704
734
  * The default value is {DOMBinaryDataFactory}.
705
735
  * @property {boolean} [enableHWA] - Enables hardware acceleration for
706
736
  * rendering. The default value is `false`.
707
- * @property {Object} [pagesMapper] - The pages mapper that will be used to map
737
+ * @property {object} [pagesMapper] - The pages mapper that will be used to map
708
738
  * page ids and page numbers. It's used when the page order is changed or some
709
739
  * pages are removed, cloned, etc.
710
740
  */
@@ -714,7 +744,6 @@ export const build: string;
714
744
  * NOTE: If a URL is used to fetch the PDF data a standard Fetch API call (or
715
745
  * XHR as fallback) is used, which means it must follow same origin rules,
716
746
  * e.g. no cross-domain requests without CORS.
717
- *
718
747
  * @param {DocumentInitParameters} src - Parameter object.
719
748
  * @returns {PDFDocumentLoadingTask}
720
749
  */
@@ -758,7 +787,7 @@ export class PDFDataRangeTransport {
758
787
  #private;
759
788
  }
760
789
  /**
761
- * @typedef {Object} OnProgressParameters
790
+ * @typedef {object} OnProgressParameters
762
791
  * @property {number} loaded - Currently loaded number of bytes.
763
792
  * @property {number} total - Total number of bytes in the PDF file.
764
793
  * @property {number} percent - Currently loaded percentage, as an integer value
@@ -804,14 +833,14 @@ export class PDFDocumentLoadingTask {
804
833
  * Callback to request a password if a wrong or no password was provided.
805
834
  * The callback receives two parameters: a function that should be called
806
835
  * with the new password, and a reason (see {@link PasswordResponses}).
807
- * @type {function}
836
+ * @type {Function}
808
837
  */
809
838
  onPassword: Function;
810
839
  /**
811
840
  * Callback to be able to monitor the loading progress of the PDF file
812
841
  * (necessary to implement e.g. a loading bar).
813
842
  * The callback receives an {@link OnProgressParameters} argument.
814
- * @type {function}
843
+ * @type {Function}
815
844
  */
816
845
  onProgress: Function;
817
846
  /**
@@ -849,13 +878,13 @@ export class PDFDocumentProxy {
849
878
  */
850
879
  get annotationStorage(): AnnotationStorage;
851
880
  /**
852
- * @type {Object} The canvas factory instance.
881
+ * @type {object} The canvas factory instance.
853
882
  */
854
- get canvasFactory(): Object;
883
+ get canvasFactory(): object;
855
884
  /**
856
- * @type {Object} The filter factory instance.
885
+ * @type {object} The filter factory instance.
857
886
  */
858
- get filterFactory(): Object;
887
+ get filterFactory(): object;
859
888
  /**
860
889
  * @type {number} Total number of pages in the PDF file.
861
890
  */
@@ -873,11 +902,10 @@ export class PDFDocumentProxy {
873
902
  get isPureXfa(): boolean;
874
903
  /**
875
904
  * NOTE: This is (mostly) intended to support printing of XFA forms.
876
- *
877
- * @type {Object | null} An object representing a HTML tree structure
905
+ * @type {object | null} An object representing a HTML tree structure
878
906
  * to render the XFA, or `null` when no XFA form exists.
879
907
  */
880
- get allXfaHtml(): Object | null;
908
+ get allXfaHtml(): object | null;
881
909
  /**
882
910
  * @param {number} pageNumber - The page number to get. The first page is 1.
883
911
  * @returns {Promise<PDFPageProxy>} A promise that is resolved with
@@ -891,14 +919,12 @@ export class PDFDocumentProxy {
891
919
  */
892
920
  getPageIndex(ref: RefProxy): Promise<number>;
893
921
  /**
894
- * @returns {Promise<Object<string, Array<any>>>} A promise that is resolved
922
+ * @returns {Promise<Map<string, Array<any>>>} A promise that is resolved
895
923
  * with a mapping from named destinations to references.
896
924
  *
897
925
  * This can be slow for large documents. Use `getDestination` instead.
898
926
  */
899
- getDestinations(): Promise<{
900
- [x: string]: Array<any>;
901
- }>;
927
+ getDestinations(): Promise<Map<string, Array<any>>>;
902
928
  /**
903
929
  * @param {string} id - The named destination to get.
904
930
  * @returns {Promise<Array<any> | null>} A promise that is resolved with all
@@ -923,17 +949,17 @@ export class PDFDocumentProxy {
923
949
  */
924
950
  getPageMode(): Promise<string>;
925
951
  /**
926
- * @returns {Promise<Object | null>} A promise that is resolved with an
927
- * {Object} containing the viewer preferences, or `null` when no viewer
928
- * preferences are present in the PDF file.
952
+ * @returns {Promise<Map | null>} A promise that is resolved with a {Map}
953
+ * containing the viewer preferences, or `null` when no viewer preferences
954
+ * are present in the PDF file.
929
955
  */
930
- getViewerPreferences(): Promise<Object | null>;
956
+ getViewerPreferences(): Promise<Map<any, any> | null>;
931
957
  /**
932
- * @returns {Promise<any | null>} A promise that is resolved with an {Array}
933
- * containing the destination, or `null` when no open action is present
934
- * in the PDF.
958
+ * @returns {Promise<Map | null>} A promise that is resolved with a {Map}
959
+ * containing a destination or action, or `null` when no open action is
960
+ * present in the PDF.
935
961
  */
936
- getOpenAction(): Promise<any | null>;
962
+ getOpenAction(): Promise<Map<any, any> | null>;
937
963
  /**
938
964
  * @returns {Promise<Map<string, CatalogAttachment> | null>}
939
965
  * Promise that is resolved with a lookup table for mapping named
@@ -950,20 +976,20 @@ export class PDFDocumentProxy {
950
976
  /**
951
977
  * @param {Set<number>} types - The annotation types to retrieve.
952
978
  * @param {Set<number>} pageIndexesToSkip
953
- * @returns {Promise<Array<Object>>} A promise that is resolved with a list of
979
+ * @returns {Promise<Array<object>>} A promise that is resolved with a list of
954
980
  * annotations data.
955
981
  */
956
- getAnnotationsByType(types: Set<number>, pageIndexesToSkip: Set<number>): Promise<Array<Object>>;
982
+ getAnnotationsByType(types: Set<number>, pageIndexesToSkip: Set<number>): Promise<Array<object>>;
957
983
  /**
958
- * @returns {Promise<Object | null>} A promise that is resolved with
959
- * an {Object} with the JavaScript actions:
984
+ * @returns {Promise<Map | null>} A promise that is resolved with a {Map} with
985
+ * the JavaScript actions:
960
986
  * - from the name tree.
961
987
  * - from A or AA entries in the catalog dictionary.
962
988
  * , or `null` if no JavaScript exists.
963
989
  */
964
- getJSActions(): Promise<Object | null>;
990
+ getJSActions(): Promise<Map<any, any> | null>;
965
991
  /**
966
- * @typedef {Object} OutlineNode
992
+ * @typedef {object} OutlineNode
967
993
  * @property {string} title
968
994
  * @property {boolean} bold
969
995
  * @property {boolean} italic
@@ -997,7 +1023,7 @@ export class PDFDocumentProxy {
997
1023
  items: Array</*elided*/ any>;
998
1024
  }>>;
999
1025
  /**
1000
- * @typedef {Object} GetOptionalContentConfigParameters
1026
+ * @typedef {object} GetOptionalContentConfigParameters
1001
1027
  * @property {string} [intent] - Determines the optional content groups that
1002
1028
  * are visible by default; valid values are:
1003
1029
  * - 'display' (viewable groups).
@@ -1024,24 +1050,24 @@ export class PDFDocumentProxy {
1024
1050
  intent?: string | undefined;
1025
1051
  }): Promise<OptionalContentConfig>;
1026
1052
  /**
1027
- * @returns {Promise<Array<number> | null>} A promise that is resolved with
1028
- * an {Array} that contains the permission flags for the PDF document, or
1029
- * `null` when no permissions are present in the PDF file.
1053
+ * @returns {Promise<Set<number> | null>} A promise that is resolved with
1054
+ * a {Set} that contains the permission flags for the PDF document,
1055
+ * or `null` when no permissions are present in the PDF file.
1030
1056
  */
1031
- getPermissions(): Promise<Array<number> | null>;
1057
+ getPermissions(): Promise<Set<number> | null>;
1032
1058
  /**
1033
- * @returns {Promise<{ info: Object, metadata: Metadata }>} A promise that is
1059
+ * @returns {Promise<{info: object, metadata: Metadata}>} A promise that is
1034
1060
  * resolved with an {Object} that has `info` and `metadata` properties.
1035
1061
  * `info` is an {Object} filled with anything available in the information
1036
1062
  * dictionary and similarly `metadata` is a {Metadata} object with
1037
1063
  * information from the metadata section of the PDF.
1038
1064
  */
1039
1065
  getMetadata(): Promise<{
1040
- info: Object;
1066
+ info: object;
1041
1067
  metadata: Metadata;
1042
1068
  }>;
1043
1069
  /**
1044
- * @typedef {Object} MarkInfo
1070
+ * @typedef {object} MarkInfo
1045
1071
  * Properties correspond to Table 321 of the PDF 32000-1:2008 spec.
1046
1072
  * @property {boolean} Marked
1047
1073
  * @property {boolean} UserProperties
@@ -1063,13 +1089,18 @@ export class PDFDocumentProxy {
1063
1089
  */
1064
1090
  getData(): Promise<Uint8Array>;
1065
1091
  /**
1092
+ * @param {function(Array<object>): Promise<Uint8Array | null>} [printToPDF] -
1093
+ * Firefox-only platform appearance renderer. It receives ordered
1094
+ * `{ data }` entries and returns a PDF with one page per entry, or `null`.
1095
+ * Each page must place its appearance in
1096
+ * `[0, 0, data.width, data.height]`, with dimensions in points.
1066
1097
  * @returns {Promise<Uint8Array<ArrayBuffer>>} A promise that is
1067
1098
  * resolved with a {Uint8Array<ArrayBuffer>} containing the
1068
1099
  * full data of the saved document.
1069
1100
  */
1070
- saveDocument(): Promise<Uint8Array<ArrayBuffer>>;
1101
+ saveDocument(printToPDF?: (arg0: Array<object>) => Promise<Uint8Array | null>): Promise<Uint8Array<ArrayBuffer>>;
1071
1102
  /**
1072
- * @typedef {Object} PageInfo
1103
+ * @typedef {object} PageInfo
1073
1104
  * @property {null|Uint8Array} [document]
1074
1105
  * @property {ImageBitmap} [image] Image to insert as a synthetic page.
1075
1106
  * @property {Array<Array<number>|number>} [includePages]
@@ -1099,6 +1130,10 @@ export class PDFDocumentProxy {
1099
1130
  */
1100
1131
  /**
1101
1132
  * @param {Array<PageInfo>} pageInfos - The pages to extract.
1133
+ * @param {Int32Array} [copyLevels] - For each viewer page, its rank among the
1134
+ * extracted pages sharing the same source page, or -1 if it isn't extracted.
1135
+ * This routes editor annotations when the viewer contains multiple copies
1136
+ * of a source page.
1102
1137
  * @returns {Promise<Uint8Array>} A promise that is resolved with a
1103
1138
  * {Uint8Array} containing the full data of the saved document.
1104
1139
  */
@@ -1142,7 +1177,7 @@ export class PDFDocumentProxy {
1142
1177
  * same entry.
1143
1178
  */
1144
1179
  insertAfter?: number | undefined;
1145
- }>): Promise<Uint8Array>;
1180
+ }>, copyLevels?: Int32Array): Promise<Uint8Array>;
1146
1181
  /**
1147
1182
  * @returns {Promise<{ length: number }>} A promise that is resolved when the
1148
1183
  * document's data is loaded. It is resolved with an {Object} that contains
@@ -1151,14 +1186,12 @@ export class PDFDocumentProxy {
1151
1186
  getDownloadInfo(): Promise<{
1152
1187
  length: number;
1153
1188
  }>;
1154
- getRawData(data: any): any;
1155
1189
  /**
1156
1190
  * Cleans up resources allocated by the document on both the main and worker
1157
1191
  * threads.
1158
1192
  *
1159
1193
  * NOTE: Do not, under any circumstances, call this method when rendering is
1160
1194
  * currently ongoing since that may lead to rendering errors.
1161
- *
1162
1195
  * @param {boolean} [keepLoadedFonts] - Let fonts remain attached to the DOM.
1163
1196
  * NOTE: This will increase persistent memory usage, hence don't use this
1164
1197
  * option unless absolutely necessary. The default value is `false`.
@@ -1180,12 +1213,30 @@ export class PDFDocumentProxy {
1180
1213
  */
1181
1214
  get loadingTask(): PDFDocumentLoadingTask;
1182
1215
  /**
1183
- * @returns {Promise<Object<string, Array<Object>> | null>} A promise that is
1184
- * resolved with an {Object} containing /AcroForm field data for the JS
1185
- * sandbox, or `null` when no field data is present in the PDF file.
1216
+ * @returns {Promise<Map<string, Array<object>> | null>} A promise that is
1217
+ * resolved with a {Map} containing /AcroForm field data for the JS sandbox,
1218
+ * or `null` when no field data is present in the PDF file.
1219
+ */
1220
+ getFieldObjects(): Promise<Map<string, Array<object>> | null>;
1221
+ /**
1222
+ * @returns {Promise<Array<object> | null>} A promise that is resolved
1223
+ * with an {Array} of digital signature metadata (signerName, reason,
1224
+ * signingTime, byteRange, subFilter, …), or `null` when the document
1225
+ * has no signatures. The PKCS#7 blob and signed-data byte spans
1226
+ * needed for verification are fetched separately via
1227
+ * {@link PDFDocumentProxy.getSignatureData} so they don't ride the
1228
+ * worker boundary unless verification is actually requested.
1186
1229
  */
1187
- getFieldObjects(): Promise<{
1188
- [x: string]: Array<Object>;
1230
+ getSignatures(): Promise<Array<object> | null>;
1231
+ /**
1232
+ * @param {string} id Signature `id` from a {@link getSignatures} entry.
1233
+ * @returns {Promise<{ data: Uint8Array[], pkcs7: Uint8Array } | null>}
1234
+ * The byte payload needed to verify the signature, or `null` if the
1235
+ * id is unknown.
1236
+ */
1237
+ getSignatureData(id: string): Promise<{
1238
+ data: Uint8Array[];
1239
+ pkcs7: Uint8Array;
1189
1240
  } | null>;
1190
1241
  /**
1191
1242
  * @returns {Promise<boolean>} A promise that is resolved with `true`
@@ -1201,8 +1252,7 @@ export class PDFDocumentProxy {
1201
1252
  }
1202
1253
  /**
1203
1254
  * Page getViewport parameters.
1204
- *
1205
- * @typedef {Object} GetViewportParameters
1255
+ * @typedef {object} GetViewportParameters
1206
1256
  * @property {number} scale - The desired scale of the viewport.
1207
1257
  * @property {number} [rotation] - The desired rotation, in degrees, of
1208
1258
  * the viewport. If omitted it defaults to the page rotation.
@@ -1215,8 +1265,7 @@ export class PDFDocumentProxy {
1215
1265
  */
1216
1266
  /**
1217
1267
  * Page getTextContent parameters.
1218
- *
1219
- * @typedef {Object} getTextContentParameters
1268
+ * @typedef {object} getTextContentParameters
1220
1269
  * @property {boolean} [includeMarkedContent] - When true include marked
1221
1270
  * content items in the items array of TextContent. The default is `false`.
1222
1271
  * @property {boolean} [disableNormalization] - When true the text is *not*
@@ -1224,19 +1273,17 @@ export class PDFDocumentProxy {
1224
1273
  */
1225
1274
  /**
1226
1275
  * Page text content.
1227
- *
1228
- * @typedef {Object} TextContent
1276
+ * @typedef {object} TextContent
1229
1277
  * @property {Array<TextItem | TextMarkedContent>} items - Array of
1230
1278
  * {@link TextItem} and {@link TextMarkedContent} objects. TextMarkedContent
1231
1279
  * items are included when includeMarkedContent is true.
1232
- * @property {Object<string, TextStyle>} styles - {@link TextStyle} objects,
1280
+ * @property {Record<string, TextStyle>} styles - {@link TextStyle} objects,
1233
1281
  * indexed by font name.
1234
1282
  * @property {string | null} lang - The document /Lang attribute.
1235
1283
  */
1236
1284
  /**
1237
1285
  * Page text content part.
1238
- *
1239
- * @typedef {Object} TextItem
1286
+ * @typedef {object} TextItem
1240
1287
  * @property {string} str - Text content.
1241
1288
  * @property {string} dir - Text direction: 'ttb', 'ltr' or 'rtl'.
1242
1289
  * @property {Array<any>} transform - Transformation matrix.
@@ -1248,8 +1295,7 @@ export class PDFDocumentProxy {
1248
1295
  */
1249
1296
  /**
1250
1297
  * Page text marked content part.
1251
- *
1252
- * @typedef {Object} TextMarkedContent
1298
+ * @typedef {object} TextMarkedContent
1253
1299
  * @property {string} type - Either 'beginMarkedContent',
1254
1300
  * 'beginMarkedContentProps', or 'endMarkedContent'.
1255
1301
  * @property {string} id - The marked content identifier. Only used for type
@@ -1257,8 +1303,7 @@ export class PDFDocumentProxy {
1257
1303
  */
1258
1304
  /**
1259
1305
  * Text style.
1260
- *
1261
- * @typedef {Object} TextStyle
1306
+ * @typedef {object} TextStyle
1262
1307
  * @property {number} ascent - Font ascent.
1263
1308
  * @property {number} descent - Font descent.
1264
1309
  * @property {boolean} vertical - Whether or not the text is in vertical mode.
@@ -1266,16 +1311,14 @@ export class PDFDocumentProxy {
1266
1311
  */
1267
1312
  /**
1268
1313
  * Page annotation parameters.
1269
- *
1270
- * @typedef {Object} GetAnnotationsParameters
1314
+ * @typedef {object} GetAnnotationsParameters
1271
1315
  * @property {string} [intent] - Determines the annotations that are fetched,
1272
1316
  * can be 'display' (viewable annotations), 'print' (printable annotations),
1273
1317
  * or 'any' (all annotations). The default value is 'display'.
1274
1318
  */
1275
1319
  /**
1276
1320
  * Page render parameters.
1277
- *
1278
- * @typedef {Object} RenderParameters
1321
+ * @typedef {object} RenderParameters
1279
1322
  * @property {HTMLCanvasElement|null} canvas - A DOM Canvas object. The default
1280
1323
  * value is the canvas associated with the `canvasContext` parameter if no
1281
1324
  * value is provided explicitly.
@@ -1311,7 +1354,7 @@ export class PDFDocumentProxy {
1311
1354
  *
1312
1355
  * NOTE: This option may be partially, or completely, ignored when the
1313
1356
  * `pageColors`-option is used.
1314
- * @property {Object} [pageColors] - Overwrites background and foreground colors
1357
+ * @property {object} [pageColors] - Overwrites background and foreground colors
1315
1358
  * with user defined ones in order to improve readability in high contrast
1316
1359
  * mode.
1317
1360
  * @property {Promise<OptionalContentConfig>} [optionalContentConfigPromise] -
@@ -1332,12 +1375,12 @@ export class PDFDocumentProxy {
1332
1375
  /**
1333
1376
  * @callback OperationsFilter
1334
1377
  * @param {number} index - The index of the operation.
1378
+ * @param {PDFOperatorList} operatorList - The page operator list.
1335
1379
  * @returns {boolean} If false, the operation is ignored.
1336
1380
  */
1337
1381
  /**
1338
1382
  * Page getOperatorList parameters.
1339
- *
1340
- * @typedef {Object} GetOperatorListParameters
1383
+ * @typedef {object} GetOperatorListParameters
1341
1384
  * @property {string} [intent] - Rendering intent, can be 'display', 'print',
1342
1385
  * or 'any'. The default value is 'display'.
1343
1386
  * @property {number} [annotationMode] Controls which annotations are included
@@ -1357,25 +1400,34 @@ export class PDFDocumentProxy {
1357
1400
  */
1358
1401
  /**
1359
1402
  * Structure tree node. The root node will have a role "Root".
1360
- *
1361
- * @typedef {Object} StructTreeNode
1403
+ * @typedef {object} StructTreeNode
1362
1404
  * @property {Array<StructTreeNode | StructTreeContent>} children - Array of
1363
1405
  * {@link StructTreeNode} and {@link StructTreeContent} objects.
1364
1406
  * @property {string} role - element's role, already mapped if a role map exists
1365
1407
  * in the PDF.
1408
+ * @property {string} [structId] - A table header's structure element
1409
+ * identifier, i.e. its `ID` entry. Note that this is unrelated to the `id`
1410
+ * property of a {@link StructTreeContent} object.
1411
+ * @property {number} [rowSpan] - The number of rows spanned by a table cell.
1412
+ * @property {number} [colSpan] - The number of columns spanned by a table cell.
1413
+ * @property {Array<string>} [headers] - The `structId` values of the table
1414
+ * headers associated with a table cell.
1415
+ * @property {"Row" | "Column" | "Both"} [scope] - The cells to which a table
1416
+ * header applies.
1417
+ * @property {string} [short] - An abbreviated version of a table header's
1418
+ * content.
1419
+ * @property {string} [summary] - A summary of a table's purpose and structure.
1366
1420
  */
1367
1421
  /**
1368
1422
  * Structure tree content.
1369
- *
1370
- * @typedef {Object} StructTreeContent
1423
+ * @typedef {object} StructTreeContent
1371
1424
  * @property {string} type - either "content" for page and stream structure
1372
1425
  * elements or "object" for object references.
1373
1426
  * @property {string} id - unique id that will map to the text layer.
1374
1427
  */
1375
1428
  /**
1376
1429
  * PDF page operator list.
1377
- *
1378
- * @typedef {Object} PDFOperatorList
1430
+ * @typedef {object} PDFOperatorList
1379
1431
  * @property {Array<number>} fnArray - Array containing the operator functions.
1380
1432
  * @property {Array<any>} argsArray - Array containing the arguments of the
1381
1433
  * functions.
@@ -1384,8 +1436,10 @@ export class PDFDocumentProxy {
1384
1436
  * Proxy to a `PDFPage` in the worker thread.
1385
1437
  */
1386
1438
  export class PDFPageProxy {
1439
+ static #idCounter: number;
1387
1440
  constructor(pageIndex: any, pageInfo: any, transport: any, pagesMapper: any, pdfBug?: boolean);
1388
1441
  _pageIndex: any;
1442
+ _id: number;
1389
1443
  _pageInfo: any;
1390
1444
  _transport: any;
1391
1445
  _stats: StatTimer | null;
@@ -1436,28 +1490,27 @@ export class PDFPageProxy {
1436
1490
  */
1437
1491
  getAnnotations({ intent }?: GetAnnotationsParameters): Promise<Array<any>>;
1438
1492
  /**
1439
- * @returns {Promise<Object>} A promise that is resolved with an
1440
- * {Object} with JS actions.
1493
+ * @returns {Promise<Map | null>} A promise that is resolved with a {Map} with
1494
+ * the JavaScript actions, or `null` if no JavaScript exists.
1441
1495
  */
1442
- getJSActions(): Promise<Object>;
1496
+ getJSActions(): Promise<Map<any, any> | null>;
1443
1497
  /**
1444
- * @type {Object} The filter factory instance.
1498
+ * @type {object} The filter factory instance.
1445
1499
  */
1446
- get filterFactory(): Object;
1500
+ get filterFactory(): object;
1447
1501
  /**
1448
1502
  * @type {boolean} True if only XFA form.
1449
1503
  */
1450
1504
  get isPureXfa(): boolean;
1451
1505
  /**
1452
- * @returns {Promise<Object | null>} A promise that is resolved with
1506
+ * @returns {Promise<object | null>} A promise that is resolved with
1453
1507
  * an {Object} with a fake DOM object (a tree structure where elements
1454
1508
  * are {Object} with a name, attributes (class, style, ...), value and
1455
1509
  * children, very similar to a HTML DOM tree), or `null` if no XFA exists.
1456
1510
  */
1457
- getXfa(): Promise<Object | null>;
1511
+ getXfa(): Promise<object | null>;
1458
1512
  /**
1459
1513
  * Begins the process of rendering a page to the desired context.
1460
- *
1461
1514
  * @param {RenderParameters} params - Page render parameters.
1462
1515
  * @returns {RenderTask} An object that contains a promise that is
1463
1516
  * resolved when the page finishes rendering.
@@ -1473,7 +1526,6 @@ export class PDFPageProxy {
1473
1526
  /**
1474
1527
  * NOTE: All occurrences of whitespace will be replaced by
1475
1528
  * standard spaces (0x20).
1476
- *
1477
1529
  * @param {getTextContentParameters} params - getTextContent parameters.
1478
1530
  * @returns {ReadableStream} Stream for reading text content chunks.
1479
1531
  */
@@ -1481,7 +1533,6 @@ export class PDFPageProxy {
1481
1533
  /**
1482
1534
  * NOTE: All occurrences of whitespace will be replaced by
1483
1535
  * standard spaces (0x20).
1484
- *
1485
1536
  * @param {getTextContentParameters} params - getTextContent parameters.
1486
1537
  * @returns {Promise<TextContent>} A promise that is resolved with a
1487
1538
  * {@link TextContent} object that represents the page's text content.
@@ -1500,7 +1551,6 @@ export class PDFPageProxy {
1500
1551
  private _destroy;
1501
1552
  /**
1502
1553
  * Cleans up resources allocated by the page.
1503
- *
1504
1554
  * @param {boolean} [resetStats] - Reset page stats, if enabled.
1505
1555
  * The default value is `false`.
1506
1556
  * @returns {boolean} Indicates if clean-up was successfully run.
@@ -1530,7 +1580,7 @@ export class PDFPageProxy {
1530
1580
  #private;
1531
1581
  }
1532
1582
  /**
1533
- * @typedef {Object} PDFWorkerParameters
1583
+ * @typedef {object} PDFWorkerParameters
1534
1584
  * @property {string} [name] - The name of the worker.
1535
1585
  * @property {Worker} [port] - The `workerPort` object.
1536
1586
  * @property {number} [verbosity] - Controls the logging level;
@@ -1541,7 +1591,6 @@ export class PDFPageProxy {
1541
1591
  * documents. Message handlers are used to pass information from the main
1542
1592
  * thread to the worker thread and vice versa. If the creation of a web
1543
1593
  * worker is not possible, a "fake" worker will be used instead.
1544
- *
1545
1594
  * @param {PDFWorkerParameters} params - The worker initialization parameters.
1546
1595
  */
1547
1596
  export class PDFWorker {
@@ -1599,15 +1648,14 @@ export class RenderTask {
1599
1648
  * Callback for incremental rendering -- a function that will be called
1600
1649
  * each time the rendering is paused. To continue rendering call the
1601
1650
  * function that is the first argument to the callback.
1602
- * @type {function}
1651
+ * @type {Function}
1603
1652
  */
1604
1653
  onContinue: Function;
1605
1654
  /**
1606
1655
  * A function that will be synchronously called when the rendering tasks
1607
1656
  * finishes with an error (either because of an actual error, or because the
1608
1657
  * rendering is cancelled).
1609
- *
1610
- * @type {function}
1658
+ * @type {Function}
1611
1659
  * @param {Error} error
1612
1660
  */
1613
1661
  onError: Function;
@@ -1620,7 +1668,6 @@ export class RenderTask {
1620
1668
  * Cancels the rendering task. If the task is currently rendering it will
1621
1669
  * not be cancelled until graphics pauses with a timeout. The promise that
1622
1670
  * this object extends will be rejected when cancelled.
1623
- *
1624
1671
  * @param {number} [extraDelay]
1625
1672
  */
1626
1673
  cancel(extraDelay?: number): void;