unpdf 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.cjs +382 -384
- package/dist/index.d.cts +97 -94
- package/dist/index.d.mts +97 -94
- package/dist/index.mjs +381 -382
- package/dist/pdfjs.mjs +52 -59
- package/dist/types/external/brotli/decode.d.ts +5 -0
- package/dist/types/external/jbig2/jbig2.d.ts +2 -0
- package/dist/types/external/openjpeg/openjpeg.d.ts +2 -0
- package/dist/types/external/qcms/qcms.d.ts +92 -0
- package/dist/types/external/qcms/qcms_utils.d.ts +14 -0
- package/dist/types/src/core/ascii_85_stream.d.ts +7 -0
- package/dist/types/src/core/ascii_hex_stream.d.ts +7 -0
- package/dist/types/src/core/base_stream.d.ts +45 -0
- package/dist/types/src/core/brotli_stream.d.ts +9 -0
- package/dist/types/src/core/calculate_md5.d.ts +1 -0
- package/dist/types/src/core/calculate_sha256.d.ts +1 -0
- package/dist/types/src/core/calculate_sha_other.d.ts +2 -0
- package/dist/types/src/core/catalog.d.ts +169 -0
- package/dist/types/src/core/ccitt_stream.d.ts +18 -0
- package/dist/types/src/core/cleanup_helper.d.ts +1 -0
- package/dist/types/src/core/colorspace.d.ts +177 -0
- package/dist/types/src/core/colorspace_utils.d.ts +21 -0
- package/dist/types/src/core/core_utils.d.ts +132 -0
- package/dist/types/src/core/crypto.d.ts +136 -0
- package/dist/types/src/core/decode_stream.d.ts +32 -0
- package/dist/types/src/core/decrypt_stream.d.ts +9 -0
- package/dist/types/src/core/file_spec.d.ts +72 -0
- package/dist/types/src/core/flate_stream.d.ts +14 -0
- package/dist/types/src/core/icc_colorspace.d.ts +22 -0
- package/dist/types/src/core/image_utils.d.ts +52 -0
- package/dist/types/src/core/jbig2_ccittFax.d.ts +13 -0
- package/dist/types/src/core/jbig2_stream.d.ts +17 -0
- package/dist/types/src/core/jpeg_stream.d.ts +24 -0
- package/dist/types/src/core/jpg.d.ts +62 -0
- package/dist/types/src/core/jpx.d.ts +24 -0
- package/dist/types/src/core/jpx_stream.d.ts +15 -0
- package/dist/types/src/core/lzw_stream.d.ts +19 -0
- package/dist/types/src/core/metadata_parser.d.ts +13 -0
- package/dist/types/src/core/name_number_tree.d.ts +21 -0
- package/dist/types/src/core/parser.d.ts +121 -0
- package/dist/types/src/core/pattern.d.ts +63 -0
- package/dist/types/src/core/predictor_stream.d.ts +14 -0
- package/dist/types/src/core/primitives.d.ts +81 -0
- package/dist/types/src/core/run_length_stream.d.ts +6 -0
- package/dist/types/src/core/stream.d.ts +20 -0
- package/dist/types/src/core/string_utils.d.ts +5 -0
- package/dist/types/src/core/struct_tree.d.ts +93 -0
- package/dist/types/src/core/unicode.d.ts +5 -0
- package/dist/types/src/core/wasm_image.d.ts +21 -0
- package/dist/types/src/core/xml_parser.d.ts +79 -0
- package/dist/types/src/core/xref.d.ts +52 -0
- package/dist/types/src/display/annotation_layer.d.ts +10 -8
- package/dist/types/src/display/api.d.ts +92 -65
- package/dist/types/src/display/binary_data_factory.d.ts +0 -4
- package/dist/types/src/display/canvas.d.ts +58 -12
- package/dist/types/src/display/canvas_dependency_tracker.d.ts +2 -2
- package/dist/types/src/display/display_utils.d.ts +4 -156
- package/dist/types/src/display/draw_layer.d.ts +127 -2
- package/dist/types/src/display/editor/alt_text.d.ts +1 -1
- package/dist/types/src/display/editor/annotation_editor_layer.d.ts +3 -3
- package/dist/types/src/display/editor/color_picker.d.ts +3 -2
- package/dist/types/src/display/editor/draw.d.ts +10 -3
- package/dist/types/src/display/editor/drawers/freedraw.d.ts +3 -3
- package/dist/types/src/display/editor/drawers/highlight.d.ts +0 -1
- package/dist/types/src/display/editor/drawers/outline.d.ts +0 -1
- package/dist/types/src/display/editor/drawers/signaturedraw.d.ts +13 -13
- package/dist/types/src/display/editor/editor.d.ts +2 -1
- package/dist/types/src/display/editor/freetext.d.ts +2 -2
- package/dist/types/src/display/editor/highlight.d.ts +3 -3
- package/dist/types/src/display/editor/ink.d.ts +2 -0
- package/dist/types/src/display/editor/toolbar.d.ts +2 -2
- package/dist/types/src/display/editor/tools.d.ts +31 -14
- package/dist/types/src/display/filter_factory.d.ts +26 -0
- package/dist/types/src/display/node_utils.d.ts +2 -2
- package/dist/types/src/display/obj_bin_transform_display.d.ts +2 -6
- package/dist/types/src/display/optional_content_config.d.ts +13 -3
- package/dist/types/src/display/page_viewport.d.ts +137 -0
- package/dist/types/src/display/pattern_helper.d.ts +11 -4
- package/dist/types/src/display/text_layer.d.ts +10 -10
- package/dist/types/src/display/text_layer_images.d.ts +1 -1
- package/dist/types/src/display/webgpu.d.ts +11 -0
- package/dist/types/src/display/worker_options.d.ts +2 -2
- package/dist/types/src/display/xfa_layer.d.ts +8 -1
- package/dist/types/src/pdf.d.ts +5 -4
- package/dist/types/src/shared/image_utils.d.ts +11 -0
- package/dist/types/src/shared/internal_evt.d.ts +7 -0
- package/dist/types/src/shared/math_clamp.d.ts +1 -0
- package/dist/types/src/shared/util.d.ts +24 -13
- package/dist/types/web/annotation_editor_layer_builder.d.ts +1 -1
- package/dist/types/web/annotation_layer_builder.d.ts +6 -3
- package/dist/types/web/app_options.d.ts +1 -1
- package/dist/types/web/autolinker.d.ts +3 -3
- package/dist/types/web/base_pdf_page_view.d.ts +1 -0
- package/dist/types/web/comment_manager.d.ts +1 -1
- package/dist/types/web/draw_layer_builder.d.ts +44 -0
- package/dist/types/web/event_utils.d.ts +0 -8
- package/dist/types/web/generic_scripting.d.ts +1 -1
- package/dist/types/web/genericl10n.d.ts +5 -5
- package/dist/types/web/internal_evt.d.ts +7 -0
- package/dist/types/web/l10n.d.ts +2 -2
- package/dist/types/web/pdf_find_controller.d.ts +12 -1
- package/dist/types/web/pdf_link_service.d.ts +8 -0
- package/dist/types/web/pdf_page_view.d.ts +10 -3
- package/dist/types/web/pdf_thumbnail_view.d.ts +5 -5
- package/dist/types/web/pdf_thumbnail_viewer.d.ts +31 -12
- package/dist/types/web/pdf_viewer.d.ts +15 -1
- package/dist/types/web/text_accessibility.d.ts +1 -1
- package/dist/types/web/text_layer_builder.d.ts +5 -5
- package/dist/types/web/xfa_layer_builder.d.ts +3 -3
- package/package.json +23 -23
- package/dist/index.d.ts +0 -189
- package/dist/types/src/display/webgpu_mesh.d.ts +0 -3
|
@@ -121,12 +121,6 @@ export type DocumentInitParameters = {
|
|
|
121
121
|
* Use -1 for no limit, which is also the default value.
|
|
122
122
|
*/
|
|
123
123
|
maxImageSize?: number | undefined;
|
|
124
|
-
/**
|
|
125
|
-
* - Determines if we can evaluate strings
|
|
126
|
-
* as JavaScript. Primarily used to improve performance of PDF functions.
|
|
127
|
-
* The default value is `true`.
|
|
128
|
-
*/
|
|
129
|
-
isEvalSupported?: boolean | undefined;
|
|
130
124
|
/**
|
|
131
125
|
* - Determines if we can use
|
|
132
126
|
* `OffscreenCanvas` in the worker. Primarily used to improve performance of
|
|
@@ -139,16 +133,6 @@ export type DocumentInitParameters = {
|
|
|
139
133
|
* `ImageDecoder` in the worker. Primarily used to improve performance of
|
|
140
134
|
* image conversion/rendering.
|
|
141
135
|
* The default value is `true` in web environments and `false` in Node.js.
|
|
142
|
-
*
|
|
143
|
-
* NOTE: Also temporarily disabled in Chromium browsers, until we no longer
|
|
144
|
-
* support the affected browser versions, because of various bugs:
|
|
145
|
-
*
|
|
146
|
-
* - Crashes when using the BMP decoder with huge images, e.g. issue6741.pdf;
|
|
147
|
-
* see https://issues.chromium.org/issues/374807001
|
|
148
|
-
*
|
|
149
|
-
* - Broken images when using the JPEG decoder with images that have custom
|
|
150
|
-
* colour profiles, e.g. GitHub discussion 19030;
|
|
151
|
-
* see https://issues.chromium.org/issues/378869810
|
|
152
136
|
*/
|
|
153
137
|
isImageDecoderSupported?: boolean | undefined;
|
|
154
138
|
/**
|
|
@@ -592,6 +576,12 @@ export type PDFWorkerParameters = {
|
|
|
592
576
|
};
|
|
593
577
|
/** @type {string} */
|
|
594
578
|
export const build: string;
|
|
579
|
+
/**
|
|
580
|
+
* @import {
|
|
581
|
+
* CatalogAttachmentContent,
|
|
582
|
+
* CatalogAttachment
|
|
583
|
+
* } from "../core/catalog.js";
|
|
584
|
+
*/
|
|
595
585
|
/**
|
|
596
586
|
* @typedef { Int8Array | Uint8Array | Uint8ClampedArray |
|
|
597
587
|
* Int16Array | Uint16Array |
|
|
@@ -662,9 +652,6 @@ export const build: string;
|
|
|
662
652
|
* @property {number} [maxImageSize] - The maximum allowed image size in total
|
|
663
653
|
* pixels, i.e. width * height. Images above this value will not be rendered.
|
|
664
654
|
* Use -1 for no limit, which is also the default value.
|
|
665
|
-
* @property {boolean} [isEvalSupported] - Determines if we can evaluate strings
|
|
666
|
-
* as JavaScript. Primarily used to improve performance of PDF functions.
|
|
667
|
-
* The default value is `true`.
|
|
668
655
|
* @property {boolean} [isOffscreenCanvasSupported] - Determines if we can use
|
|
669
656
|
* `OffscreenCanvas` in the worker. Primarily used to improve performance of
|
|
670
657
|
* image conversion/rendering.
|
|
@@ -673,17 +660,6 @@ export const build: string;
|
|
|
673
660
|
* `ImageDecoder` in the worker. Primarily used to improve performance of
|
|
674
661
|
* image conversion/rendering.
|
|
675
662
|
* The default value is `true` in web environments and `false` in Node.js.
|
|
676
|
-
*
|
|
677
|
-
* NOTE: Also temporarily disabled in Chromium browsers, until we no longer
|
|
678
|
-
* support the affected browser versions, because of various bugs:
|
|
679
|
-
*
|
|
680
|
-
* - Crashes when using the BMP decoder with huge images, e.g. issue6741.pdf;
|
|
681
|
-
* see https://issues.chromium.org/issues/374807001
|
|
682
|
-
*
|
|
683
|
-
* - Broken images when using the JPEG decoder with images that have custom
|
|
684
|
-
* colour profiles, e.g. GitHub discussion 19030;
|
|
685
|
-
* see https://issues.chromium.org/issues/378869810
|
|
686
|
-
*
|
|
687
663
|
* @property {number} [canvasMaxAreaInBytes] - The integer value is used to
|
|
688
664
|
* know when an image must be resized (uses `OffscreenCanvas` in the worker).
|
|
689
665
|
* If it's -1 then a possibly slow algorithm is used to guess the max value.
|
|
@@ -739,12 +715,10 @@ export const build: string;
|
|
|
739
715
|
* XHR as fallback) is used, which means it must follow same origin rules,
|
|
740
716
|
* e.g. no cross-domain requests without CORS.
|
|
741
717
|
*
|
|
742
|
-
* @param {
|
|
743
|
-
* src - Can be a URL where a PDF file is located, a typed array (Uint8Array)
|
|
744
|
-
* already populated with data, or a parameter object.
|
|
718
|
+
* @param {DocumentInitParameters} src - Parameter object.
|
|
745
719
|
* @returns {PDFDocumentLoadingTask}
|
|
746
720
|
*/
|
|
747
|
-
export function getDocument(src?:
|
|
721
|
+
export function getDocument(src?: DocumentInitParameters): PDFDocumentLoadingTask;
|
|
748
722
|
/**
|
|
749
723
|
* Abstract class to support range requests file loading.
|
|
750
724
|
*
|
|
@@ -764,18 +738,6 @@ export class PDFDataRangeTransport {
|
|
|
764
738
|
initialData: Uint8Array<ArrayBufferLike> | null;
|
|
765
739
|
progressiveDone: boolean;
|
|
766
740
|
contentDispositionFilename: string;
|
|
767
|
-
/**
|
|
768
|
-
* @param {function} listener
|
|
769
|
-
*/
|
|
770
|
-
addRangeListener(listener: Function): void;
|
|
771
|
-
/**
|
|
772
|
-
* @param {function} listener
|
|
773
|
-
*/
|
|
774
|
-
addProgressiveReadListener(listener: Function): void;
|
|
775
|
-
/**
|
|
776
|
-
* @param {function} listener
|
|
777
|
-
*/
|
|
778
|
-
addProgressiveDoneListener(listener: Function): void;
|
|
779
741
|
/**
|
|
780
742
|
* @param {number} begin
|
|
781
743
|
* @param {Uint8Array|null} chunk
|
|
@@ -786,7 +748,7 @@ export class PDFDataRangeTransport {
|
|
|
786
748
|
*/
|
|
787
749
|
onDataProgressiveRead(chunk: Uint8Array | null): void;
|
|
788
750
|
onDataProgressiveDone(): void;
|
|
789
|
-
transportReady(): void;
|
|
751
|
+
transportReady(listener: any): void;
|
|
790
752
|
/**
|
|
791
753
|
* @param {number} begin
|
|
792
754
|
* @param {number} end
|
|
@@ -808,11 +770,18 @@ export class PDFDataRangeTransport {
|
|
|
808
770
|
* after which individual pages can be rendered.
|
|
809
771
|
*/
|
|
810
772
|
export class PDFDocumentLoadingTask {
|
|
811
|
-
static
|
|
773
|
+
static #docId: number;
|
|
812
774
|
/**
|
|
813
775
|
* @private
|
|
814
776
|
*/
|
|
815
777
|
private _capability;
|
|
778
|
+
/**
|
|
779
|
+
* Resolves once the load-time setup chain has settled, regardless of
|
|
780
|
+
* outcome; used by `destroy()` to wait until `_transport` is either set
|
|
781
|
+
* or definitely never going to be.
|
|
782
|
+
* @private
|
|
783
|
+
*/
|
|
784
|
+
private _setupCapability;
|
|
816
785
|
/**
|
|
817
786
|
* @private
|
|
818
787
|
*/
|
|
@@ -966,10 +935,18 @@ export class PDFDocumentProxy {
|
|
|
966
935
|
*/
|
|
967
936
|
getOpenAction(): Promise<any | null>;
|
|
968
937
|
/**
|
|
969
|
-
* @returns {Promise<
|
|
970
|
-
*
|
|
938
|
+
* @returns {Promise<Map<string, CatalogAttachment> | null>}
|
|
939
|
+
* Promise that is resolved with a lookup table for mapping named
|
|
940
|
+
* attachments to their content.
|
|
971
941
|
*/
|
|
972
|
-
getAttachments(): Promise<
|
|
942
|
+
getAttachments(): Promise<Map<string, CatalogAttachment> | null>;
|
|
943
|
+
/**
|
|
944
|
+
* @param {string} id
|
|
945
|
+
* Unique attachment identifier (required).
|
|
946
|
+
* @returns {Promise<CatalogAttachmentContent>}
|
|
947
|
+
* Promise that resolves to attachment content.
|
|
948
|
+
*/
|
|
949
|
+
getAttachmentContent(id: string): Promise<CatalogAttachmentContent>;
|
|
973
950
|
/**
|
|
974
951
|
* @param {Set<number>} types - The annotation types to retrieve.
|
|
975
952
|
* @param {Set<number>} pageIndexesToSkip
|
|
@@ -1086,17 +1063,39 @@ export class PDFDocumentProxy {
|
|
|
1086
1063
|
*/
|
|
1087
1064
|
getData(): Promise<Uint8Array>;
|
|
1088
1065
|
/**
|
|
1089
|
-
* @returns {Promise<Uint8Array
|
|
1090
|
-
* {Uint8Array} containing the
|
|
1066
|
+
* @returns {Promise<Uint8Array<ArrayBuffer>>} A promise that is
|
|
1067
|
+
* resolved with a {Uint8Array<ArrayBuffer>} containing the
|
|
1068
|
+
* full data of the saved document.
|
|
1091
1069
|
*/
|
|
1092
|
-
saveDocument(): Promise<Uint8Array
|
|
1070
|
+
saveDocument(): Promise<Uint8Array<ArrayBuffer>>;
|
|
1093
1071
|
/**
|
|
1094
1072
|
* @typedef {Object} PageInfo
|
|
1095
|
-
* @property {null|Uint8Array} document
|
|
1073
|
+
* @property {null|Uint8Array} [document]
|
|
1074
|
+
* @property {ImageBitmap} [image] Image to insert as a synthetic page.
|
|
1096
1075
|
* @property {Array<Array<number>|number>} [includePages]
|
|
1097
1076
|
* included ranges or indices.
|
|
1098
1077
|
* @property {Array<Array<number>|number>} [excludePages]
|
|
1099
1078
|
* excluded ranges or indices.
|
|
1079
|
+
* @property {Array<number>} [pageIndices] Explicit 0-based positions in the
|
|
1080
|
+
* final document for pages contributed by this entry. If shorter than the
|
|
1081
|
+
* filtered page list, the remaining pages are placed in the first free
|
|
1082
|
+
* slots at extraction time. Positions must not overlap with those of
|
|
1083
|
+
* other entries, and the union of all explicit/auto-filled positions
|
|
1084
|
+
* across the call must form a dense `[0, N)` range (where `N` is the
|
|
1085
|
+
* total page count of the final document) — sparse layouts leave empty
|
|
1086
|
+
* slots and are not supported. Cannot be combined with `insertAfter` on
|
|
1087
|
+
* the same entry, and must fully cover the filtered page list when any
|
|
1088
|
+
* entry in the same call specifies `insertAfter` (partial arrays are
|
|
1089
|
+
* rejected in that case).
|
|
1090
|
+
* @property {number} [insertAfter] 0-based index in the base sequential
|
|
1091
|
+
* sequence (the concatenation of entries that have neither `pageIndices`
|
|
1092
|
+
* nor `insertAfter`) after which to insert the pages. When every
|
|
1093
|
+
* contributing entry carries explicit `pageIndices`, this is interpreted
|
|
1094
|
+
* against that explicit layout instead, shifting any existing positions
|
|
1095
|
+
* beyond the insertion point to make room. Use `-1` to insert before
|
|
1096
|
+
* everything. Values beyond the current layout are clamped so the pages
|
|
1097
|
+
* are appended at the end. Cannot be combined with `pageIndices` on the
|
|
1098
|
+
* same entry.
|
|
1100
1099
|
*/
|
|
1101
1100
|
/**
|
|
1102
1101
|
* @param {Array<PageInfo>} pageInfos - The pages to extract.
|
|
@@ -1104,7 +1103,11 @@ export class PDFDocumentProxy {
|
|
|
1104
1103
|
* {Uint8Array} containing the full data of the saved document.
|
|
1105
1104
|
*/
|
|
1106
1105
|
extractPages(pageInfos: Array<{
|
|
1107
|
-
document
|
|
1106
|
+
document?: Uint8Array<ArrayBufferLike> | null | undefined;
|
|
1107
|
+
/**
|
|
1108
|
+
* Image to insert as a synthetic page.
|
|
1109
|
+
*/
|
|
1110
|
+
image?: ImageBitmap | undefined;
|
|
1108
1111
|
/**
|
|
1109
1112
|
* included ranges or indices.
|
|
1110
1113
|
*/
|
|
@@ -1113,6 +1116,32 @@ export class PDFDocumentProxy {
|
|
|
1113
1116
|
* excluded ranges or indices.
|
|
1114
1117
|
*/
|
|
1115
1118
|
excludePages?: (number | number[])[] | undefined;
|
|
1119
|
+
/**
|
|
1120
|
+
* Explicit 0-based positions in the
|
|
1121
|
+
* final document for pages contributed by this entry. If shorter than the
|
|
1122
|
+
* filtered page list, the remaining pages are placed in the first free
|
|
1123
|
+
* slots at extraction time. Positions must not overlap with those of
|
|
1124
|
+
* other entries, and the union of all explicit/auto-filled positions
|
|
1125
|
+
* across the call must form a dense `[0, N)` range (where `N` is the
|
|
1126
|
+
* total page count of the final document) — sparse layouts leave empty
|
|
1127
|
+
* slots and are not supported. Cannot be combined with `insertAfter` on
|
|
1128
|
+
* the same entry, and must fully cover the filtered page list when any
|
|
1129
|
+
* entry in the same call specifies `insertAfter` (partial arrays are
|
|
1130
|
+
* rejected in that case).
|
|
1131
|
+
*/
|
|
1132
|
+
pageIndices?: number[] | undefined;
|
|
1133
|
+
/**
|
|
1134
|
+
* 0-based index in the base sequential
|
|
1135
|
+
* sequence (the concatenation of entries that have neither `pageIndices`
|
|
1136
|
+
* nor `insertAfter`) after which to insert the pages. When every
|
|
1137
|
+
* contributing entry carries explicit `pageIndices`, this is interpreted
|
|
1138
|
+
* against that explicit layout instead, shifting any existing positions
|
|
1139
|
+
* beyond the insertion point to make room. Use `-1` to insert before
|
|
1140
|
+
* everything. Values beyond the current layout are clamped so the pages
|
|
1141
|
+
* are appended at the end. Cannot be combined with `pageIndices` on the
|
|
1142
|
+
* same entry.
|
|
1143
|
+
*/
|
|
1144
|
+
insertAfter?: number | undefined;
|
|
1116
1145
|
}>): Promise<Uint8Array>;
|
|
1117
1146
|
/**
|
|
1118
1147
|
* @returns {Promise<{ length: number }>} A promise that is resolved when the
|
|
@@ -1136,10 +1165,6 @@ export class PDFDocumentProxy {
|
|
|
1136
1165
|
* @returns {Promise} A promise that is resolved when clean-up has finished.
|
|
1137
1166
|
*/
|
|
1138
1167
|
cleanup(keepLoadedFonts?: boolean): Promise<any>;
|
|
1139
|
-
/**
|
|
1140
|
-
* Destroys the current document instance and terminates the worker.
|
|
1141
|
-
*/
|
|
1142
|
-
destroy(): Promise<void>;
|
|
1143
1168
|
/**
|
|
1144
1169
|
* @param {RefProxy} ref - The page reference.
|
|
1145
1170
|
* @returns {number | null} The page number, if it's cached.
|
|
@@ -1520,9 +1545,9 @@ export class PDFPageProxy {
|
|
|
1520
1545
|
* @param {PDFWorkerParameters} params - The worker initialization parameters.
|
|
1521
1546
|
*/
|
|
1522
1547
|
export class PDFWorker {
|
|
1523
|
-
static
|
|
1524
|
-
static
|
|
1525
|
-
static
|
|
1548
|
+
static #fakeWorkerId: number;
|
|
1549
|
+
static #isWorkerDisabled: boolean;
|
|
1550
|
+
static #workerPorts: WeakMap<object, any>;
|
|
1526
1551
|
/**
|
|
1527
1552
|
* @param {PDFWorkerParameters} params - The worker initialization parameters.
|
|
1528
1553
|
* @returns {PDFWorker}
|
|
@@ -1533,7 +1558,7 @@ export class PDFWorker {
|
|
|
1533
1558
|
* @type {string}
|
|
1534
1559
|
*/
|
|
1535
1560
|
static get workerSrc(): string;
|
|
1536
|
-
static get
|
|
1561
|
+
static get #mainThreadWorkerMessageHandler(): any;
|
|
1537
1562
|
static get _setupFakeWorkerGlobal(): any;
|
|
1538
1563
|
constructor({ name, port, verbosity, }?: {
|
|
1539
1564
|
name?: null | undefined;
|
|
@@ -1608,11 +1633,13 @@ export class RenderTask {
|
|
|
1608
1633
|
}
|
|
1609
1634
|
/** @type {string} */
|
|
1610
1635
|
export const version: string;
|
|
1611
|
-
import { PageViewport } from "./
|
|
1636
|
+
import { PageViewport } from "./page_viewport.js";
|
|
1612
1637
|
import { OptionalContentConfig } from "./optional_content_config.js";
|
|
1613
1638
|
import { PrintAnnotationStorage } from "./annotation_storage.js";
|
|
1614
1639
|
import { PagesMapper } from "./pages_mapper.js";
|
|
1615
1640
|
import { AnnotationStorage } from "./annotation_storage.js";
|
|
1641
|
+
import type { CatalogAttachment } from "../core/catalog.js";
|
|
1642
|
+
import type { CatalogAttachmentContent } from "../core/catalog.js";
|
|
1616
1643
|
import { Metadata } from "./metadata.js";
|
|
1617
1644
|
import { StatTimer } from "./display_utils.js";
|
|
1618
1645
|
import { PDFObjects } from "./pdf_objects.js";
|
|
@@ -17,9 +17,13 @@ export class CanvasGraphics {
|
|
|
17
17
|
baseTransformStack: any[];
|
|
18
18
|
groupLevel: number;
|
|
19
19
|
smaskStack: any[];
|
|
20
|
-
smaskCounter: number;
|
|
21
20
|
tempSMask: any;
|
|
22
21
|
smaskGroupCanvases: any[];
|
|
22
|
+
smaskPreparedEntry: any;
|
|
23
|
+
smaskPreparedFor: any;
|
|
24
|
+
smaskPreparedOffsetX: number;
|
|
25
|
+
smaskPreparedOffsetY: number;
|
|
26
|
+
smaskPreparedOOBAlpha: any;
|
|
23
27
|
suspendedCtx: any;
|
|
24
28
|
contentVisible: boolean;
|
|
25
29
|
markedContentStack: never[];
|
|
@@ -73,22 +77,63 @@ export class CanvasGraphics {
|
|
|
73
77
|
setFlatness(opIdx: any, flatness: any): void;
|
|
74
78
|
setGState(opIdx: any, states: any): void;
|
|
75
79
|
get inSMaskMode(): boolean;
|
|
76
|
-
|
|
80
|
+
_clearPreparedSMask(): void;
|
|
81
|
+
_ensurePreparedSMask(smask: any): void;
|
|
82
|
+
checkSMaskState(opIdx: any): void;
|
|
83
|
+
_prepareSMaskCanvas(smask: any): void;
|
|
77
84
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* the
|
|
85
|
+
* Bake the mask plus optional backdrop into a (w x h) canvas with the
|
|
86
|
+
* mask drawn at (drawX, drawY), then optionally pipe through the SVG
|
|
87
|
+
* filter described by `filterSpec`. Returns the prepared canvas-
|
|
88
|
+
* factory entry.
|
|
89
|
+
*
|
|
90
|
+
* The backdrop fill uses destination-atop so transparent / partial-
|
|
91
|
+
* alpha pixels inside the mask see the backdrop *before* filtering
|
|
92
|
+
* (per PDF spec). Filtering the raw mask would yield filter(0)
|
|
93
|
+
* instead of filter(backdrop) -- wrong for "keep" Luminosity and for
|
|
94
|
+
* Alpha masks whose transferMap[255] differs from transferMap[0].
|
|
95
|
+
*
|
|
96
|
+
* In the no-backdrop layer-size case the OOB region of srcEntry
|
|
97
|
+
* stays transparent and the filter outputs filter(transparent) =
|
|
98
|
+
* transferMap[0], matching the spec's transparent extension of the
|
|
99
|
+
* mask group. No-backdrop mask-size prebakes have no OOB region;
|
|
100
|
+
* destination-in handles OOB at compose time.
|
|
101
|
+
*
|
|
102
|
+
* Some browsers (e.g. older Safari) silently ignore SVG `url(#id)`
|
|
103
|
+
* filters on a 2D canvas: the assignment is accepted but
|
|
104
|
+
* `ctx.filter` reads back as "none" and `drawImage` produces an
|
|
105
|
+
* unfiltered copy. We detect that and fall back to a pixel-buffer
|
|
106
|
+
* loop that reproduces the SVG filter exactly (matrix luminance and
|
|
107
|
+
* `feFuncA` transferMap, both with sRGB color-interpolation, i.e.
|
|
108
|
+
* straight on gamma-encoded byte values).
|
|
109
|
+
*/
|
|
110
|
+
_bakeSMaskCanvas(maskCanvas: any, drawX: any, drawY: any, w: any, h: any, backdrop: any, filterSpec: any): any;
|
|
111
|
+
/**
|
|
112
|
+
* Replaces the current drawing canvas with a temporary scratch canvas and
|
|
113
|
+
* suspends the main context. Drawing operations on the scratch canvas are
|
|
114
|
+
* composited back via `compose()`. The scratch canvas mirrors many operations
|
|
115
|
+
* onto the suspended canvas to keep their graphics-state stacks in sync, so
|
|
116
|
+
* that clipping paths and transformations remain correct when soft mask mode
|
|
117
|
+
* ends.
|
|
85
118
|
*/
|
|
86
119
|
beginSMaskMode(opIdx: any): void;
|
|
87
120
|
smaskScratchCanvas: any;
|
|
88
121
|
endSMaskMode(): void;
|
|
89
122
|
compose(dirtyBox: any): void;
|
|
90
123
|
composeSMask(ctx: any, smask: any, layerCtx: any, layerBox: any): void;
|
|
91
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Fade the dirty box's OOB region by a constant alpha. Called from
|
|
126
|
+
* composeSMask when smaskPreparedOOBAlpha is in (0, 255).
|
|
127
|
+
*
|
|
128
|
+
* destination-in clears every destination pixel outside the source's
|
|
129
|
+
* footprint, so four fillRects (one per strip) would each clear the
|
|
130
|
+
* others. Instead one fillRect covers the dirty box, restricted by
|
|
131
|
+
* an even-odd clip enclosing exactly (dirty_box XOR mask_region);
|
|
132
|
+
* within the clip the source covers everything so no "outside
|
|
133
|
+
* source" pixels exist.
|
|
134
|
+
*/
|
|
135
|
+
_applySMaskOOBAlpha(layerCtx: any, layerOffsetX: any, layerOffsetY: any, layerWidth: any, layerHeight: any, maskX0: any, maskY0: any, maskX1: any, maskY1: any, alpha: any): void;
|
|
136
|
+
genericComposeSMask(smask: any, layerCtx: any, width: any, height: any, layerOffsetX: any, layerOffsetY: any): void;
|
|
92
137
|
save(opIdx: any): void;
|
|
93
138
|
restore(opIdx: any): void;
|
|
94
139
|
transform(opIdx: any, a: any, b: any, c: any, d: any, e: any, f: any): void;
|
|
@@ -122,7 +167,7 @@ export class CanvasGraphics {
|
|
|
122
167
|
nextLine(opIdx: any): void;
|
|
123
168
|
paintChar(opIdx: any, character: any, x: any, y: any, patternFillTransform: any, patternStrokeTransform: any): void;
|
|
124
169
|
get isFontSubpixelAAEnabled(): any;
|
|
125
|
-
showText(opIdx: any, glyphs: any):
|
|
170
|
+
showText(opIdx: any, glyphs: any): void;
|
|
126
171
|
showType3Text(opIdx: any, glyphs: any): void;
|
|
127
172
|
setCharWidth(opIdx: any, xWidth: any, yWidth: any): void;
|
|
128
173
|
setCharWidthAndBounds(opIdx: any, xWidth: any, yWidth: any, llx: any, lly: any, urx: any, ury: any): void;
|
|
@@ -141,7 +186,7 @@ export class CanvasGraphics {
|
|
|
141
186
|
paintFormXObjectEnd(opIdx: any): void;
|
|
142
187
|
beginGroup(opIdx: any, group: any): void;
|
|
143
188
|
endGroup(opIdx: any, group: any): void;
|
|
144
|
-
beginAnnotation(opIdx: any, id: any, rect: any, transform: any, matrix: any, hasOwnCanvas: any): void;
|
|
189
|
+
beginAnnotation(opIdx: any, id: any, rect: any, transform: any, matrix: any, hasOwnCanvas: any, canvasName: any): void;
|
|
145
190
|
annotationCanvas: any;
|
|
146
191
|
endAnnotation(opIdx: any): void;
|
|
147
192
|
paintImageMaskXObject(opIdx: any, img: any): void;
|
|
@@ -191,6 +236,7 @@ declare class CanvasExtraState {
|
|
|
191
236
|
textRise: number;
|
|
192
237
|
fillColor: string;
|
|
193
238
|
strokeColor: string;
|
|
239
|
+
tilingPatternDims: null;
|
|
194
240
|
patternFill: boolean;
|
|
195
241
|
patternStroke: boolean;
|
|
196
242
|
fillAlpha: number;
|
|
@@ -123,10 +123,10 @@ export class CanvasDependencyTracker {
|
|
|
123
123
|
* the current canvas transform.
|
|
124
124
|
*/
|
|
125
125
|
export class CanvasImagesTracker {
|
|
126
|
-
static
|
|
126
|
+
static #CoordsArray: any;
|
|
127
127
|
constructor(canvas: any);
|
|
128
128
|
record(ctx: any, width: any, height: any, clipBox: any): void;
|
|
129
|
-
take():
|
|
129
|
+
take(): any;
|
|
130
130
|
#private;
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
@@ -1,64 +1,3 @@
|
|
|
1
|
-
export type PageViewportParameters = {
|
|
2
|
-
/**
|
|
3
|
-
* - The xMin, yMin, xMax and
|
|
4
|
-
* yMax coordinates.
|
|
5
|
-
*/
|
|
6
|
-
viewBox: Array<number>;
|
|
7
|
-
/**
|
|
8
|
-
* - The size of units.
|
|
9
|
-
*/
|
|
10
|
-
userUnit: number;
|
|
11
|
-
/**
|
|
12
|
-
* - The scale of the viewport.
|
|
13
|
-
*/
|
|
14
|
-
scale: number;
|
|
15
|
-
/**
|
|
16
|
-
* - The rotation, in degrees, of the viewport.
|
|
17
|
-
*/
|
|
18
|
-
rotation: number;
|
|
19
|
-
/**
|
|
20
|
-
* - The horizontal, i.e. x-axis, offset. The
|
|
21
|
-
* default value is `0`.
|
|
22
|
-
*/
|
|
23
|
-
offsetX?: number | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* - The vertical, i.e. y-axis, offset. The
|
|
26
|
-
* default value is `0`.
|
|
27
|
-
*/
|
|
28
|
-
offsetY?: number | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* - If true, the y-axis will not be flipped.
|
|
31
|
-
* The default value is `false`.
|
|
32
|
-
*/
|
|
33
|
-
dontFlip?: boolean | undefined;
|
|
34
|
-
};
|
|
35
|
-
export type PageViewportCloneParameters = {
|
|
36
|
-
/**
|
|
37
|
-
* - The scale, overriding the one in the cloned
|
|
38
|
-
* viewport. The default value is `this.scale`.
|
|
39
|
-
*/
|
|
40
|
-
scale?: number | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* - The rotation, in degrees, overriding the one
|
|
43
|
-
* in the cloned viewport. The default value is `this.rotation`.
|
|
44
|
-
*/
|
|
45
|
-
rotation?: number | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* - The horizontal, i.e. x-axis, offset.
|
|
48
|
-
* The default value is `this.offsetX`.
|
|
49
|
-
*/
|
|
50
|
-
offsetX?: number | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* - The vertical, i.e. y-axis, offset.
|
|
53
|
-
* The default value is `this.offsetY`.
|
|
54
|
-
*/
|
|
55
|
-
offsetY?: number | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* - If true, the x-axis will not be flipped.
|
|
58
|
-
* The default value is `false`.
|
|
59
|
-
*/
|
|
60
|
-
dontFlip?: boolean | undefined;
|
|
61
|
-
};
|
|
62
1
|
export function applyOpacity(color: any, opacity: any): any;
|
|
63
2
|
export class ColorScheme {
|
|
64
3
|
static get isDarkMode(): any;
|
|
@@ -95,14 +34,8 @@ export function getFilenameFromUrl(url: string): string;
|
|
|
95
34
|
* @returns {string} Guessed PDF filename.
|
|
96
35
|
*/
|
|
97
36
|
export function getPdfFilenameFromUrl(url: string, defaultFilename?: string): string;
|
|
98
|
-
export function getRGB(color: any): any;
|
|
99
|
-
|
|
100
|
-
* NOTE: This is (mostly) intended to support printing of XFA forms.
|
|
101
|
-
*/
|
|
102
|
-
export function getXfaPageViewport(xfaPage: any, { scale, rotation }: {
|
|
103
|
-
scale?: number | undefined;
|
|
104
|
-
rotation?: number | undefined;
|
|
105
|
-
}): PageViewport;
|
|
37
|
+
export function getRGB(color: any): any[];
|
|
38
|
+
export function getRGBA(color: any): any[] | null;
|
|
106
39
|
export function isDataScheme(url: any): boolean;
|
|
107
40
|
export function isPdfFile(filename: any): boolean;
|
|
108
41
|
export function isValidFetchUrl(url: any, baseUrl: any): boolean;
|
|
@@ -140,93 +73,8 @@ export class OutputScale {
|
|
|
140
73
|
*/
|
|
141
74
|
limitCanvas(width: any, height: any, maxPixels: any, maxDim: any, capAreaFactor?: number): boolean;
|
|
142
75
|
}
|
|
143
|
-
/**
|
|
144
|
-
* @typedef {Object} PageViewportParameters
|
|
145
|
-
* @property {Array<number>} viewBox - The xMin, yMin, xMax and
|
|
146
|
-
* yMax coordinates.
|
|
147
|
-
* @property {number} userUnit - The size of units.
|
|
148
|
-
* @property {number} scale - The scale of the viewport.
|
|
149
|
-
* @property {number} rotation - The rotation, in degrees, of the viewport.
|
|
150
|
-
* @property {number} [offsetX] - The horizontal, i.e. x-axis, offset. The
|
|
151
|
-
* default value is `0`.
|
|
152
|
-
* @property {number} [offsetY] - The vertical, i.e. y-axis, offset. The
|
|
153
|
-
* default value is `0`.
|
|
154
|
-
* @property {boolean} [dontFlip] - If true, the y-axis will not be flipped.
|
|
155
|
-
* The default value is `false`.
|
|
156
|
-
*/
|
|
157
|
-
/**
|
|
158
|
-
* @typedef {Object} PageViewportCloneParameters
|
|
159
|
-
* @property {number} [scale] - The scale, overriding the one in the cloned
|
|
160
|
-
* viewport. The default value is `this.scale`.
|
|
161
|
-
* @property {number} [rotation] - The rotation, in degrees, overriding the one
|
|
162
|
-
* in the cloned viewport. The default value is `this.rotation`.
|
|
163
|
-
* @property {number} [offsetX] - The horizontal, i.e. x-axis, offset.
|
|
164
|
-
* The default value is `this.offsetX`.
|
|
165
|
-
* @property {number} [offsetY] - The vertical, i.e. y-axis, offset.
|
|
166
|
-
* The default value is `this.offsetY`.
|
|
167
|
-
* @property {boolean} [dontFlip] - If true, the x-axis will not be flipped.
|
|
168
|
-
* The default value is `false`.
|
|
169
|
-
*/
|
|
170
|
-
/**
|
|
171
|
-
* PDF page viewport created based on scale, rotation and offset.
|
|
172
|
-
*/
|
|
173
|
-
export class PageViewport {
|
|
174
|
-
/**
|
|
175
|
-
* @param {PageViewportParameters}
|
|
176
|
-
*/
|
|
177
|
-
constructor({ viewBox, userUnit, scale, rotation, offsetX, offsetY, dontFlip, }: PageViewportParameters);
|
|
178
|
-
viewBox: number[];
|
|
179
|
-
userUnit: number;
|
|
180
|
-
scale: number;
|
|
181
|
-
rotation: number;
|
|
182
|
-
offsetX: number;
|
|
183
|
-
offsetY: number;
|
|
184
|
-
transform: number[];
|
|
185
|
-
width: number;
|
|
186
|
-
height: number;
|
|
187
|
-
/**
|
|
188
|
-
* The original, un-scaled, viewport dimensions.
|
|
189
|
-
* @type {Object}
|
|
190
|
-
*/
|
|
191
|
-
get rawDims(): Object;
|
|
192
|
-
/**
|
|
193
|
-
* Clones viewport, with optional additional properties.
|
|
194
|
-
* @param {PageViewportCloneParameters} [params]
|
|
195
|
-
* @returns {PageViewport} Cloned viewport.
|
|
196
|
-
*/
|
|
197
|
-
clone({ scale, rotation, offsetX, offsetY, dontFlip, }?: PageViewportCloneParameters): PageViewport;
|
|
198
|
-
/**
|
|
199
|
-
* Converts PDF point to the viewport coordinates. For examples, useful for
|
|
200
|
-
* converting PDF location into canvas pixel coordinates.
|
|
201
|
-
* @param {number} x - The x-coordinate.
|
|
202
|
-
* @param {number} y - The y-coordinate.
|
|
203
|
-
* @returns {Array} Array containing `x`- and `y`-coordinates of the
|
|
204
|
-
* point in the viewport coordinate space.
|
|
205
|
-
* @see {@link convertToPdfPoint}
|
|
206
|
-
* @see {@link convertToViewportRectangle}
|
|
207
|
-
*/
|
|
208
|
-
convertToViewportPoint(x: number, y: number): any[];
|
|
209
|
-
/**
|
|
210
|
-
* Converts PDF rectangle to the viewport coordinates.
|
|
211
|
-
* @param {Array} rect - The xMin, yMin, xMax and yMax coordinates.
|
|
212
|
-
* @returns {Array} Array containing corresponding coordinates of the
|
|
213
|
-
* rectangle in the viewport coordinate space.
|
|
214
|
-
* @see {@link convertToViewportPoint}
|
|
215
|
-
*/
|
|
216
|
-
convertToViewportRectangle(rect: any[]): any[];
|
|
217
|
-
/**
|
|
218
|
-
* Converts viewport coordinates to the PDF location. For examples, useful
|
|
219
|
-
* for converting canvas pixel location into PDF one.
|
|
220
|
-
* @param {number} x - The x-coordinate.
|
|
221
|
-
* @param {number} y - The y-coordinate.
|
|
222
|
-
* @returns {Array} Array containing `x`- and `y`-coordinates of the
|
|
223
|
-
* point in the PDF coordinate space.
|
|
224
|
-
* @see {@link convertToViewportPoint}
|
|
225
|
-
*/
|
|
226
|
-
convertToPdfPoint(x: number, y: number): any[];
|
|
227
|
-
}
|
|
228
76
|
export class PDFDateString {
|
|
229
|
-
static
|
|
77
|
+
static #regex: any;
|
|
230
78
|
/**
|
|
231
79
|
* Convert a PDF date string to a JavaScript `Date` object.
|
|
232
80
|
*
|
|
@@ -277,5 +125,5 @@ export class StatTimer {
|
|
|
277
125
|
}
|
|
278
126
|
export function stopEvent(e: any): void;
|
|
279
127
|
export const SupportedImageMimeTypes: string[];
|
|
280
|
-
|
|
128
|
+
import { PageViewport } from "./page_viewport.js";
|
|
281
129
|
export {};
|