unpdf 1.6.2 → 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.
Files changed (122) hide show
  1. package/README.md +61 -25
  2. package/dist/index.cjs +386 -353
  3. package/dist/index.d.cts +101 -91
  4. package/dist/index.d.mts +101 -91
  5. package/dist/index.mjs +385 -351
  6. package/dist/pdfjs.d.mts +1 -1
  7. package/dist/pdfjs.d.ts +1 -1
  8. package/dist/pdfjs.mjs +52 -59
  9. package/dist/types/external/brotli/decode.d.ts +5 -0
  10. package/dist/types/external/jbig2/jbig2.d.ts +2 -0
  11. package/dist/types/external/openjpeg/openjpeg.d.ts +2 -0
  12. package/dist/types/external/qcms/qcms.d.ts +92 -0
  13. package/dist/types/external/qcms/qcms_utils.d.ts +14 -0
  14. package/dist/types/src/core/ascii_85_stream.d.ts +7 -0
  15. package/dist/types/src/core/ascii_hex_stream.d.ts +7 -0
  16. package/dist/types/src/core/base_stream.d.ts +45 -0
  17. package/dist/types/src/core/brotli_stream.d.ts +9 -0
  18. package/dist/types/src/core/calculate_md5.d.ts +1 -0
  19. package/dist/types/src/core/calculate_sha256.d.ts +1 -0
  20. package/dist/types/src/core/calculate_sha_other.d.ts +2 -0
  21. package/dist/types/src/core/catalog.d.ts +169 -0
  22. package/dist/types/src/core/ccitt_stream.d.ts +18 -0
  23. package/dist/types/src/core/cleanup_helper.d.ts +1 -0
  24. package/dist/types/src/core/colorspace.d.ts +177 -0
  25. package/dist/types/src/core/colorspace_utils.d.ts +21 -0
  26. package/dist/types/src/core/core_utils.d.ts +132 -0
  27. package/dist/types/src/core/crypto.d.ts +136 -0
  28. package/dist/types/src/core/decode_stream.d.ts +32 -0
  29. package/dist/types/src/core/decrypt_stream.d.ts +9 -0
  30. package/dist/types/src/core/file_spec.d.ts +72 -0
  31. package/dist/types/src/core/flate_stream.d.ts +14 -0
  32. package/dist/types/src/core/icc_colorspace.d.ts +22 -0
  33. package/dist/types/src/core/image_utils.d.ts +52 -0
  34. package/dist/types/src/core/jbig2_ccittFax.d.ts +13 -0
  35. package/dist/types/src/core/jbig2_stream.d.ts +17 -0
  36. package/dist/types/src/core/jpeg_stream.d.ts +24 -0
  37. package/dist/types/src/core/jpg.d.ts +62 -0
  38. package/dist/types/src/core/jpx.d.ts +24 -0
  39. package/dist/types/src/core/jpx_stream.d.ts +15 -0
  40. package/dist/types/src/core/lzw_stream.d.ts +19 -0
  41. package/dist/types/src/core/metadata_parser.d.ts +13 -0
  42. package/dist/types/src/core/name_number_tree.d.ts +21 -0
  43. package/dist/types/src/core/parser.d.ts +121 -0
  44. package/dist/types/src/core/pattern.d.ts +63 -0
  45. package/dist/types/src/core/predictor_stream.d.ts +14 -0
  46. package/dist/types/src/core/primitives.d.ts +81 -0
  47. package/dist/types/src/core/run_length_stream.d.ts +6 -0
  48. package/dist/types/src/core/stream.d.ts +20 -0
  49. package/dist/types/src/core/string_utils.d.ts +5 -0
  50. package/dist/types/src/core/struct_tree.d.ts +93 -0
  51. package/dist/types/src/core/unicode.d.ts +5 -0
  52. package/dist/types/src/core/wasm_image.d.ts +21 -0
  53. package/dist/types/src/core/xml_parser.d.ts +79 -0
  54. package/dist/types/src/core/xref.d.ts +52 -0
  55. package/dist/types/src/display/annotation_layer.d.ts +11 -9
  56. package/dist/types/src/display/api.d.ts +92 -65
  57. package/dist/types/src/display/binary_data_factory.d.ts +0 -4
  58. package/dist/types/src/display/canvas.d.ts +58 -12
  59. package/dist/types/src/display/canvas_dependency_tracker.d.ts +2 -2
  60. package/dist/types/src/display/display_utils.d.ts +4 -156
  61. package/dist/types/src/display/draw_layer.d.ts +127 -2
  62. package/dist/types/src/display/editor/alt_text.d.ts +1 -1
  63. package/dist/types/src/display/editor/annotation_editor_layer.d.ts +3 -3
  64. package/dist/types/src/display/editor/color_picker.d.ts +3 -2
  65. package/dist/types/src/display/editor/draw.d.ts +10 -3
  66. package/dist/types/src/display/editor/drawers/freedraw.d.ts +3 -3
  67. package/dist/types/src/display/editor/drawers/highlight.d.ts +0 -1
  68. package/dist/types/src/display/editor/drawers/outline.d.ts +0 -1
  69. package/dist/types/src/display/editor/drawers/signaturedraw.d.ts +13 -13
  70. package/dist/types/src/display/editor/editor.d.ts +2 -1
  71. package/dist/types/src/display/editor/freetext.d.ts +2 -2
  72. package/dist/types/src/display/editor/highlight.d.ts +3 -3
  73. package/dist/types/src/display/editor/ink.d.ts +2 -0
  74. package/dist/types/src/display/editor/toolbar.d.ts +2 -2
  75. package/dist/types/src/display/editor/tools.d.ts +31 -14
  76. package/dist/types/src/display/filter_factory.d.ts +26 -0
  77. package/dist/types/src/display/node_utils.d.ts +2 -2
  78. package/dist/types/src/display/obj_bin_transform_display.d.ts +2 -6
  79. package/dist/types/src/display/optional_content_config.d.ts +13 -3
  80. package/dist/types/src/display/page_viewport.d.ts +137 -0
  81. package/dist/types/src/display/pattern_helper.d.ts +11 -4
  82. package/dist/types/src/display/text_layer.d.ts +13 -13
  83. package/dist/types/src/display/text_layer_images.d.ts +1 -1
  84. package/dist/types/src/display/webgpu.d.ts +11 -0
  85. package/dist/types/src/display/worker_options.d.ts +2 -2
  86. package/dist/types/src/display/xfa_layer.d.ts +10 -3
  87. package/dist/types/src/display/xfa_text.d.ts +2 -2
  88. package/dist/types/src/pdf.d.ts +10 -9
  89. package/dist/types/src/shared/image_utils.d.ts +11 -0
  90. package/dist/types/src/shared/internal_evt.d.ts +7 -0
  91. package/dist/types/src/shared/math_clamp.d.ts +1 -0
  92. package/dist/types/src/shared/util.d.ts +24 -13
  93. package/dist/types/web/annotation_editor_layer_builder.d.ts +5 -5
  94. package/dist/types/web/annotation_layer_builder.d.ts +14 -11
  95. package/dist/types/web/app_options.d.ts +1 -1
  96. package/dist/types/web/autolinker.d.ts +3 -3
  97. package/dist/types/web/base_pdf_page_view.d.ts +1 -0
  98. package/dist/types/web/comment_manager.d.ts +1 -1
  99. package/dist/types/web/draw_layer_builder.d.ts +44 -0
  100. package/dist/types/web/event_utils.d.ts +0 -8
  101. package/dist/types/web/generic_scripting.d.ts +1 -1
  102. package/dist/types/web/genericl10n.d.ts +5 -5
  103. package/dist/types/web/internal_evt.d.ts +7 -0
  104. package/dist/types/web/l10n.d.ts +2 -2
  105. package/dist/types/web/pdf_find_controller.d.ts +16 -5
  106. package/dist/types/web/pdf_history.d.ts +1 -1
  107. package/dist/types/web/pdf_link_service.d.ts +10 -2
  108. package/dist/types/web/pdf_page_view.d.ts +19 -12
  109. package/dist/types/web/pdf_rendering_queue.d.ts +3 -3
  110. package/dist/types/web/pdf_scripting_manager.d.ts +1 -1
  111. package/dist/types/web/pdf_thumbnail_view.d.ts +9 -9
  112. package/dist/types/web/pdf_thumbnail_viewer.d.ts +38 -19
  113. package/dist/types/web/pdf_viewer.d.ts +28 -14
  114. package/dist/types/web/renderable_view.d.ts +2 -2
  115. package/dist/types/web/struct_tree_layer_builder.d.ts +1 -1
  116. package/dist/types/web/text_accessibility.d.ts +1 -1
  117. package/dist/types/web/text_highlighter.d.ts +6 -6
  118. package/dist/types/web/text_layer_builder.d.ts +10 -10
  119. package/dist/types/web/xfa_layer_builder.d.ts +8 -8
  120. package/package.json +25 -24
  121. package/dist/index.d.ts +0 -182
  122. package/dist/types/src/display/webgpu_mesh.d.ts +0 -3
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @type {function(!Int8Array, ?Options=):!Int8Array}
3
+ */
4
+ export let BrotliDecode: (arg0: Int8Array, arg1: (Options | null) | undefined) => Int8Array;
5
+ export type Options = Object;
@@ -0,0 +1,2 @@
1
+ export default JBig2;
2
+ declare function JBig2(moduleArg?: {}): Promise<{}>;
@@ -0,0 +1,2 @@
1
+ export default OpenJPEG;
2
+ declare function OpenJPEG(moduleArg?: {}): Promise<{}>;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * # Safety
3
+ *
4
+ * This function is called directly from JavaScript.
5
+ * @param {number} transformer
6
+ * @param {Uint8Array} src
7
+ */
8
+ export function qcms_convert_array(transformer: number, src: Uint8Array): void;
9
+ /**
10
+ * # Safety
11
+ *
12
+ * This function is called directly from JavaScript.
13
+ * @param {number} transformer
14
+ * @param {number} src1
15
+ * @param {number} src2
16
+ * @param {number} src3
17
+ * @param {number} src4
18
+ * @param {boolean} css
19
+ */
20
+ export function qcms_convert_four(transformer: number, src1: number, src2: number, src3: number, src4: number, css: boolean): void;
21
+ /**
22
+ * # Safety
23
+ *
24
+ * This function is called directly from JavaScript.
25
+ * @param {number} transformer
26
+ * @param {number} src
27
+ * @param {boolean} css
28
+ */
29
+ export function qcms_convert_one(transformer: number, src: number, css: boolean): void;
30
+ /**
31
+ * # Safety
32
+ *
33
+ * This function is called directly from JavaScript.
34
+ * @param {number} transformer
35
+ * @param {number} src1
36
+ * @param {number} src2
37
+ * @param {number} src3
38
+ * @param {boolean} css
39
+ */
40
+ export function qcms_convert_three(transformer: number, src1: number, src2: number, src3: number, css: boolean): void;
41
+ /**
42
+ * # Safety
43
+ *
44
+ * This function is called directly from JavaScript.
45
+ * @param {number} transformer
46
+ */
47
+ export function qcms_drop_transformer(transformer: number): void;
48
+ /**
49
+ * # Safety
50
+ *
51
+ * This function is called directly from JavaScript.
52
+ * @param {Uint8Array} mem
53
+ * @param {DataType} in_type
54
+ * @param {Intent} intent
55
+ * @returns {number}
56
+ */
57
+ export function qcms_transformer_from_memory(mem: Uint8Array, in_type: DataType, intent: Intent): number;
58
+ export type DataType = 0 | 1 | 2 | 3 | 4 | 5;
59
+ /**
60
+ * @enum {0 | 1 | 2 | 3 | 4 | 5}
61
+ */
62
+ export const DataType: Readonly<{
63
+ RGB8: 0;
64
+ "0": "RGB8";
65
+ RGBA8: 1;
66
+ "1": "RGBA8";
67
+ BGRA8: 2;
68
+ "2": "BGRA8";
69
+ Gray8: 3;
70
+ "3": "Gray8";
71
+ GrayA8: 4;
72
+ "4": "GrayA8";
73
+ CMYK: 5;
74
+ "5": "CMYK";
75
+ }>;
76
+ export type Intent = 0 | 1 | 2 | 3;
77
+ /**
78
+ * @enum {0 | 1 | 2 | 3}
79
+ */
80
+ export const Intent: Readonly<{
81
+ Perceptual: 0;
82
+ "0": "Perceptual";
83
+ RelativeColorimetric: 1;
84
+ "1": "RelativeColorimetric";
85
+ Saturation: 2;
86
+ "2": "Saturation";
87
+ AbsoluteColorimetric: 3;
88
+ "3": "AbsoluteColorimetric";
89
+ }>;
90
+ export function initSync(module: any): any;
91
+ declare function __wbg_init(module_or_path: any): Promise<any>;
92
+ export { __wbg_init as default };
@@ -0,0 +1,14 @@
1
+ export function copy_result(ptr: any, len: any): void;
2
+ export function copy_rgb(ptr: any): void;
3
+ export function make_cssRGB(ptr: any): void;
4
+ export class QCMS {
5
+ static #memoryArray: null;
6
+ static _memory: null;
7
+ static _mustAddAlpha: boolean;
8
+ static _destBuffer: null;
9
+ static _destOffset: number;
10
+ static _destLength: number;
11
+ static _cssColor: string;
12
+ static _makeHexColor: null;
13
+ static get _memoryArray(): Uint8Array<any>;
14
+ }
@@ -0,0 +1,7 @@
1
+ export class Ascii85Stream extends DecodeStream {
2
+ constructor(str: any, maybeLength: any);
3
+ stream: any;
4
+ dict: any;
5
+ #private;
6
+ }
7
+ import { DecodeStream } from "./decode_stream.js";
@@ -0,0 +1,7 @@
1
+ export class AsciiHexStream extends DecodeStream {
2
+ constructor(str: any, maybeLength: any);
3
+ stream: any;
4
+ dict: any;
5
+ firstDigit: number;
6
+ }
7
+ import { DecodeStream } from "./decode_stream.js";
@@ -0,0 +1,45 @@
1
+ export class BaseStream {
2
+ /**
3
+ * @returns {number}
4
+ */
5
+ get length(): number;
6
+ /**
7
+ * @returns {boolean}
8
+ */
9
+ get isEmpty(): boolean;
10
+ get isDataLoaded(): any;
11
+ getByte(): void;
12
+ /**
13
+ * @param {number | undefined} [length]
14
+ * @returns {Uint8Array}
15
+ */
16
+ getBytes(length?: number | undefined): Uint8Array;
17
+ /**
18
+ * NOTE: This method can only be used to get image-data that is guaranteed
19
+ * to be fully loaded, since otherwise intermittent errors may occur;
20
+ * note the `ObjectLoader` class.
21
+ */
22
+ getImageData(length: any, decoderOptions: any): Promise<Uint8Array<ArrayBufferLike>>;
23
+ asyncGetBytes(): Promise<void>;
24
+ get isAsync(): boolean;
25
+ get isAsyncDecoder(): boolean;
26
+ get isImageStream(): boolean;
27
+ get canAsyncDecodeImageFromBuffer(): boolean;
28
+ getTransferableImage(): Promise<null>;
29
+ peekByte(): void;
30
+ peekBytes(length: any): Uint8Array<ArrayBufferLike>;
31
+ getUint16(): any;
32
+ getInt32(): any;
33
+ getByteRange(begin: any, end: any): void;
34
+ getString(length: any): string;
35
+ skip(n: any): void;
36
+ reset(): void;
37
+ moveStart(): void;
38
+ makeSubStream(start: any, length: any, dict?: null): void;
39
+ clone(): void;
40
+ /**
41
+ * @returns {Array | null}
42
+ */
43
+ getBaseStreams(): any[] | null;
44
+ getOriginalStream(): any;
45
+ }
@@ -0,0 +1,9 @@
1
+ export class BrotliStream extends DecodeStream {
2
+ constructor(stream: any, maybeLength: any);
3
+ stream: any;
4
+ dict: any;
5
+ getImageData(length: any, _decoderOptions: any): Promise<Uint8Array<ArrayBuffer>>;
6
+ asyncGetBytes(): Promise<Uint8Array<ArrayBuffer> | null>;
7
+ #private;
8
+ }
9
+ import { DecodeStream } from "./decode_stream.js";
@@ -0,0 +1 @@
1
+ export function calculateMD5(data: any, offset: any, length: any): Uint8Array<ArrayBuffer>;
@@ -0,0 +1 @@
1
+ export function calculateSHA256(data: any, offset: any, length: any): Uint8Array<ArrayBuffer>;
@@ -0,0 +1,2 @@
1
+ export function calculateSHA384(data: any, offset: any, length: any): Uint8Array<ArrayBuffer>;
2
+ export function calculateSHA512(data: any, offset: any, length: any, mode384?: boolean): Uint8Array<ArrayBuffer>;
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Callback used to lazily fetch attachment content.
3
+ */
4
+ export type GetAttachmentContent = (id: string) => CatalogAttachmentContent;
5
+ /**
6
+ * Attachment value.
7
+ */
8
+ export type CatalogAttachmentContent = Uint8Array | null;
9
+ /**
10
+ * Attachment metadata.
11
+ */
12
+ export type CatalogAttachment = {
13
+ /**
14
+ * Value, when already available.
15
+ */
16
+ content?: CatalogAttachmentContent | undefined;
17
+ /**
18
+ * Description.
19
+ */
20
+ description: string;
21
+ /**
22
+ * Filename (just the basename) for display.
23
+ */
24
+ filename: string;
25
+ /**
26
+ * File path.
27
+ */
28
+ rawFilename: string;
29
+ };
30
+ export class Catalog {
31
+ /**
32
+ * @typedef {Object} ParseDestDictionaryParameters
33
+ * @property {Dict} destDict - The dictionary containing the destination.
34
+ * @property {Object} resultObj - The object where the parsed destination
35
+ * properties will be placed.
36
+ * @property {string} [docBaseUrl] - The document base URL that is used when
37
+ * attempting to recover valid absolute URLs from relative ones.
38
+ * @property {Record<string, CatalogAttachment> | null} [docAttachments] - The
39
+ * document attachments (may not exist in most PDF documents).
40
+ */
41
+ /**
42
+ * Derive a destination array from a Structure Element reference.
43
+ * Walks the SE dict to find its page (Pg) and optional bounding box (A.BBox),
44
+ * then returns an XYZ destination array that can be used for navigation.
45
+ * @param {XRef} xref
46
+ * @param {Ref} seRef
47
+ * @returns {Array|null}
48
+ */
49
+ static #getDestFromStructElement(xref: XRef, seRef: Ref): any[] | null;
50
+ /**
51
+ * Helper function used to parse the contents of destination dictionaries.
52
+ * @param {ParseDestDictionaryParameters} params
53
+ */
54
+ static parseDestDictionary({ destDict, resultObj, docBaseUrl, docAttachments, }: {
55
+ /**
56
+ * - The dictionary containing the destination.
57
+ */
58
+ destDict: Dict;
59
+ /**
60
+ * - The object where the parsed destination
61
+ * properties will be placed.
62
+ */
63
+ resultObj: Object;
64
+ /**
65
+ * - The document base URL that is used when
66
+ * attempting to recover valid absolute URLs from relative ones.
67
+ */
68
+ docBaseUrl?: string | undefined;
69
+ /**
70
+ * - The
71
+ * document attachments (may not exist in most PDF documents).
72
+ */
73
+ docAttachments?: Record<string, CatalogAttachment> | null | undefined;
74
+ }): void;
75
+ constructor(pdfManager: any, xref: any);
76
+ builtInCMapCache: Map<any, any>;
77
+ fontCache: RefSetCache;
78
+ globalColorSpaceCache: GlobalColorSpaceCache;
79
+ globalImageCache: GlobalImageCache;
80
+ nonBlendModesSet: RefSet;
81
+ pageDictCache: RefSetCache;
82
+ pageIndexCache: RefSetCache;
83
+ pageKidsCountCache: RefSetCache;
84
+ standardFontDataCache: Map<any, any>;
85
+ systemFontCache: Map<any, any>;
86
+ pdfManager: any;
87
+ xref: any;
88
+ cloneDict(): any;
89
+ /**
90
+ * Create an id for an attachment from a FileAttachment annotation.
91
+ *
92
+ * The id is registered here rather than parsed from a public string prefix in
93
+ * `attachmentContent`, since catalog attachment names can be arbitrary PDF
94
+ * strings and may otherwise collide with annotation-local ids.
95
+ *
96
+ * @param {Ref} ref
97
+ * File-spec or embedded-file stream reference.
98
+ * @returns {string}
99
+ * Attachment id.
100
+ */
101
+ getAttachmentIdForAnnotation(ref: Ref): string;
102
+ get version(): any;
103
+ get lang(): any;
104
+ /**
105
+ * @type {boolean} `true` for pure XFA documents,
106
+ * `false` for XFA Foreground documents.
107
+ */
108
+ get needsRendering(): boolean;
109
+ get collection(): any;
110
+ get acroForm(): any;
111
+ get acroFormRef(): any;
112
+ get metadata(): any;
113
+ get markInfo(): any;
114
+ get hasStructTree(): any;
115
+ get structTreeRoot(): any;
116
+ get toplevelPagesDict(): any;
117
+ get documentOutline(): any;
118
+ get documentOutlineForEditor(): any;
119
+ get permissions(): any;
120
+ get optionalContentConfig(): any;
121
+ setActualNumPages(num?: null): void;
122
+ get hasActualNumPages(): boolean;
123
+ get _pagesCount(): any;
124
+ get numPages(): any;
125
+ get destinations(): any;
126
+ getDestination(id: any): any;
127
+ get rawPageLabels(): Map<any, any> | null;
128
+ get pageLabels(): any;
129
+ get pageLayout(): any;
130
+ get pageMode(): any;
131
+ get viewerPreferences(): any;
132
+ get openAction(): any;
133
+ /**
134
+ * Get attachments.
135
+ *
136
+ * @returns {Map<string, CatalogAttachment> | null}
137
+ * Attachments.
138
+ */
139
+ get attachments(): Map<string, CatalogAttachment> | null;
140
+ /**
141
+ * Get content for an attachment.
142
+ *
143
+ * @param {string} id
144
+ * Unique attachment identifier (required).
145
+ * @returns {CatalogAttachmentContent}
146
+ * Content.
147
+ */
148
+ attachmentContent(id: string): CatalogAttachmentContent;
149
+ get rawEmbeddedFiles(): Map<any, any> | null;
150
+ get xfaImages(): any;
151
+ get jsActions(): any;
152
+ cleanup(manuallyTriggered?: boolean): Promise<void>;
153
+ getPageDict(pageIndex: any): Promise<(Dict | Ref)[] | (Dict | null)[]>;
154
+ /**
155
+ * Eagerly fetches the entire /Pages-tree; should ONLY be used as a fallback.
156
+ * @returns {Promise<Map>}
157
+ */
158
+ getAllPageDicts(recoveryMode?: boolean): Promise<Map<any, any>>;
159
+ getPageIndex(pageRef: any): Promise<any>;
160
+ get baseUrl(): any;
161
+ #private;
162
+ }
163
+ import { RefSetCache } from "./primitives.js";
164
+ import { GlobalColorSpaceCache } from "./image_utils.js";
165
+ import { GlobalImageCache } from "./image_utils.js";
166
+ import { RefSet } from "./primitives.js";
167
+ import { Ref } from "./primitives.js";
168
+ import { Dict } from "./primitives.js";
169
+ import type { XRef } from "./xref.js";
@@ -0,0 +1,18 @@
1
+ export class CCITTFaxStream extends DecodeStream {
2
+ constructor(str: any, maybeLength: any, params: any);
3
+ stream: any;
4
+ maybeLength: any;
5
+ dict: any;
6
+ params: {
7
+ K: any;
8
+ EndOfLine: boolean;
9
+ EncodedByteAlign: boolean;
10
+ Columns: any;
11
+ Rows: any;
12
+ EndOfBlock: boolean;
13
+ BlackIs1: boolean;
14
+ };
15
+ get bytes(): any;
16
+ decodeImage(bytes: any, length: any, _decoderOptions: any): Promise<Uint8Array<ArrayBuffer>>;
17
+ }
18
+ import { DecodeStream } from "./decode_stream.js";
@@ -0,0 +1 @@
1
+ export function clearGlobalCaches(): void;
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Alternate color space handles both Separation and DeviceN color spaces. A
3
+ * Separation color space is actually just a DeviceN with one color component.
4
+ * Both color spaces use a tinting function to convert colors to a base color
5
+ * space.
6
+ *
7
+ * The default color is `new Float32Array(new Array(numComps).fill(1))`.
8
+ */
9
+ export class AlternateCS extends ColorSpace {
10
+ constructor(numComps: any, base: any, tintFn: any);
11
+ base: any;
12
+ tintFn: any;
13
+ tmpBuf: Float32Array<any>;
14
+ getOutputLength(inputLength: any, alpha01: any): any;
15
+ }
16
+ /**
17
+ * CalGrayCS: Based on "PDF Reference, Sixth Ed", p.245
18
+ *
19
+ * The default color is `new Float32Array([0])`.
20
+ */
21
+ export class CalGrayCS extends ColorSpace {
22
+ constructor(whitePoint: any, blackPoint: any, gamma: any);
23
+ G: any;
24
+ XB: any;
25
+ YB: any;
26
+ ZB: any;
27
+ getOutputLength(inputLength: any, alpha01: any): number;
28
+ #private;
29
+ }
30
+ /**
31
+ * CalRGBCS: Based on "PDF Reference, Sixth Ed", p.247
32
+ *
33
+ * The default color is `new Float32Array([0, 0, 0])`.
34
+ */
35
+ export class CalRGBCS extends ColorSpace {
36
+ static #BRADFORD_SCALE_MATRIX: Float32Array<ArrayBuffer>;
37
+ static #BRADFORD_SCALE_INVERSE_MATRIX: Float32Array<ArrayBuffer>;
38
+ static #SRGB_D65_XYZ_TO_RGB_MATRIX: Float32Array<ArrayBuffer>;
39
+ static #FLAT_WHITEPOINT_MATRIX: Float32Array<ArrayBuffer>;
40
+ static #tempNormalizeMatrix: Float32Array<ArrayBuffer>;
41
+ static #tempConvertMatrix1: Float32Array<ArrayBuffer>;
42
+ static #tempConvertMatrix2: Float32Array<ArrayBuffer>;
43
+ static #DECODE_L_CONSTANT: number;
44
+ constructor(whitePoint: any, blackPoint: any, gamma: any, matrix: any);
45
+ whitePoint: any;
46
+ blackPoint: any;
47
+ GR: any;
48
+ GG: any;
49
+ GB: any;
50
+ getOutputLength(inputLength: any, alpha01: any): number;
51
+ #private;
52
+ }
53
+ export class ColorSpace {
54
+ static #rgbBuf: Uint8ClampedArray<ArrayBuffer>;
55
+ /**
56
+ * Checks if a decode map matches the default decode map for a color space.
57
+ * This handles the general decode maps where there are two values per
58
+ * component, e.g. [0, 1, 0, 1, 0, 1] for a RGB color.
59
+ * This does not handle Lab, Indexed, or Pattern decode maps since they are
60
+ * slightly different.
61
+ * @param {Array} decode - Decode map (usually from an image).
62
+ * @param {number} numComps - Number of components the color space has.
63
+ */
64
+ static isDefaultDecode(decode: any[], numComps: number): boolean;
65
+ constructor(name: any, numComps: any);
66
+ name: any;
67
+ numComps: any;
68
+ /**
69
+ * Converts the color value to the RGB color. The color components are
70
+ * located in the src array starting from the srcOffset. Returns the array
71
+ * of the rgb components, each value ranging from [0,255].
72
+ */
73
+ getRgb(src: any, srcOffset: any, output?: Uint8ClampedArray<ArrayBuffer>): Uint8ClampedArray<ArrayBuffer>;
74
+ getRgbHex(src: any, srcOffset: any): string;
75
+ /**
76
+ * Converts the color value to the RGB color, similar to the getRgb method.
77
+ * The result placed into the dest array starting from the destOffset.
78
+ */
79
+ getRgbItem(src: any, srcOffset: any, dest: any, destOffset: any): void;
80
+ /**
81
+ * Converts the specified number of the color values to the RGB colors.
82
+ * The colors are located in the src array starting from the srcOffset.
83
+ * The result is placed into the dest array starting from the destOffset.
84
+ * The src array items shall be in [0,2^bits) range, the dest array items
85
+ * will be in [0,255] range. alpha01 indicates how many alpha components
86
+ * there are in the dest array; it will be either 0 (RGB array) or 1 (RGBA
87
+ * array).
88
+ */
89
+ getRgbBuffer(src: any, srcOffset: any, count: any, dest: any, destOffset: any, bits: any, alpha01: any): void;
90
+ /**
91
+ * Determines the number of bytes required to store the result of the
92
+ * conversion done by the getRgbBuffer method. As in getRgbBuffer,
93
+ * |alpha01| is either 0 (RGB output) or 1 (RGBA output).
94
+ */
95
+ getOutputLength(inputLength: any, alpha01: any): void;
96
+ /**
97
+ * Returns true if source data will be equal the result/output data.
98
+ */
99
+ isPassthrough(bits: any): boolean;
100
+ /**
101
+ * Refer to the static `ColorSpace.isDefaultDecode` method below.
102
+ */
103
+ isDefaultDecode(decode: any, bpc: any): boolean;
104
+ /**
105
+ * Fills in the RGB colors in the destination buffer. alpha01 indicates
106
+ * how many alpha components there are in the dest array; it will be either
107
+ * 0 (RGB array) or 1 (RGBA array).
108
+ */
109
+ fillRgb(dest: any, originalWidth: any, originalHeight: any, width: any, height: any, actualHeight: any, bpc: any, comps: any, alpha01: any): void;
110
+ /**
111
+ * True if the colorspace has components in the default range of [0, 1].
112
+ * This should be true for all colorspaces except for lab color spaces
113
+ * which are [0,100], [-128, 127], [-128, 127].
114
+ */
115
+ get usesZeroToOneRange(): any;
116
+ }
117
+ /**
118
+ * The default color is `new Float32Array([0, 0, 0, 1])`.
119
+ */
120
+ export class DeviceCmykCS extends ColorSpace {
121
+ constructor();
122
+ getOutputLength(inputLength: any, alpha01: any): number;
123
+ #private;
124
+ }
125
+ /**
126
+ * The default color is `new Float32Array([0])`.
127
+ */
128
+ export class DeviceGrayCS extends ColorSpace {
129
+ constructor();
130
+ getOutputLength(inputLength: any, alpha01: any): number;
131
+ }
132
+ /**
133
+ * The default color is `new Float32Array([0, 0, 0, 1])`.
134
+ */
135
+ export class DeviceRgbaCS extends ColorSpace {
136
+ constructor();
137
+ getOutputLength(inputLength: any, _alpha01: any): number;
138
+ }
139
+ /**
140
+ * The default color is `new Float32Array([0, 0, 0])`.
141
+ */
142
+ export class DeviceRgbCS extends ColorSpace {
143
+ constructor();
144
+ getOutputLength(inputLength: any, alpha01: any): number;
145
+ }
146
+ /**
147
+ * The default color is `new Uint8Array([0])`.
148
+ */
149
+ export class IndexedCS extends ColorSpace {
150
+ constructor(base: any, highVal: any, lookup: any);
151
+ base: any;
152
+ highVal: any;
153
+ lookup: Uint8Array<ArrayBuffer>;
154
+ getOutputLength(inputLength: any, alpha01: any): any;
155
+ }
156
+ /**
157
+ * LabCS: Based on "PDF Reference, Sixth Ed", p.250
158
+ *
159
+ * The default color is `new Float32Array([0, 0, 0])`.
160
+ */
161
+ export class LabCS extends ColorSpace {
162
+ constructor(whitePoint: any, blackPoint: any, range: any);
163
+ XB: any;
164
+ YB: any;
165
+ ZB: any;
166
+ amin: any;
167
+ amax: any;
168
+ bmin: any;
169
+ bmax: any;
170
+ getOutputLength(inputLength: any, alpha01: any): number;
171
+ #private;
172
+ }
173
+ export class PatternCS extends ColorSpace {
174
+ constructor(baseCS: any);
175
+ base: any;
176
+ isDefaultDecode(decode: any, bpc: any): void;
177
+ }
@@ -0,0 +1,21 @@
1
+ export class ColorSpaceUtils {
2
+ static parse({ cs, xref, resources, pdfFunctionFactory, globalColorSpaceCache, localColorSpaceCache, asyncIfNotCached, }: {
3
+ cs: any;
4
+ xref: any;
5
+ resources?: null | undefined;
6
+ pdfFunctionFactory: any;
7
+ globalColorSpaceCache: any;
8
+ localColorSpaceCache: any;
9
+ asyncIfNotCached?: boolean | undefined;
10
+ }): any;
11
+ /**
12
+ * NOTE: This method should *only* be invoked from `this.#parse`,
13
+ * when parsing "sub" ColorSpaces.
14
+ */
15
+ static #subParse(cs: any, options: any): any;
16
+ static #parse(cs: any, options: any): any;
17
+ static get gray(): any;
18
+ static get rgb(): any;
19
+ static get rgba(): any;
20
+ static get cmyk(): any;
21
+ }