unpdf 0.5.3 → 0.6.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 (85) hide show
  1. package/README.md +64 -31
  2. package/dist/index.node.cjs +8 -9
  3. package/dist/index.node.d.cts +4 -4
  4. package/dist/index.node.d.mts +4 -4
  5. package/dist/index.node.d.ts +4 -4
  6. package/dist/index.node.mjs +2 -3
  7. package/dist/index.web.cjs +8 -9
  8. package/dist/index.web.d.cts +4 -4
  9. package/dist/index.web.d.mts +4 -4
  10. package/dist/index.web.d.ts +4 -4
  11. package/dist/index.web.mjs +2 -3
  12. package/dist/index.worker.cjs +14 -11
  13. package/dist/index.worker.d.cts +4 -4
  14. package/dist/index.worker.d.mts +4 -4
  15. package/dist/index.worker.d.ts +4 -4
  16. package/dist/index.worker.mjs +12 -8
  17. package/dist/pdfjs.d.mts +1 -0
  18. package/dist/pdfjs.d.ts +1 -0
  19. package/dist/pdfjs.mjs +1 -0
  20. package/dist/shared/{unpdf.d3d8f5ac.d.mts → unpdf.3991886a.d.cts} +11 -9
  21. package/dist/shared/{unpdf.d3d8f5ac.d.cts → unpdf.3991886a.d.mts} +11 -9
  22. package/dist/shared/{unpdf.d3d8f5ac.d.ts → unpdf.3991886a.d.ts} +11 -9
  23. package/dist/shared/unpdf.6c0ca5b5.cjs +107 -0
  24. package/dist/shared/unpdf.ce219a40.mjs +99 -0
  25. package/dist/types/external/webL10n/l10n.d.ts +0 -0
  26. package/dist/types/src/display/annotation_layer.d.ts +203 -0
  27. package/dist/types/src/display/annotation_storage.d.ts +89 -0
  28. package/dist/types/src/display/api.d.ts +1466 -0
  29. package/dist/types/src/display/base_factory.d.ts +54 -0
  30. package/dist/types/src/display/canvas.d.ts +208 -0
  31. package/dist/types/src/display/display_utils.d.ts +277 -0
  32. package/dist/types/src/display/editor/annotation_editor_layer.d.ts +196 -0
  33. package/dist/types/src/display/editor/editor.d.ts +325 -0
  34. package/dist/types/src/display/editor/freetext.d.ts +72 -0
  35. package/dist/types/src/display/editor/ink.d.ts +95 -0
  36. package/dist/types/src/display/editor/stamp.d.ts +28 -0
  37. package/dist/types/src/display/editor/tools.d.ts +349 -0
  38. package/dist/types/src/display/font_loader.d.ts +43 -0
  39. package/dist/types/src/display/metadata.d.ts +11 -0
  40. package/dist/types/src/display/optional_content_config.d.ts +13 -0
  41. package/dist/types/src/display/pattern_helper.d.ts +73 -0
  42. package/dist/types/src/display/text_layer.d.ts +151 -0
  43. package/dist/types/src/display/transport_stream.d.ts +68 -0
  44. package/dist/types/src/display/worker_options.d.ts +27 -0
  45. package/dist/types/src/display/xfa_layer.d.ts +46 -0
  46. package/dist/types/src/display/xfa_text.d.ts +19 -0
  47. package/dist/types/src/pdf.d.ts +50 -0
  48. package/dist/types/src/shared/image_utils.d.ts +17 -0
  49. package/dist/types/src/shared/message_handler.d.ts +43 -0
  50. package/dist/types/src/shared/murmurhash3.d.ts +7 -0
  51. package/dist/types/src/shared/scripting_utils.d.ts +16 -0
  52. package/dist/types/src/shared/util.d.ts +398 -0
  53. package/dist/types/web/annotation_editor_layer_builder.d.ts +50 -0
  54. package/dist/types/web/annotation_layer_builder.d.ts +83 -0
  55. package/dist/types/web/app_options.d.ts +14 -0
  56. package/dist/types/web/download_manager.d.ts +14 -0
  57. package/dist/types/web/event_utils.d.ts +75 -0
  58. package/dist/types/web/generic_scripting.d.ts +8 -0
  59. package/dist/types/web/genericl10n.d.ts +13 -0
  60. package/dist/types/web/interfaces.d.ts +163 -0
  61. package/dist/types/web/l10n_utils.d.ts +7 -0
  62. package/dist/types/web/pdf_find_controller.d.ts +108 -0
  63. package/dist/types/web/pdf_find_utils.d.ts +16 -0
  64. package/dist/types/web/pdf_history.d.ts +168 -0
  65. package/dist/types/web/pdf_link_service.d.ts +243 -0
  66. package/dist/types/web/pdf_page_view.d.ts +209 -0
  67. package/dist/types/web/pdf_rendering_queue.d.ts +53 -0
  68. package/dist/types/web/pdf_scripting_manager.component.d.ts +5 -0
  69. package/dist/types/web/pdf_scripting_manager.d.ts +61 -0
  70. package/dist/types/web/pdf_single_page_viewer.d.ts +7 -0
  71. package/dist/types/web/pdf_thumbnail_view.d.ts +131 -0
  72. package/dist/types/web/pdf_thumbnail_viewer.d.ts +104 -0
  73. package/dist/types/web/pdf_viewer.component.d.ts +24 -0
  74. package/dist/types/web/pdf_viewer.d.ts +455 -0
  75. package/dist/types/web/struct_tree_layer_builder.d.ts +7 -0
  76. package/dist/types/web/text_accessibility.d.ts +42 -0
  77. package/dist/types/web/text_highlighter.d.ts +63 -0
  78. package/dist/types/web/text_layer_builder.d.ts +64 -0
  79. package/dist/types/web/ui_utils.d.ts +288 -0
  80. package/dist/types/web/xfa_layer_builder.d.ts +41 -0
  81. package/package.json +67 -41
  82. package/dist/shared/unpdf.61a2a4e1.cjs +0 -56
  83. package/dist/shared/unpdf.9511ac30.cjs +0 -52
  84. package/dist/shared/unpdf.c7f36e56.mjs +0 -50
  85. package/dist/shared/unpdf.cd67d475.mjs +0 -48
@@ -0,0 +1,1466 @@
1
+ export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
2
+ export type BinaryData = TypedArray | ArrayBuffer | Array<number> | string;
3
+ export type RefProxy = {
4
+ num: number;
5
+ gen: number;
6
+ };
7
+ /**
8
+ * Document initialization / loading parameters object.
9
+ */
10
+ export type DocumentInitParameters = {
11
+ /**
12
+ * - The URL of the PDF.
13
+ */
14
+ url?: string | URL | undefined;
15
+ /**
16
+ * - Binary PDF data.
17
+ * Use TypedArrays (Uint8Array) to improve the memory usage. If PDF data is
18
+ * BASE64-encoded, use `atob()` to convert it to a binary string first.
19
+ *
20
+ * NOTE: If TypedArrays are used they will generally be transferred to the
21
+ * worker-thread. This will help reduce main-thread memory usage, however
22
+ * it will take ownership of the TypedArrays.
23
+ */
24
+ data?: BinaryData | undefined;
25
+ /**
26
+ * - Basic authentication headers.
27
+ */
28
+ httpHeaders?: Object | undefined;
29
+ /**
30
+ * - Indicates whether or not
31
+ * cross-site Access-Control requests should be made using credentials such
32
+ * as cookies or authorization headers. The default is `false`.
33
+ */
34
+ withCredentials?: boolean | undefined;
35
+ /**
36
+ * - For decrypting password-protected PDFs.
37
+ */
38
+ password?: string | undefined;
39
+ /**
40
+ * - The PDF file length. It's used for progress
41
+ * reports and range requests operations.
42
+ */
43
+ length?: number | undefined;
44
+ /**
45
+ * - Allows for using a custom range
46
+ * transport implementation.
47
+ */
48
+ range?: PDFDataRangeTransport | undefined;
49
+ /**
50
+ * - Specify maximum number of bytes fetched
51
+ * per range request. The default value is {@link DEFAULT_RANGE_CHUNK_SIZE }.
52
+ */
53
+ rangeChunkSize?: number | undefined;
54
+ /**
55
+ * - The worker that will be used for loading and
56
+ * parsing the PDF data.
57
+ */
58
+ worker?: PDFWorker | undefined;
59
+ /**
60
+ * - Controls the logging level; the constants
61
+ * from {@link VerbosityLevel } should be used.
62
+ */
63
+ verbosity?: number | undefined;
64
+ /**
65
+ * - The base URL of the document, used when
66
+ * attempting to recover valid absolute URLs for annotations, and outline
67
+ * items, that (incorrectly) only specify relative URLs.
68
+ */
69
+ docBaseUrl?: string | undefined;
70
+ /**
71
+ * - The URL where the predefined Adobe CMaps are
72
+ * located. Include the trailing slash.
73
+ */
74
+ cMapUrl?: string | undefined;
75
+ /**
76
+ * - Specifies if the Adobe CMaps are binary
77
+ * packed or not. The default value is `true`.
78
+ */
79
+ cMapPacked?: boolean | undefined;
80
+ /**
81
+ * - The factory that will be used when
82
+ * reading built-in CMap files. Providing a custom factory is useful for
83
+ * environments without Fetch API or `XMLHttpRequest` support, such as
84
+ * Node.js. The default value is {DOMCMapReaderFactory}.
85
+ */
86
+ CMapReaderFactory?: Object | undefined;
87
+ /**
88
+ * - When `true`, fonts that aren't
89
+ * embedded in the PDF document will fallback to a system font.
90
+ * The default value is `true` in web environments and `false` in Node.js;
91
+ * unless `disableFontFace === true` in which case this defaults to `false`
92
+ * regardless of the environment (to prevent completely broken fonts).
93
+ */
94
+ useSystemFonts?: boolean | undefined;
95
+ /**
96
+ * - The URL where the standard font
97
+ * files are located. Include the trailing slash.
98
+ */
99
+ standardFontDataUrl?: string | undefined;
100
+ /**
101
+ * - The factory that will be used
102
+ * when reading the standard font files. Providing a custom factory is useful
103
+ * for environments without Fetch API or `XMLHttpRequest` support, such as
104
+ * Node.js. The default value is {DOMStandardFontDataFactory}.
105
+ */
106
+ StandardFontDataFactory?: Object | undefined;
107
+ /**
108
+ * - Enable using the Fetch API in the
109
+ * worker-thread when reading CMap and standard font files. When `true`,
110
+ * the `CMapReaderFactory` and `StandardFontDataFactory` options are ignored.
111
+ * The default value is `true` in web environments and `false` in Node.js.
112
+ */
113
+ useWorkerFetch?: boolean | undefined;
114
+ /**
115
+ * - Reject certain promises, e.g.
116
+ * `getOperatorList`, `getTextContent`, and `RenderTask`, when the associated
117
+ * PDF data cannot be successfully parsed, instead of attempting to recover
118
+ * whatever possible of the data. The default value is `false`.
119
+ */
120
+ stopAtErrors?: boolean | undefined;
121
+ /**
122
+ * - The maximum allowed image size in total
123
+ * pixels, i.e. width * height. Images above this value will not be rendered.
124
+ * Use -1 for no limit, which is also the default value.
125
+ */
126
+ maxImageSize?: number | undefined;
127
+ /**
128
+ * - Determines if we can evaluate strings
129
+ * as JavaScript. Primarily used to improve performance of font rendering, and
130
+ * when parsing PDF functions. The default value is `true`.
131
+ */
132
+ isEvalSupported?: boolean | undefined;
133
+ /**
134
+ * - Determines if we can use
135
+ * `OffscreenCanvas` in the worker. Primarily used to improve performance of
136
+ * image conversion/rendering.
137
+ * The default value is `true` in web environments and `false` in Node.js.
138
+ */
139
+ isOffscreenCanvasSupported?: boolean | undefined;
140
+ /**
141
+ * - The integer value is used to
142
+ * know when an image must be resized (uses `OffscreenCanvas` in the worker).
143
+ * If it's -1 then a possibly slow algorithm is used to guess the max value.
144
+ */
145
+ canvasMaxAreaInBytes?: number | undefined;
146
+ /**
147
+ * - By default fonts are converted to
148
+ * OpenType fonts and loaded via the Font Loading API or `@font-face` rules.
149
+ * If disabled, fonts will be rendered using a built-in font renderer that
150
+ * constructs the glyphs with primitive path commands.
151
+ * The default value is `false` in web environments and `true` in Node.js.
152
+ */
153
+ disableFontFace?: boolean | undefined;
154
+ /**
155
+ * - Include additional properties,
156
+ * which are unused during rendering of PDF documents, when exporting the
157
+ * parsed font data from the worker-thread. This may be useful for debugging
158
+ * purposes (and backwards compatibility), but note that it will lead to
159
+ * increased memory usage. The default value is `false`.
160
+ */
161
+ fontExtraProperties?: boolean | undefined;
162
+ /**
163
+ * - Render Xfa forms if any.
164
+ * The default value is `false`.
165
+ */
166
+ enableXfa?: boolean | undefined;
167
+ /**
168
+ * - Specify an explicit document
169
+ * context to create elements with and to load resources, such as fonts,
170
+ * into. Defaults to the current document.
171
+ */
172
+ ownerDocument?: HTMLDocument | undefined;
173
+ /**
174
+ * - Disable range request loading of PDF
175
+ * files. When enabled, and if the server supports partial content requests,
176
+ * then the PDF will be fetched in chunks. The default value is `false`.
177
+ */
178
+ disableRange?: boolean | undefined;
179
+ /**
180
+ * - Disable streaming of PDF file data.
181
+ * By default PDF.js attempts to load PDF files in chunks. The default value
182
+ * is `false`.
183
+ */
184
+ disableStream?: boolean | undefined;
185
+ /**
186
+ * - Disable pre-fetching of PDF file
187
+ * data. When range requests are enabled PDF.js will automatically keep
188
+ * fetching more data even if it isn't needed to display the current page.
189
+ * The default value is `false`.
190
+ *
191
+ * NOTE: It is also necessary to disable streaming, see above, in order for
192
+ * disabling of pre-fetching to work correctly.
193
+ */
194
+ disableAutoFetch?: boolean | undefined;
195
+ /**
196
+ * - Enables special hooks for debugging PDF.js
197
+ * (see `web/debugger.js`). The default value is `false`.
198
+ */
199
+ pdfBug?: boolean | undefined;
200
+ /**
201
+ * - The factory instance that will be used
202
+ * when creating canvases. The default value is {new DOMCanvasFactory()}.
203
+ */
204
+ canvasFactory?: Object | undefined;
205
+ /**
206
+ * - A factory instance that will be used
207
+ * to create SVG filters when rendering some images on the main canvas.
208
+ */
209
+ filterFactory?: Object | undefined;
210
+ };
211
+ export type OnProgressParameters = {
212
+ /**
213
+ * - Currently loaded number of bytes.
214
+ */
215
+ loaded: number;
216
+ /**
217
+ * - Total number of bytes in the PDF file.
218
+ */
219
+ total: number;
220
+ };
221
+ /**
222
+ * Page getViewport parameters.
223
+ */
224
+ export type GetViewportParameters = {
225
+ /**
226
+ * - The desired scale of the viewport.
227
+ */
228
+ scale: number;
229
+ /**
230
+ * - The desired rotation, in degrees, of
231
+ * the viewport. If omitted it defaults to the page rotation.
232
+ */
233
+ rotation?: number | undefined;
234
+ /**
235
+ * - The horizontal, i.e. x-axis, offset.
236
+ * The default value is `0`.
237
+ */
238
+ offsetX?: number | undefined;
239
+ /**
240
+ * - The vertical, i.e. y-axis, offset.
241
+ * The default value is `0`.
242
+ */
243
+ offsetY?: number | undefined;
244
+ /**
245
+ * - If true, the y-axis will not be
246
+ * flipped. The default value is `false`.
247
+ */
248
+ dontFlip?: boolean | undefined;
249
+ };
250
+ /**
251
+ * Page getTextContent parameters.
252
+ */
253
+ export type getTextContentParameters = {
254
+ /**
255
+ * - When true include marked
256
+ * content items in the items array of TextContent. The default is `false`.
257
+ */
258
+ includeMarkedContent?: boolean | undefined;
259
+ /**
260
+ * - When true the text is *not*
261
+ * normalized in the worker-thread. The default is `false`.
262
+ */
263
+ disableNormalization?: boolean | undefined;
264
+ };
265
+ /**
266
+ * Page text content.
267
+ */
268
+ export type TextContent = {
269
+ /**
270
+ * - Array of
271
+ * {@link TextItem } and {@link TextMarkedContent } objects. TextMarkedContent
272
+ * items are included when includeMarkedContent is true.
273
+ */
274
+ items: Array<TextItem | TextMarkedContent>;
275
+ /**
276
+ * - {@link TextStyle } objects,
277
+ * indexed by font name.
278
+ */
279
+ styles: {
280
+ [x: string]: TextStyle;
281
+ };
282
+ };
283
+ /**
284
+ * Page text content part.
285
+ */
286
+ export type TextItem = {
287
+ /**
288
+ * - Text content.
289
+ */
290
+ str: string;
291
+ /**
292
+ * - Text direction: 'ttb', 'ltr' or 'rtl'.
293
+ */
294
+ dir: string;
295
+ /**
296
+ * - Transformation matrix.
297
+ */
298
+ transform: Array<any>;
299
+ /**
300
+ * - Width in device space.
301
+ */
302
+ width: number;
303
+ /**
304
+ * - Height in device space.
305
+ */
306
+ height: number;
307
+ /**
308
+ * - Font name used by PDF.js for converted font.
309
+ */
310
+ fontName: string;
311
+ /**
312
+ * - Indicating if the text content is followed by a
313
+ * line-break.
314
+ */
315
+ hasEOL: boolean;
316
+ };
317
+ /**
318
+ * Page text marked content part.
319
+ */
320
+ export type TextMarkedContent = {
321
+ /**
322
+ * - Either 'beginMarkedContent',
323
+ * 'beginMarkedContentProps', or 'endMarkedContent'.
324
+ */
325
+ type: string;
326
+ /**
327
+ * - The marked content identifier. Only used for type
328
+ * 'beginMarkedContentProps'.
329
+ */
330
+ id: string;
331
+ };
332
+ /**
333
+ * Text style.
334
+ */
335
+ export type TextStyle = {
336
+ /**
337
+ * - Font ascent.
338
+ */
339
+ ascent: number;
340
+ /**
341
+ * - Font descent.
342
+ */
343
+ descent: number;
344
+ /**
345
+ * - Whether or not the text is in vertical mode.
346
+ */
347
+ vertical: boolean;
348
+ /**
349
+ * - The possible font family.
350
+ */
351
+ fontFamily: string;
352
+ };
353
+ /**
354
+ * Page annotation parameters.
355
+ */
356
+ export type GetAnnotationsParameters = {
357
+ /**
358
+ * - Determines the annotations that are fetched,
359
+ * can be 'display' (viewable annotations), 'print' (printable annotations),
360
+ * or 'any' (all annotations). The default value is 'display'.
361
+ */
362
+ intent?: string | undefined;
363
+ };
364
+ /**
365
+ * Page render parameters.
366
+ */
367
+ export type RenderParameters = {
368
+ /**
369
+ * - A 2D context of a DOM
370
+ * Canvas object.
371
+ */
372
+ canvasContext: CanvasRenderingContext2D;
373
+ /**
374
+ * - Rendering viewport obtained by calling
375
+ * the `PDFPageProxy.getViewport` method.
376
+ */
377
+ viewport: PageViewport;
378
+ /**
379
+ * - Rendering intent, can be 'display', 'print',
380
+ * or 'any'. The default value is 'display'.
381
+ */
382
+ intent?: string | undefined;
383
+ /**
384
+ * Controls which annotations are rendered
385
+ * onto the canvas, for annotations with appearance-data; the values from
386
+ * {@link AnnotationMode } should be used. The following values are supported:
387
+ * - `AnnotationMode.DISABLE`, which disables all annotations.
388
+ * - `AnnotationMode.ENABLE`, which includes all possible annotations (thus
389
+ * it also depends on the `intent`-option, see above).
390
+ * - `AnnotationMode.ENABLE_FORMS`, which excludes annotations that contain
391
+ * interactive form elements (those will be rendered in the display layer).
392
+ * - `AnnotationMode.ENABLE_STORAGE`, which includes all possible annotations
393
+ * (as above) but where interactive form elements are updated with data
394
+ * from the {@link AnnotationStorage }-instance; useful e.g. for printing.
395
+ * The default value is `AnnotationMode.ENABLE`.
396
+ */
397
+ annotationMode?: number | undefined;
398
+ /**
399
+ * - Additional transform, applied just
400
+ * before viewport transform.
401
+ */
402
+ transform?: any[] | undefined;
403
+ /**
404
+ * - Background
405
+ * to use for the canvas.
406
+ * Any valid `canvas.fillStyle` can be used: a `DOMString` parsed as CSS
407
+ * <color> value, a `CanvasGradient` object (a linear or radial gradient) or
408
+ * a `CanvasPattern` object (a repetitive image). The default value is
409
+ * 'rgb(255,255,255)'.
410
+ *
411
+ * NOTE: This option may be partially, or completely, ignored when the
412
+ * `pageColors`-option is used.
413
+ */
414
+ background?: string | CanvasGradient | CanvasPattern | undefined;
415
+ /**
416
+ * - Overwrites background and foreground colors
417
+ * with user defined ones in order to improve readability in high contrast
418
+ * mode.
419
+ */
420
+ pageColors?: Object | undefined;
421
+ /**
422
+ * -
423
+ * A promise that should resolve with an {@link OptionalContentConfig }created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,
424
+ * the configuration will be fetched automatically with the default visibility
425
+ * states set.
426
+ */
427
+ optionalContentConfigPromise?: Promise<OptionalContentConfig> | undefined;
428
+ /**
429
+ * - Map some
430
+ * annotation ids with canvases used to render them.
431
+ */
432
+ annotationCanvasMap?: Map<string, HTMLCanvasElement> | undefined;
433
+ printAnnotationStorage?: PrintAnnotationStorage | undefined;
434
+ };
435
+ /**
436
+ * Page getOperatorList parameters.
437
+ */
438
+ export type GetOperatorListParameters = {
439
+ /**
440
+ * - Rendering intent, can be 'display', 'print',
441
+ * or 'any'. The default value is 'display'.
442
+ */
443
+ intent?: string | undefined;
444
+ /**
445
+ * Controls which annotations are included
446
+ * in the operatorList, for annotations with appearance-data; the values from
447
+ * {@link AnnotationMode } should be used. The following values are supported:
448
+ * - `AnnotationMode.DISABLE`, which disables all annotations.
449
+ * - `AnnotationMode.ENABLE`, which includes all possible annotations (thus
450
+ * it also depends on the `intent`-option, see above).
451
+ * - `AnnotationMode.ENABLE_FORMS`, which excludes annotations that contain
452
+ * interactive form elements (those will be rendered in the display layer).
453
+ * - `AnnotationMode.ENABLE_STORAGE`, which includes all possible annotations
454
+ * (as above) but where interactive form elements are updated with data
455
+ * from the {@link AnnotationStorage }-instance; useful e.g. for printing.
456
+ * The default value is `AnnotationMode.ENABLE`.
457
+ */
458
+ annotationMode?: number | undefined;
459
+ printAnnotationStorage?: PrintAnnotationStorage | undefined;
460
+ };
461
+ /**
462
+ * Structure tree node. The root node will have a role "Root".
463
+ */
464
+ export type StructTreeNode = {
465
+ /**
466
+ * - Array of
467
+ * {@link StructTreeNode } and {@link StructTreeContent } objects.
468
+ */
469
+ children: Array<StructTreeNode | StructTreeContent>;
470
+ /**
471
+ * - element's role, already mapped if a role map exists
472
+ * in the PDF.
473
+ */
474
+ role: string;
475
+ };
476
+ /**
477
+ * Structure tree content.
478
+ */
479
+ export type StructTreeContent = {
480
+ /**
481
+ * - either "content" for page and stream structure
482
+ * elements or "object" for object references.
483
+ */
484
+ type: string;
485
+ /**
486
+ * - unique id that will map to the text layer.
487
+ */
488
+ id: string;
489
+ };
490
+ /**
491
+ * PDF page operator list.
492
+ */
493
+ export type PDFOperatorList = {
494
+ /**
495
+ * - Array containing the operator functions.
496
+ */
497
+ fnArray: Array<number>;
498
+ /**
499
+ * - Array containing the arguments of the
500
+ * functions.
501
+ */
502
+ argsArray: Array<any>;
503
+ };
504
+ export type PDFWorkerParameters = {
505
+ /**
506
+ * - The name of the worker.
507
+ */
508
+ name?: string | undefined;
509
+ /**
510
+ * - The `workerPort` object.
511
+ */
512
+ port?: Worker | undefined;
513
+ /**
514
+ * - Controls the logging level;
515
+ * the constants from {@link VerbosityLevel } should be used.
516
+ */
517
+ verbosity?: number | undefined;
518
+ };
519
+ /** @type {string} */
520
+ export const build: string;
521
+ export const DefaultCanvasFactory: any;
522
+ export const DefaultCMapReaderFactory: any;
523
+ export const DefaultFilterFactory: any;
524
+ export const DefaultStandardFontDataFactory: any;
525
+ /**
526
+ * @typedef { Int8Array | Uint8Array | Uint8ClampedArray |
527
+ * Int16Array | Uint16Array |
528
+ * Int32Array | Uint32Array | Float32Array |
529
+ * Float64Array
530
+ * } TypedArray
531
+ */
532
+ /**
533
+ * @typedef { TypedArray | ArrayBuffer | Array<number> | string } BinaryData
534
+ */
535
+ /**
536
+ * @typedef {Object} RefProxy
537
+ * @property {number} num
538
+ * @property {number} gen
539
+ */
540
+ /**
541
+ * Document initialization / loading parameters object.
542
+ *
543
+ * @typedef {Object} DocumentInitParameters
544
+ * @property {string | URL} [url] - The URL of the PDF.
545
+ * @property {BinaryData} [data] - Binary PDF data.
546
+ * Use TypedArrays (Uint8Array) to improve the memory usage. If PDF data is
547
+ * BASE64-encoded, use `atob()` to convert it to a binary string first.
548
+ *
549
+ * NOTE: If TypedArrays are used they will generally be transferred to the
550
+ * worker-thread. This will help reduce main-thread memory usage, however
551
+ * it will take ownership of the TypedArrays.
552
+ * @property {Object} [httpHeaders] - Basic authentication headers.
553
+ * @property {boolean} [withCredentials] - Indicates whether or not
554
+ * cross-site Access-Control requests should be made using credentials such
555
+ * as cookies or authorization headers. The default is `false`.
556
+ * @property {string} [password] - For decrypting password-protected PDFs.
557
+ * @property {number} [length] - The PDF file length. It's used for progress
558
+ * reports and range requests operations.
559
+ * @property {PDFDataRangeTransport} [range] - Allows for using a custom range
560
+ * transport implementation.
561
+ * @property {number} [rangeChunkSize] - Specify maximum number of bytes fetched
562
+ * per range request. The default value is {@link DEFAULT_RANGE_CHUNK_SIZE}.
563
+ * @property {PDFWorker} [worker] - The worker that will be used for loading and
564
+ * parsing the PDF data.
565
+ * @property {number} [verbosity] - Controls the logging level; the constants
566
+ * from {@link VerbosityLevel} should be used.
567
+ * @property {string} [docBaseUrl] - The base URL of the document, used when
568
+ * attempting to recover valid absolute URLs for annotations, and outline
569
+ * items, that (incorrectly) only specify relative URLs.
570
+ * @property {string} [cMapUrl] - The URL where the predefined Adobe CMaps are
571
+ * located. Include the trailing slash.
572
+ * @property {boolean} [cMapPacked] - Specifies if the Adobe CMaps are binary
573
+ * packed or not. The default value is `true`.
574
+ * @property {Object} [CMapReaderFactory] - The factory that will be used when
575
+ * reading built-in CMap files. Providing a custom factory is useful for
576
+ * environments without Fetch API or `XMLHttpRequest` support, such as
577
+ * Node.js. The default value is {DOMCMapReaderFactory}.
578
+ * @property {boolean} [useSystemFonts] - When `true`, fonts that aren't
579
+ * embedded in the PDF document will fallback to a system font.
580
+ * The default value is `true` in web environments and `false` in Node.js;
581
+ * unless `disableFontFace === true` in which case this defaults to `false`
582
+ * regardless of the environment (to prevent completely broken fonts).
583
+ * @property {string} [standardFontDataUrl] - The URL where the standard font
584
+ * files are located. Include the trailing slash.
585
+ * @property {Object} [StandardFontDataFactory] - The factory that will be used
586
+ * when reading the standard font files. Providing a custom factory is useful
587
+ * for environments without Fetch API or `XMLHttpRequest` support, such as
588
+ * Node.js. The default value is {DOMStandardFontDataFactory}.
589
+ * @property {boolean} [useWorkerFetch] - Enable using the Fetch API in the
590
+ * worker-thread when reading CMap and standard font files. When `true`,
591
+ * the `CMapReaderFactory` and `StandardFontDataFactory` options are ignored.
592
+ * The default value is `true` in web environments and `false` in Node.js.
593
+ * @property {boolean} [stopAtErrors] - Reject certain promises, e.g.
594
+ * `getOperatorList`, `getTextContent`, and `RenderTask`, when the associated
595
+ * PDF data cannot be successfully parsed, instead of attempting to recover
596
+ * whatever possible of the data. The default value is `false`.
597
+ * @property {number} [maxImageSize] - The maximum allowed image size in total
598
+ * pixels, i.e. width * height. Images above this value will not be rendered.
599
+ * Use -1 for no limit, which is also the default value.
600
+ * @property {boolean} [isEvalSupported] - Determines if we can evaluate strings
601
+ * as JavaScript. Primarily used to improve performance of font rendering, and
602
+ * when parsing PDF functions. The default value is `true`.
603
+ * @property {boolean} [isOffscreenCanvasSupported] - Determines if we can use
604
+ * `OffscreenCanvas` in the worker. Primarily used to improve performance of
605
+ * image conversion/rendering.
606
+ * The default value is `true` in web environments and `false` in Node.js.
607
+ * @property {number} [canvasMaxAreaInBytes] - The integer value is used to
608
+ * know when an image must be resized (uses `OffscreenCanvas` in the worker).
609
+ * If it's -1 then a possibly slow algorithm is used to guess the max value.
610
+ * @property {boolean} [disableFontFace] - By default fonts are converted to
611
+ * OpenType fonts and loaded via the Font Loading API or `@font-face` rules.
612
+ * If disabled, fonts will be rendered using a built-in font renderer that
613
+ * constructs the glyphs with primitive path commands.
614
+ * The default value is `false` in web environments and `true` in Node.js.
615
+ * @property {boolean} [fontExtraProperties] - Include additional properties,
616
+ * which are unused during rendering of PDF documents, when exporting the
617
+ * parsed font data from the worker-thread. This may be useful for debugging
618
+ * purposes (and backwards compatibility), but note that it will lead to
619
+ * increased memory usage. The default value is `false`.
620
+ * @property {boolean} [enableXfa] - Render Xfa forms if any.
621
+ * The default value is `false`.
622
+ * @property {HTMLDocument} [ownerDocument] - Specify an explicit document
623
+ * context to create elements with and to load resources, such as fonts,
624
+ * into. Defaults to the current document.
625
+ * @property {boolean} [disableRange] - Disable range request loading of PDF
626
+ * files. When enabled, and if the server supports partial content requests,
627
+ * then the PDF will be fetched in chunks. The default value is `false`.
628
+ * @property {boolean} [disableStream] - Disable streaming of PDF file data.
629
+ * By default PDF.js attempts to load PDF files in chunks. The default value
630
+ * is `false`.
631
+ * @property {boolean} [disableAutoFetch] - Disable pre-fetching of PDF file
632
+ * data. When range requests are enabled PDF.js will automatically keep
633
+ * fetching more data even if it isn't needed to display the current page.
634
+ * The default value is `false`.
635
+ *
636
+ * NOTE: It is also necessary to disable streaming, see above, in order for
637
+ * disabling of pre-fetching to work correctly.
638
+ * @property {boolean} [pdfBug] - Enables special hooks for debugging PDF.js
639
+ * (see `web/debugger.js`). The default value is `false`.
640
+ * @property {Object} [canvasFactory] - The factory instance that will be used
641
+ * when creating canvases. The default value is {new DOMCanvasFactory()}.
642
+ * @property {Object} [filterFactory] - A factory instance that will be used
643
+ * to create SVG filters when rendering some images on the main canvas.
644
+ */
645
+ /**
646
+ * This is the main entry point for loading a PDF and interacting with it.
647
+ *
648
+ * NOTE: If a URL is used to fetch the PDF data a standard Fetch API call (or
649
+ * XHR as fallback) is used, which means it must follow same origin rules,
650
+ * e.g. no cross-domain requests without CORS.
651
+ *
652
+ * @param {string | URL | TypedArray | ArrayBuffer | DocumentInitParameters}
653
+ * src - Can be a URL where a PDF file is located, a typed array (Uint8Array)
654
+ * already populated with data, or a parameter object.
655
+ * @returns {PDFDocumentLoadingTask}
656
+ */
657
+ export function getDocument(src: string | URL | TypedArray | ArrayBuffer | DocumentInitParameters): PDFDocumentLoadingTask;
658
+ export class LoopbackPort {
659
+ postMessage(obj: any, transfer: any): void;
660
+ addEventListener(name: any, listener: any): void;
661
+ removeEventListener(name: any, listener: any): void;
662
+ terminate(): void;
663
+ #private;
664
+ }
665
+ /**
666
+ * Abstract class to support range requests file loading.
667
+ *
668
+ * NOTE: The TypedArrays passed to the constructor and relevant methods below
669
+ * will generally be transferred to the worker-thread. This will help reduce
670
+ * main-thread memory usage, however it will take ownership of the TypedArrays.
671
+ */
672
+ export class PDFDataRangeTransport {
673
+ /**
674
+ * @param {number} length
675
+ * @param {Uint8Array|null} initialData
676
+ * @param {boolean} [progressiveDone]
677
+ * @param {string} [contentDispositionFilename]
678
+ */
679
+ constructor(length: number, initialData: Uint8Array | null, progressiveDone?: boolean | undefined, contentDispositionFilename?: string | undefined);
680
+ length: number;
681
+ initialData: Uint8Array | null;
682
+ progressiveDone: boolean;
683
+ contentDispositionFilename: string;
684
+ _rangeListeners: any[];
685
+ _progressListeners: any[];
686
+ _progressiveReadListeners: any[];
687
+ _progressiveDoneListeners: any[];
688
+ _readyCapability: PromiseCapability;
689
+ /**
690
+ * @param {function} listener
691
+ */
692
+ addRangeListener(listener: Function): void;
693
+ /**
694
+ * @param {function} listener
695
+ */
696
+ addProgressListener(listener: Function): void;
697
+ /**
698
+ * @param {function} listener
699
+ */
700
+ addProgressiveReadListener(listener: Function): void;
701
+ /**
702
+ * @param {function} listener
703
+ */
704
+ addProgressiveDoneListener(listener: Function): void;
705
+ /**
706
+ * @param {number} begin
707
+ * @param {Uint8Array|null} chunk
708
+ */
709
+ onDataRange(begin: number, chunk: Uint8Array | null): void;
710
+ /**
711
+ * @param {number} loaded
712
+ * @param {number|undefined} total
713
+ */
714
+ onDataProgress(loaded: number, total: number | undefined): void;
715
+ /**
716
+ * @param {Uint8Array|null} chunk
717
+ */
718
+ onDataProgressiveRead(chunk: Uint8Array | null): void;
719
+ onDataProgressiveDone(): void;
720
+ transportReady(): void;
721
+ /**
722
+ * @param {number} begin
723
+ * @param {number} end
724
+ */
725
+ requestDataRange(begin: number, end: number): void;
726
+ abort(): void;
727
+ }
728
+ /**
729
+ * @typedef {Object} OnProgressParameters
730
+ * @property {number} loaded - Currently loaded number of bytes.
731
+ * @property {number} total - Total number of bytes in the PDF file.
732
+ */
733
+ /**
734
+ * The loading task controls the operations required to load a PDF document
735
+ * (such as network requests) and provides a way to listen for completion,
736
+ * after which individual pages can be rendered.
737
+ */
738
+ export class PDFDocumentLoadingTask {
739
+ static "__#32@#docId": number;
740
+ _capability: PromiseCapability;
741
+ _transport: any;
742
+ _worker: any;
743
+ /**
744
+ * Unique identifier for the document loading task.
745
+ * @type {string}
746
+ */
747
+ docId: string;
748
+ /**
749
+ * Whether the loading task is destroyed or not.
750
+ * @type {boolean}
751
+ */
752
+ destroyed: boolean;
753
+ /**
754
+ * Callback to request a password if a wrong or no password was provided.
755
+ * The callback receives two parameters: a function that should be called
756
+ * with the new password, and a reason (see {@link PasswordResponses}).
757
+ * @type {function}
758
+ */
759
+ onPassword: Function;
760
+ /**
761
+ * Callback to be able to monitor the loading progress of the PDF file
762
+ * (necessary to implement e.g. a loading bar).
763
+ * The callback receives an {@link OnProgressParameters} argument.
764
+ * @type {function}
765
+ */
766
+ onProgress: Function;
767
+ /**
768
+ * Promise for document loading task completion.
769
+ * @type {Promise<PDFDocumentProxy>}
770
+ */
771
+ get promise(): Promise<PDFDocumentProxy>;
772
+ /**
773
+ * Abort all network requests and destroy the worker.
774
+ * @returns {Promise<void>} A promise that is resolved when destruction is
775
+ * completed.
776
+ */
777
+ destroy(): Promise<void>;
778
+ }
779
+ /**
780
+ * Proxy to a `PDFDocument` in the worker thread.
781
+ */
782
+ export class PDFDocumentProxy {
783
+ constructor(pdfInfo: any, transport: any);
784
+ _pdfInfo: any;
785
+ _transport: any;
786
+ /**
787
+ * @type {AnnotationStorage} Storage for annotation data in forms.
788
+ */
789
+ get annotationStorage(): AnnotationStorage;
790
+ /**
791
+ * @type {Object} The filter factory instance.
792
+ */
793
+ get filterFactory(): Object;
794
+ /**
795
+ * @type {number} Total number of pages in the PDF file.
796
+ */
797
+ get numPages(): number;
798
+ /**
799
+ * @type {Array<string, string|null>} A (not guaranteed to be) unique ID to
800
+ * identify the PDF document.
801
+ * NOTE: The first element will always be defined for all PDF documents,
802
+ * whereas the second element is only defined for *modified* PDF documents.
803
+ */
804
+ get fingerprints(): string[];
805
+ /**
806
+ * @type {boolean} True if only XFA form.
807
+ */
808
+ get isPureXfa(): boolean;
809
+ /**
810
+ * NOTE: This is (mostly) intended to support printing of XFA forms.
811
+ *
812
+ * @type {Object | null} An object representing a HTML tree structure
813
+ * to render the XFA, or `null` when no XFA form exists.
814
+ */
815
+ get allXfaHtml(): Object | null;
816
+ /**
817
+ * @param {number} pageNumber - The page number to get. The first page is 1.
818
+ * @returns {Promise<PDFPageProxy>} A promise that is resolved with
819
+ * a {@link PDFPageProxy} object.
820
+ */
821
+ getPage(pageNumber: number): Promise<PDFPageProxy>;
822
+ /**
823
+ * @param {RefProxy} ref - The page reference.
824
+ * @returns {Promise<number>} A promise that is resolved with the page index,
825
+ * starting from zero, that is associated with the reference.
826
+ */
827
+ getPageIndex(ref: RefProxy): Promise<number>;
828
+ /**
829
+ * @returns {Promise<Object<string, Array<any>>>} A promise that is resolved
830
+ * with a mapping from named destinations to references.
831
+ *
832
+ * This can be slow for large documents. Use `getDestination` instead.
833
+ */
834
+ getDestinations(): Promise<{
835
+ [x: string]: Array<any>;
836
+ }>;
837
+ /**
838
+ * @param {string} id - The named destination to get.
839
+ * @returns {Promise<Array<any> | null>} A promise that is resolved with all
840
+ * information of the given named destination, or `null` when the named
841
+ * destination is not present in the PDF file.
842
+ */
843
+ getDestination(id: string): Promise<Array<any> | null>;
844
+ /**
845
+ * @returns {Promise<Array<string> | null>} A promise that is resolved with
846
+ * an {Array} containing the page labels that correspond to the page
847
+ * indexes, or `null` when no page labels are present in the PDF file.
848
+ */
849
+ getPageLabels(): Promise<Array<string> | null>;
850
+ /**
851
+ * @returns {Promise<string>} A promise that is resolved with a {string}
852
+ * containing the page layout name.
853
+ */
854
+ getPageLayout(): Promise<string>;
855
+ /**
856
+ * @returns {Promise<string>} A promise that is resolved with a {string}
857
+ * containing the page mode name.
858
+ */
859
+ getPageMode(): Promise<string>;
860
+ /**
861
+ * @returns {Promise<Object | null>} A promise that is resolved with an
862
+ * {Object} containing the viewer preferences, or `null` when no viewer
863
+ * preferences are present in the PDF file.
864
+ */
865
+ getViewerPreferences(): Promise<Object | null>;
866
+ /**
867
+ * @returns {Promise<any | null>} A promise that is resolved with an {Array}
868
+ * containing the destination, or `null` when no open action is present
869
+ * in the PDF.
870
+ */
871
+ getOpenAction(): Promise<any | null>;
872
+ /**
873
+ * @returns {Promise<any>} A promise that is resolved with a lookup table
874
+ * for mapping named attachments to their content.
875
+ */
876
+ getAttachments(): Promise<any>;
877
+ /**
878
+ * @returns {Promise<Object | null>} A promise that is resolved with
879
+ * an {Object} with the JavaScript actions:
880
+ * - from the name tree.
881
+ * - from A or AA entries in the catalog dictionary.
882
+ * , or `null` if no JavaScript exists.
883
+ */
884
+ getJSActions(): Promise<Object | null>;
885
+ /**
886
+ * @typedef {Object} OutlineNode
887
+ * @property {string} title
888
+ * @property {boolean} bold
889
+ * @property {boolean} italic
890
+ * @property {Uint8ClampedArray} color - The color in RGB format to use for
891
+ * display purposes.
892
+ * @property {string | Array<any> | null} dest
893
+ * @property {string | null} url
894
+ * @property {string | undefined} unsafeUrl
895
+ * @property {boolean | undefined} newWindow
896
+ * @property {number | undefined} count
897
+ * @property {Array<OutlineNode>} items
898
+ */
899
+ /**
900
+ * @returns {Promise<Array<OutlineNode>>} A promise that is resolved with an
901
+ * {Array} that is a tree outline (if it has one) of the PDF file.
902
+ */
903
+ getOutline(): Promise<{
904
+ title: string;
905
+ bold: boolean;
906
+ italic: boolean;
907
+ /**
908
+ * - The color in RGB format to use for
909
+ * display purposes.
910
+ */
911
+ color: Uint8ClampedArray;
912
+ dest: string | Array<any> | null;
913
+ url: string | null;
914
+ unsafeUrl: string | undefined;
915
+ newWindow: boolean | undefined;
916
+ count: number | undefined;
917
+ items: any[];
918
+ }[]>;
919
+ /**
920
+ * @returns {Promise<OptionalContentConfig>} A promise that is resolved with
921
+ * an {@link OptionalContentConfig} that contains all the optional content
922
+ * groups (assuming that the document has any).
923
+ */
924
+ getOptionalContentConfig(): Promise<OptionalContentConfig>;
925
+ /**
926
+ * @returns {Promise<Array<number> | null>} A promise that is resolved with
927
+ * an {Array} that contains the permission flags for the PDF document, or
928
+ * `null` when no permissions are present in the PDF file.
929
+ */
930
+ getPermissions(): Promise<Array<number> | null>;
931
+ /**
932
+ * @returns {Promise<{ info: Object, metadata: Metadata }>} A promise that is
933
+ * resolved with an {Object} that has `info` and `metadata` properties.
934
+ * `info` is an {Object} filled with anything available in the information
935
+ * dictionary and similarly `metadata` is a {Metadata} object with
936
+ * information from the metadata section of the PDF.
937
+ */
938
+ getMetadata(): Promise<{
939
+ info: Object;
940
+ metadata: Metadata;
941
+ }>;
942
+ /**
943
+ * @typedef {Object} MarkInfo
944
+ * Properties correspond to Table 321 of the PDF 32000-1:2008 spec.
945
+ * @property {boolean} Marked
946
+ * @property {boolean} UserProperties
947
+ * @property {boolean} Suspects
948
+ */
949
+ /**
950
+ * @returns {Promise<MarkInfo | null>} A promise that is resolved with
951
+ * a {MarkInfo} object that contains the MarkInfo flags for the PDF
952
+ * document, or `null` when no MarkInfo values are present in the PDF file.
953
+ */
954
+ getMarkInfo(): Promise<{
955
+ Marked: boolean;
956
+ UserProperties: boolean;
957
+ Suspects: boolean;
958
+ } | null>;
959
+ /**
960
+ * @returns {Promise<Uint8Array>} A promise that is resolved with a
961
+ * {Uint8Array} containing the raw data of the PDF document.
962
+ */
963
+ getData(): Promise<Uint8Array>;
964
+ /**
965
+ * @returns {Promise<Uint8Array>} A promise that is resolved with a
966
+ * {Uint8Array} containing the full data of the saved document.
967
+ */
968
+ saveDocument(): Promise<Uint8Array>;
969
+ /**
970
+ * @returns {Promise<{ length: number }>} A promise that is resolved when the
971
+ * document's data is loaded. It is resolved with an {Object} that contains
972
+ * the `length` property that indicates size of the PDF data in bytes.
973
+ */
974
+ getDownloadInfo(): Promise<{
975
+ length: number;
976
+ }>;
977
+ /**
978
+ * Cleans up resources allocated by the document on both the main and worker
979
+ * threads.
980
+ *
981
+ * NOTE: Do not, under any circumstances, call this method when rendering is
982
+ * currently ongoing since that may lead to rendering errors.
983
+ *
984
+ * @param {boolean} [keepLoadedFonts] - Let fonts remain attached to the DOM.
985
+ * NOTE: This will increase persistent memory usage, hence don't use this
986
+ * option unless absolutely necessary. The default value is `false`.
987
+ * @returns {Promise} A promise that is resolved when clean-up has finished.
988
+ */
989
+ cleanup(keepLoadedFonts?: boolean | undefined): Promise<any>;
990
+ /**
991
+ * Destroys the current document instance and terminates the worker.
992
+ */
993
+ destroy(): Promise<void>;
994
+ /**
995
+ * @type {DocumentInitParameters} A subset of the current
996
+ * {DocumentInitParameters}, which are needed in the viewer.
997
+ */
998
+ get loadingParams(): DocumentInitParameters;
999
+ /**
1000
+ * @type {PDFDocumentLoadingTask} The loadingTask for the current document.
1001
+ */
1002
+ get loadingTask(): PDFDocumentLoadingTask;
1003
+ /**
1004
+ * @returns {Promise<Object<string, Array<Object>> | null>} A promise that is
1005
+ * resolved with an {Object} containing /AcroForm field data for the JS
1006
+ * sandbox, or `null` when no field data is present in the PDF file.
1007
+ */
1008
+ getFieldObjects(): Promise<{
1009
+ [x: string]: Array<Object>;
1010
+ } | null>;
1011
+ /**
1012
+ * @returns {Promise<boolean>} A promise that is resolved with `true`
1013
+ * if some /AcroForm fields have JavaScript actions.
1014
+ */
1015
+ hasJSActions(): Promise<boolean>;
1016
+ /**
1017
+ * @returns {Promise<Array<string> | null>} A promise that is resolved with an
1018
+ * {Array<string>} containing IDs of annotations that have a calculation
1019
+ * action, or `null` when no such annotations are present in the PDF file.
1020
+ */
1021
+ getCalculationOrderIds(): Promise<Array<string> | null>;
1022
+ }
1023
+ /**
1024
+ * Page getViewport parameters.
1025
+ *
1026
+ * @typedef {Object} GetViewportParameters
1027
+ * @property {number} scale - The desired scale of the viewport.
1028
+ * @property {number} [rotation] - The desired rotation, in degrees, of
1029
+ * the viewport. If omitted it defaults to the page rotation.
1030
+ * @property {number} [offsetX] - The horizontal, i.e. x-axis, offset.
1031
+ * The default value is `0`.
1032
+ * @property {number} [offsetY] - The vertical, i.e. y-axis, offset.
1033
+ * The default value is `0`.
1034
+ * @property {boolean} [dontFlip] - If true, the y-axis will not be
1035
+ * flipped. The default value is `false`.
1036
+ */
1037
+ /**
1038
+ * Page getTextContent parameters.
1039
+ *
1040
+ * @typedef {Object} getTextContentParameters
1041
+ * @property {boolean} [includeMarkedContent] - When true include marked
1042
+ * content items in the items array of TextContent. The default is `false`.
1043
+ * @property {boolean} [disableNormalization] - When true the text is *not*
1044
+ * normalized in the worker-thread. The default is `false`.
1045
+ */
1046
+ /**
1047
+ * Page text content.
1048
+ *
1049
+ * @typedef {Object} TextContent
1050
+ * @property {Array<TextItem | TextMarkedContent>} items - Array of
1051
+ * {@link TextItem} and {@link TextMarkedContent} objects. TextMarkedContent
1052
+ * items are included when includeMarkedContent is true.
1053
+ * @property {Object<string, TextStyle>} styles - {@link TextStyle} objects,
1054
+ * indexed by font name.
1055
+ */
1056
+ /**
1057
+ * Page text content part.
1058
+ *
1059
+ * @typedef {Object} TextItem
1060
+ * @property {string} str - Text content.
1061
+ * @property {string} dir - Text direction: 'ttb', 'ltr' or 'rtl'.
1062
+ * @property {Array<any>} transform - Transformation matrix.
1063
+ * @property {number} width - Width in device space.
1064
+ * @property {number} height - Height in device space.
1065
+ * @property {string} fontName - Font name used by PDF.js for converted font.
1066
+ * @property {boolean} hasEOL - Indicating if the text content is followed by a
1067
+ * line-break.
1068
+ */
1069
+ /**
1070
+ * Page text marked content part.
1071
+ *
1072
+ * @typedef {Object} TextMarkedContent
1073
+ * @property {string} type - Either 'beginMarkedContent',
1074
+ * 'beginMarkedContentProps', or 'endMarkedContent'.
1075
+ * @property {string} id - The marked content identifier. Only used for type
1076
+ * 'beginMarkedContentProps'.
1077
+ */
1078
+ /**
1079
+ * Text style.
1080
+ *
1081
+ * @typedef {Object} TextStyle
1082
+ * @property {number} ascent - Font ascent.
1083
+ * @property {number} descent - Font descent.
1084
+ * @property {boolean} vertical - Whether or not the text is in vertical mode.
1085
+ * @property {string} fontFamily - The possible font family.
1086
+ */
1087
+ /**
1088
+ * Page annotation parameters.
1089
+ *
1090
+ * @typedef {Object} GetAnnotationsParameters
1091
+ * @property {string} [intent] - Determines the annotations that are fetched,
1092
+ * can be 'display' (viewable annotations), 'print' (printable annotations),
1093
+ * or 'any' (all annotations). The default value is 'display'.
1094
+ */
1095
+ /**
1096
+ * Page render parameters.
1097
+ *
1098
+ * @typedef {Object} RenderParameters
1099
+ * @property {CanvasRenderingContext2D} canvasContext - A 2D context of a DOM
1100
+ * Canvas object.
1101
+ * @property {PageViewport} viewport - Rendering viewport obtained by calling
1102
+ * the `PDFPageProxy.getViewport` method.
1103
+ * @property {string} [intent] - Rendering intent, can be 'display', 'print',
1104
+ * or 'any'. The default value is 'display'.
1105
+ * @property {number} [annotationMode] Controls which annotations are rendered
1106
+ * onto the canvas, for annotations with appearance-data; the values from
1107
+ * {@link AnnotationMode} should be used. The following values are supported:
1108
+ * - `AnnotationMode.DISABLE`, which disables all annotations.
1109
+ * - `AnnotationMode.ENABLE`, which includes all possible annotations (thus
1110
+ * it also depends on the `intent`-option, see above).
1111
+ * - `AnnotationMode.ENABLE_FORMS`, which excludes annotations that contain
1112
+ * interactive form elements (those will be rendered in the display layer).
1113
+ * - `AnnotationMode.ENABLE_STORAGE`, which includes all possible annotations
1114
+ * (as above) but where interactive form elements are updated with data
1115
+ * from the {@link AnnotationStorage}-instance; useful e.g. for printing.
1116
+ * The default value is `AnnotationMode.ENABLE`.
1117
+ * @property {Array<any>} [transform] - Additional transform, applied just
1118
+ * before viewport transform.
1119
+ * @property {CanvasGradient | CanvasPattern | string} [background] - Background
1120
+ * to use for the canvas.
1121
+ * Any valid `canvas.fillStyle` can be used: a `DOMString` parsed as CSS
1122
+ * <color> value, a `CanvasGradient` object (a linear or radial gradient) or
1123
+ * a `CanvasPattern` object (a repetitive image). The default value is
1124
+ * 'rgb(255,255,255)'.
1125
+ *
1126
+ * NOTE: This option may be partially, or completely, ignored when the
1127
+ * `pageColors`-option is used.
1128
+ * @property {Object} [pageColors] - Overwrites background and foreground colors
1129
+ * with user defined ones in order to improve readability in high contrast
1130
+ * mode.
1131
+ * @property {Promise<OptionalContentConfig>} [optionalContentConfigPromise] -
1132
+ * A promise that should resolve with an {@link OptionalContentConfig}
1133
+ * created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,
1134
+ * the configuration will be fetched automatically with the default visibility
1135
+ * states set.
1136
+ * @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap] - Map some
1137
+ * annotation ids with canvases used to render them.
1138
+ * @property {PrintAnnotationStorage} [printAnnotationStorage]
1139
+ */
1140
+ /**
1141
+ * Page getOperatorList parameters.
1142
+ *
1143
+ * @typedef {Object} GetOperatorListParameters
1144
+ * @property {string} [intent] - Rendering intent, can be 'display', 'print',
1145
+ * or 'any'. The default value is 'display'.
1146
+ * @property {number} [annotationMode] Controls which annotations are included
1147
+ * in the operatorList, for annotations with appearance-data; the values from
1148
+ * {@link AnnotationMode} should be used. The following values are supported:
1149
+ * - `AnnotationMode.DISABLE`, which disables all annotations.
1150
+ * - `AnnotationMode.ENABLE`, which includes all possible annotations (thus
1151
+ * it also depends on the `intent`-option, see above).
1152
+ * - `AnnotationMode.ENABLE_FORMS`, which excludes annotations that contain
1153
+ * interactive form elements (those will be rendered in the display layer).
1154
+ * - `AnnotationMode.ENABLE_STORAGE`, which includes all possible annotations
1155
+ * (as above) but where interactive form elements are updated with data
1156
+ * from the {@link AnnotationStorage}-instance; useful e.g. for printing.
1157
+ * The default value is `AnnotationMode.ENABLE`.
1158
+ * @property {PrintAnnotationStorage} [printAnnotationStorage]
1159
+ */
1160
+ /**
1161
+ * Structure tree node. The root node will have a role "Root".
1162
+ *
1163
+ * @typedef {Object} StructTreeNode
1164
+ * @property {Array<StructTreeNode | StructTreeContent>} children - Array of
1165
+ * {@link StructTreeNode} and {@link StructTreeContent} objects.
1166
+ * @property {string} role - element's role, already mapped if a role map exists
1167
+ * in the PDF.
1168
+ */
1169
+ /**
1170
+ * Structure tree content.
1171
+ *
1172
+ * @typedef {Object} StructTreeContent
1173
+ * @property {string} type - either "content" for page and stream structure
1174
+ * elements or "object" for object references.
1175
+ * @property {string} id - unique id that will map to the text layer.
1176
+ */
1177
+ /**
1178
+ * PDF page operator list.
1179
+ *
1180
+ * @typedef {Object} PDFOperatorList
1181
+ * @property {Array<number>} fnArray - Array containing the operator functions.
1182
+ * @property {Array<any>} argsArray - Array containing the arguments of the
1183
+ * functions.
1184
+ */
1185
+ /**
1186
+ * Proxy to a `PDFPage` in the worker thread.
1187
+ */
1188
+ export class PDFPageProxy {
1189
+ constructor(pageIndex: any, pageInfo: any, transport: any, pdfBug?: boolean);
1190
+ _pageIndex: any;
1191
+ _pageInfo: any;
1192
+ _transport: any;
1193
+ _stats: StatTimer | null;
1194
+ _pdfBug: boolean;
1195
+ /** @type {PDFObjects} */
1196
+ commonObjs: PDFObjects;
1197
+ objs: PDFObjects;
1198
+ _maybeCleanupAfterRender: boolean;
1199
+ _intentStates: Map<any, any>;
1200
+ destroyed: boolean;
1201
+ /**
1202
+ * @type {number} Page number of the page. First page is 1.
1203
+ */
1204
+ get pageNumber(): number;
1205
+ /**
1206
+ * @type {number} The number of degrees the page is rotated clockwise.
1207
+ */
1208
+ get rotate(): number;
1209
+ /**
1210
+ * @type {RefProxy | null} The reference that points to this page.
1211
+ */
1212
+ get ref(): RefProxy | null;
1213
+ /**
1214
+ * @type {number} The default size of units in 1/72nds of an inch.
1215
+ */
1216
+ get userUnit(): number;
1217
+ /**
1218
+ * @type {Array<number>} An array of the visible portion of the PDF page in
1219
+ * user space units [x1, y1, x2, y2].
1220
+ */
1221
+ get view(): number[];
1222
+ /**
1223
+ * @param {GetViewportParameters} params - Viewport parameters.
1224
+ * @returns {PageViewport} Contains 'width' and 'height' properties
1225
+ * along with transforms required for rendering.
1226
+ */
1227
+ getViewport({ scale, rotation, offsetX, offsetY, dontFlip, }?: GetViewportParameters): PageViewport;
1228
+ /**
1229
+ * @param {GetAnnotationsParameters} params - Annotation parameters.
1230
+ * @returns {Promise<Array<any>>} A promise that is resolved with an
1231
+ * {Array} of the annotation objects.
1232
+ */
1233
+ getAnnotations({ intent }?: GetAnnotationsParameters): Promise<Array<any>>;
1234
+ /**
1235
+ * @returns {Promise<Object>} A promise that is resolved with an
1236
+ * {Object} with JS actions.
1237
+ */
1238
+ getJSActions(): Promise<Object>;
1239
+ /**
1240
+ * @type {Object} The filter factory instance.
1241
+ */
1242
+ get filterFactory(): Object;
1243
+ /**
1244
+ * @type {boolean} True if only XFA form.
1245
+ */
1246
+ get isPureXfa(): boolean;
1247
+ /**
1248
+ * @returns {Promise<Object | null>} A promise that is resolved with
1249
+ * an {Object} with a fake DOM object (a tree structure where elements
1250
+ * are {Object} with a name, attributes (class, style, ...), value and
1251
+ * children, very similar to a HTML DOM tree), or `null` if no XFA exists.
1252
+ */
1253
+ getXfa(): Promise<Object | null>;
1254
+ /**
1255
+ * Begins the process of rendering a page to the desired context.
1256
+ *
1257
+ * @param {RenderParameters} params - Page render parameters.
1258
+ * @returns {RenderTask} An object that contains a promise that is
1259
+ * resolved when the page finishes rendering.
1260
+ */
1261
+ render({ canvasContext, viewport, intent, annotationMode, transform, background, optionalContentConfigPromise, annotationCanvasMap, pageColors, printAnnotationStorage, }: RenderParameters): RenderTask;
1262
+ /**
1263
+ * @param {GetOperatorListParameters} params - Page getOperatorList
1264
+ * parameters.
1265
+ * @returns {Promise<PDFOperatorList>} A promise resolved with an
1266
+ * {@link PDFOperatorList} object that represents the page's operator list.
1267
+ */
1268
+ getOperatorList({ intent, annotationMode, printAnnotationStorage, }?: GetOperatorListParameters): Promise<PDFOperatorList>;
1269
+ /**
1270
+ * NOTE: All occurrences of whitespace will be replaced by
1271
+ * standard spaces (0x20).
1272
+ *
1273
+ * @param {getTextContentParameters} params - getTextContent parameters.
1274
+ * @returns {ReadableStream} Stream for reading text content chunks.
1275
+ */
1276
+ streamTextContent({ includeMarkedContent, disableNormalization, }?: getTextContentParameters): ReadableStream;
1277
+ /**
1278
+ * NOTE: All occurrences of whitespace will be replaced by
1279
+ * standard spaces (0x20).
1280
+ *
1281
+ * @param {getTextContentParameters} params - getTextContent parameters.
1282
+ * @returns {Promise<TextContent>} A promise that is resolved with a
1283
+ * {@link TextContent} object that represents the page's text content.
1284
+ */
1285
+ getTextContent(params?: getTextContentParameters): Promise<TextContent>;
1286
+ /**
1287
+ * @returns {Promise<StructTreeNode>} A promise that is resolved with a
1288
+ * {@link StructTreeNode} object that represents the page's structure tree,
1289
+ * or `null` when no structure tree is present for the current page.
1290
+ */
1291
+ getStructTree(): Promise<StructTreeNode>;
1292
+ /**
1293
+ * Destroys the page object.
1294
+ * @private
1295
+ */
1296
+ private _destroy;
1297
+ /**
1298
+ * Cleans up resources allocated by the page.
1299
+ *
1300
+ * @param {boolean} [resetStats] - Reset page stats, if enabled.
1301
+ * The default value is `false`.
1302
+ * @returns {boolean} Indicates if clean-up was successfully run.
1303
+ */
1304
+ cleanup(resetStats?: boolean | undefined): boolean;
1305
+ /**
1306
+ * @private
1307
+ */
1308
+ private _startRenderPage;
1309
+ /**
1310
+ * @private
1311
+ */
1312
+ private _renderPageChunk;
1313
+ /**
1314
+ * @private
1315
+ */
1316
+ private _pumpOperatorList;
1317
+ /**
1318
+ * @private
1319
+ */
1320
+ private _abortOperatorList;
1321
+ /**
1322
+ * @type {StatTimer | null} Returns page stats, if enabled; returns `null`
1323
+ * otherwise.
1324
+ */
1325
+ get stats(): StatTimer | null;
1326
+ #private;
1327
+ }
1328
+ /**
1329
+ * PDF.js web worker abstraction that controls the instantiation of PDF
1330
+ * documents. Message handlers are used to pass information from the main
1331
+ * thread to the worker thread and vice versa. If the creation of a web
1332
+ * worker is not possible, a "fake" worker will be used instead.
1333
+ *
1334
+ * @param {PDFWorkerParameters} params - The worker initialization parameters.
1335
+ */
1336
+ export class PDFWorker {
1337
+ static "__#35@#workerPorts": any;
1338
+ /**
1339
+ * @param {PDFWorkerParameters} params - The worker initialization parameters.
1340
+ */
1341
+ static fromPort(params: PDFWorkerParameters): any;
1342
+ /**
1343
+ * The current `workerSrc`, when it exists.
1344
+ * @type {string}
1345
+ */
1346
+ static get workerSrc(): string;
1347
+ static get _mainThreadWorkerMessageHandler(): any;
1348
+ static get _setupFakeWorkerGlobal(): any;
1349
+ constructor({ name, port, verbosity, }?: {
1350
+ name?: null | undefined;
1351
+ port?: null | undefined;
1352
+ verbosity?: number | undefined;
1353
+ });
1354
+ name: any;
1355
+ destroyed: boolean;
1356
+ verbosity: number;
1357
+ _readyCapability: PromiseCapability;
1358
+ _port: any;
1359
+ _webWorker: Worker | null;
1360
+ _messageHandler: MessageHandler | null;
1361
+ /**
1362
+ * Promise for worker initialization completion.
1363
+ * @type {Promise<void>}
1364
+ */
1365
+ get promise(): Promise<void>;
1366
+ /**
1367
+ * The current `workerPort`, when it exists.
1368
+ * @type {Worker}
1369
+ */
1370
+ get port(): Worker;
1371
+ /**
1372
+ * The current MessageHandler-instance.
1373
+ * @type {MessageHandler}
1374
+ */
1375
+ get messageHandler(): MessageHandler;
1376
+ _initializeFromPort(port: any): void;
1377
+ _initialize(): void;
1378
+ _setupFakeWorker(): void;
1379
+ /**
1380
+ * Destroys the worker instance.
1381
+ */
1382
+ destroy(): void;
1383
+ }
1384
+ export namespace PDFWorkerUtil {
1385
+ let isWorkerDisabled: boolean;
1386
+ let fallbackWorkerSrc: null;
1387
+ let fakeWorkerId: number;
1388
+ }
1389
+ /**
1390
+ * Allows controlling of the rendering tasks.
1391
+ */
1392
+ export class RenderTask {
1393
+ constructor(internalRenderTask: any);
1394
+ /**
1395
+ * Callback for incremental rendering -- a function that will be called
1396
+ * each time the rendering is paused. To continue rendering call the
1397
+ * function that is the first argument to the callback.
1398
+ * @type {function}
1399
+ */
1400
+ onContinue: Function;
1401
+ /**
1402
+ * Promise for rendering task completion.
1403
+ * @type {Promise<void>}
1404
+ */
1405
+ get promise(): Promise<void>;
1406
+ /**
1407
+ * Cancels the rendering task. If the task is currently rendering it will
1408
+ * not be cancelled until graphics pauses with a timeout. The promise that
1409
+ * this object extends will be rejected when cancelled.
1410
+ *
1411
+ * @param {number} [extraDelay]
1412
+ */
1413
+ cancel(extraDelay?: number | undefined): void;
1414
+ /**
1415
+ * Whether form fields are rendered separately from the main operatorList.
1416
+ * @type {boolean}
1417
+ */
1418
+ get separateAnnots(): boolean;
1419
+ #private;
1420
+ }
1421
+ /** @type {string} */
1422
+ export const version: string;
1423
+ import { PageViewport } from "./display_utils.js";
1424
+ import { OptionalContentConfig } from "./optional_content_config.js";
1425
+ import { PrintAnnotationStorage } from "./annotation_storage.js";
1426
+ import { PromiseCapability } from "../shared/util.js";
1427
+ import { AnnotationStorage } from "./annotation_storage.js";
1428
+ import { info } from "../shared/util.js";
1429
+ import { Metadata } from "./metadata.js";
1430
+ import { StatTimer } from "./display_utils.js";
1431
+ /**
1432
+ * A PDF document and page is built of many objects. E.g. there are objects for
1433
+ * fonts, images, rendering code, etc. These objects may get processed inside of
1434
+ * a worker. This class implements some basic methods to manage these objects.
1435
+ */
1436
+ declare class PDFObjects {
1437
+ /**
1438
+ * If called *without* callback, this returns the data of `objId` but the
1439
+ * object needs to be resolved. If it isn't, this method throws.
1440
+ *
1441
+ * If called *with* a callback, the callback is called with the data of the
1442
+ * object once the object is resolved. That means, if you call this method
1443
+ * and the object is already resolved, the callback gets called right away.
1444
+ *
1445
+ * @param {string} objId
1446
+ * @param {function} [callback]
1447
+ * @returns {any}
1448
+ */
1449
+ get(objId: string, callback?: Function | undefined): any;
1450
+ /**
1451
+ * @param {string} objId
1452
+ * @returns {boolean}
1453
+ */
1454
+ has(objId: string): boolean;
1455
+ /**
1456
+ * Resolves the object `objId` with optional `data`.
1457
+ *
1458
+ * @param {string} objId
1459
+ * @param {any} [data]
1460
+ */
1461
+ resolve(objId: string, data?: any): void;
1462
+ clear(): void;
1463
+ #private;
1464
+ }
1465
+ import { MessageHandler } from "../shared/message_handler.js";
1466
+ export { SVGGraphics };