pdfjs-serverless 0.1.0 → 0.2.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 (59) hide show
  1. package/README.md +11 -8
  2. package/dist/index.d.ts +1 -1
  3. package/dist/types/external/webL10n/l10n.d.ts +0 -0
  4. package/dist/types/src/display/annotation_layer.d.ts +203 -0
  5. package/dist/types/src/display/annotation_storage.d.ts +89 -0
  6. package/dist/types/src/display/api.d.ts +1472 -0
  7. package/dist/types/src/display/base_factory.d.ts +54 -0
  8. package/dist/types/src/display/canvas.d.ts +208 -0
  9. package/dist/types/src/display/display_utils.d.ts +277 -0
  10. package/dist/types/src/display/editor/annotation_editor_layer.d.ts +182 -0
  11. package/dist/types/src/display/editor/editor.d.ts +308 -0
  12. package/dist/types/src/display/editor/freetext.d.ts +72 -0
  13. package/dist/types/src/display/editor/ink.d.ts +95 -0
  14. package/dist/types/src/display/editor/stamp.d.ts +22 -0
  15. package/dist/types/src/display/editor/tools.d.ts +324 -0
  16. package/dist/types/src/display/font_loader.d.ts +43 -0
  17. package/dist/types/src/display/metadata.d.ts +11 -0
  18. package/dist/types/src/display/optional_content_config.d.ts +13 -0
  19. package/dist/types/src/display/pattern_helper.d.ts +73 -0
  20. package/dist/types/src/display/text_layer.d.ts +151 -0
  21. package/dist/types/src/display/transport_stream.d.ts +68 -0
  22. package/dist/types/src/display/worker_options.d.ts +27 -0
  23. package/dist/types/src/display/xfa_layer.d.ts +46 -0
  24. package/dist/types/src/display/xfa_text.d.ts +19 -0
  25. package/dist/types/src/pdf.d.ts +50 -0
  26. package/dist/types/src/shared/image_utils.d.ts +17 -0
  27. package/dist/types/src/shared/message_handler.d.ts +43 -0
  28. package/dist/types/src/shared/murmurhash3.d.ts +7 -0
  29. package/dist/types/src/shared/scripting_utils.d.ts +12 -0
  30. package/dist/types/src/shared/util.d.ts +396 -0
  31. package/dist/types/web/annotation_editor_layer_builder.d.ts +50 -0
  32. package/dist/types/web/annotation_layer_builder.d.ts +83 -0
  33. package/dist/types/web/app_options.d.ts +14 -0
  34. package/dist/types/web/download_manager.d.ts +14 -0
  35. package/dist/types/web/event_utils.d.ts +75 -0
  36. package/dist/types/web/generic_scripting.d.ts +8 -0
  37. package/dist/types/web/genericl10n.d.ts +13 -0
  38. package/dist/types/web/interfaces.d.ts +163 -0
  39. package/dist/types/web/l10n_utils.d.ts +7 -0
  40. package/dist/types/web/pdf_find_controller.d.ts +108 -0
  41. package/dist/types/web/pdf_find_utils.d.ts +16 -0
  42. package/dist/types/web/pdf_history.d.ts +168 -0
  43. package/dist/types/web/pdf_link_service.d.ts +243 -0
  44. package/dist/types/web/pdf_page_view.d.ts +209 -0
  45. package/dist/types/web/pdf_rendering_queue.d.ts +53 -0
  46. package/dist/types/web/pdf_scripting_manager.component.d.ts +5 -0
  47. package/dist/types/web/pdf_scripting_manager.d.ts +61 -0
  48. package/dist/types/web/pdf_single_page_viewer.d.ts +7 -0
  49. package/dist/types/web/pdf_thumbnail_view.d.ts +131 -0
  50. package/dist/types/web/pdf_thumbnail_viewer.d.ts +104 -0
  51. package/dist/types/web/pdf_viewer.component.d.ts +24 -0
  52. package/dist/types/web/pdf_viewer.d.ts +455 -0
  53. package/dist/types/web/struct_tree_layer_builder.d.ts +7 -0
  54. package/dist/types/web/text_accessibility.d.ts +42 -0
  55. package/dist/types/web/text_highlighter.d.ts +63 -0
  56. package/dist/types/web/text_layer_builder.d.ts +64 -0
  57. package/dist/types/web/ui_utils.d.ts +288 -0
  58. package/dist/types/web/xfa_layer_builder.d.ts +41 -0
  59. package/package.json +6 -7
@@ -0,0 +1,1472 @@
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<Array<string> | null>} A promise that is resolved with
879
+ * an {Array} of all the JavaScript strings in the name tree, or `null`
880
+ * if no JavaScript exists.
881
+ */
882
+ getJavaScript(): Promise<Array<string> | null>;
883
+ /**
884
+ * @returns {Promise<Object | null>} A promise that is resolved with
885
+ * an {Object} with the JavaScript actions:
886
+ * - from the name tree (like getJavaScript);
887
+ * - from A or AA entries in the catalog dictionary.
888
+ * , or `null` if no JavaScript exists.
889
+ */
890
+ getJSActions(): Promise<Object | null>;
891
+ /**
892
+ * @typedef {Object} OutlineNode
893
+ * @property {string} title
894
+ * @property {boolean} bold
895
+ * @property {boolean} italic
896
+ * @property {Uint8ClampedArray} color - The color in RGB format to use for
897
+ * display purposes.
898
+ * @property {string | Array<any> | null} dest
899
+ * @property {string | null} url
900
+ * @property {string | undefined} unsafeUrl
901
+ * @property {boolean | undefined} newWindow
902
+ * @property {number | undefined} count
903
+ * @property {Array<OutlineNode>} items
904
+ */
905
+ /**
906
+ * @returns {Promise<Array<OutlineNode>>} A promise that is resolved with an
907
+ * {Array} that is a tree outline (if it has one) of the PDF file.
908
+ */
909
+ getOutline(): Promise<{
910
+ title: string;
911
+ bold: boolean;
912
+ italic: boolean;
913
+ /**
914
+ * - The color in RGB format to use for
915
+ * display purposes.
916
+ */
917
+ color: Uint8ClampedArray;
918
+ dest: string | Array<any> | null;
919
+ url: string | null;
920
+ unsafeUrl: string | undefined;
921
+ newWindow: boolean | undefined;
922
+ count: number | undefined;
923
+ items: any[];
924
+ }[]>;
925
+ /**
926
+ * @returns {Promise<OptionalContentConfig>} A promise that is resolved with
927
+ * an {@link OptionalContentConfig} that contains all the optional content
928
+ * groups (assuming that the document has any).
929
+ */
930
+ getOptionalContentConfig(): Promise<OptionalContentConfig>;
931
+ /**
932
+ * @returns {Promise<Array<number> | null>} A promise that is resolved with
933
+ * an {Array} that contains the permission flags for the PDF document, or
934
+ * `null` when no permissions are present in the PDF file.
935
+ */
936
+ getPermissions(): Promise<Array<number> | null>;
937
+ /**
938
+ * @returns {Promise<{ info: Object, metadata: Metadata }>} A promise that is
939
+ * resolved with an {Object} that has `info` and `metadata` properties.
940
+ * `info` is an {Object} filled with anything available in the information
941
+ * dictionary and similarly `metadata` is a {Metadata} object with
942
+ * information from the metadata section of the PDF.
943
+ */
944
+ getMetadata(): Promise<{
945
+ info: Object;
946
+ metadata: Metadata;
947
+ }>;
948
+ /**
949
+ * @typedef {Object} MarkInfo
950
+ * Properties correspond to Table 321 of the PDF 32000-1:2008 spec.
951
+ * @property {boolean} Marked
952
+ * @property {boolean} UserProperties
953
+ * @property {boolean} Suspects
954
+ */
955
+ /**
956
+ * @returns {Promise<MarkInfo | null>} A promise that is resolved with
957
+ * a {MarkInfo} object that contains the MarkInfo flags for the PDF
958
+ * document, or `null` when no MarkInfo values are present in the PDF file.
959
+ */
960
+ getMarkInfo(): Promise<{
961
+ Marked: boolean;
962
+ UserProperties: boolean;
963
+ Suspects: boolean;
964
+ } | null>;
965
+ /**
966
+ * @returns {Promise<Uint8Array>} A promise that is resolved with a
967
+ * {Uint8Array} containing the raw data of the PDF document.
968
+ */
969
+ getData(): Promise<Uint8Array>;
970
+ /**
971
+ * @returns {Promise<Uint8Array>} A promise that is resolved with a
972
+ * {Uint8Array} containing the full data of the saved document.
973
+ */
974
+ saveDocument(): Promise<Uint8Array>;
975
+ /**
976
+ * @returns {Promise<{ length: number }>} A promise that is resolved when the
977
+ * document's data is loaded. It is resolved with an {Object} that contains
978
+ * the `length` property that indicates size of the PDF data in bytes.
979
+ */
980
+ getDownloadInfo(): Promise<{
981
+ length: number;
982
+ }>;
983
+ /**
984
+ * Cleans up resources allocated by the document on both the main and worker
985
+ * threads.
986
+ *
987
+ * NOTE: Do not, under any circumstances, call this method when rendering is
988
+ * currently ongoing since that may lead to rendering errors.
989
+ *
990
+ * @param {boolean} [keepLoadedFonts] - Let fonts remain attached to the DOM.
991
+ * NOTE: This will increase persistent memory usage, hence don't use this
992
+ * option unless absolutely necessary. The default value is `false`.
993
+ * @returns {Promise} A promise that is resolved when clean-up has finished.
994
+ */
995
+ cleanup(keepLoadedFonts?: boolean | undefined): Promise<any>;
996
+ /**
997
+ * Destroys the current document instance and terminates the worker.
998
+ */
999
+ destroy(): Promise<void>;
1000
+ /**
1001
+ * @type {DocumentInitParameters} A subset of the current
1002
+ * {DocumentInitParameters}, which are needed in the viewer.
1003
+ */
1004
+ get loadingParams(): DocumentInitParameters;
1005
+ /**
1006
+ * @type {PDFDocumentLoadingTask} The loadingTask for the current document.
1007
+ */
1008
+ get loadingTask(): PDFDocumentLoadingTask;
1009
+ /**
1010
+ * @returns {Promise<Object<string, Array<Object>> | null>} A promise that is
1011
+ * resolved with an {Object} containing /AcroForm field data for the JS
1012
+ * sandbox, or `null` when no field data is present in the PDF file.
1013
+ */
1014
+ getFieldObjects(): Promise<{
1015
+ [x: string]: Array<Object>;
1016
+ } | null>;
1017
+ /**
1018
+ * @returns {Promise<boolean>} A promise that is resolved with `true`
1019
+ * if some /AcroForm fields have JavaScript actions.
1020
+ */
1021
+ hasJSActions(): Promise<boolean>;
1022
+ /**
1023
+ * @returns {Promise<Array<string> | null>} A promise that is resolved with an
1024
+ * {Array<string>} containing IDs of annotations that have a calculation
1025
+ * action, or `null` when no such annotations are present in the PDF file.
1026
+ */
1027
+ getCalculationOrderIds(): Promise<Array<string> | null>;
1028
+ }
1029
+ /**
1030
+ * Page getViewport parameters.
1031
+ *
1032
+ * @typedef {Object} GetViewportParameters
1033
+ * @property {number} scale - The desired scale of the viewport.
1034
+ * @property {number} [rotation] - The desired rotation, in degrees, of
1035
+ * the viewport. If omitted it defaults to the page rotation.
1036
+ * @property {number} [offsetX] - The horizontal, i.e. x-axis, offset.
1037
+ * The default value is `0`.
1038
+ * @property {number} [offsetY] - The vertical, i.e. y-axis, offset.
1039
+ * The default value is `0`.
1040
+ * @property {boolean} [dontFlip] - If true, the y-axis will not be
1041
+ * flipped. The default value is `false`.
1042
+ */
1043
+ /**
1044
+ * Page getTextContent parameters.
1045
+ *
1046
+ * @typedef {Object} getTextContentParameters
1047
+ * @property {boolean} [includeMarkedContent] - When true include marked
1048
+ * content items in the items array of TextContent. The default is `false`.
1049
+ * @property {boolean} [disableNormalization] - When true the text is *not*
1050
+ * normalized in the worker-thread. The default is `false`.
1051
+ */
1052
+ /**
1053
+ * Page text content.
1054
+ *
1055
+ * @typedef {Object} TextContent
1056
+ * @property {Array<TextItem | TextMarkedContent>} items - Array of
1057
+ * {@link TextItem} and {@link TextMarkedContent} objects. TextMarkedContent
1058
+ * items are included when includeMarkedContent is true.
1059
+ * @property {Object<string, TextStyle>} styles - {@link TextStyle} objects,
1060
+ * indexed by font name.
1061
+ */
1062
+ /**
1063
+ * Page text content part.
1064
+ *
1065
+ * @typedef {Object} TextItem
1066
+ * @property {string} str - Text content.
1067
+ * @property {string} dir - Text direction: 'ttb', 'ltr' or 'rtl'.
1068
+ * @property {Array<any>} transform - Transformation matrix.
1069
+ * @property {number} width - Width in device space.
1070
+ * @property {number} height - Height in device space.
1071
+ * @property {string} fontName - Font name used by PDF.js for converted font.
1072
+ * @property {boolean} hasEOL - Indicating if the text content is followed by a
1073
+ * line-break.
1074
+ */
1075
+ /**
1076
+ * Page text marked content part.
1077
+ *
1078
+ * @typedef {Object} TextMarkedContent
1079
+ * @property {string} type - Either 'beginMarkedContent',
1080
+ * 'beginMarkedContentProps', or 'endMarkedContent'.
1081
+ * @property {string} id - The marked content identifier. Only used for type
1082
+ * 'beginMarkedContentProps'.
1083
+ */
1084
+ /**
1085
+ * Text style.
1086
+ *
1087
+ * @typedef {Object} TextStyle
1088
+ * @property {number} ascent - Font ascent.
1089
+ * @property {number} descent - Font descent.
1090
+ * @property {boolean} vertical - Whether or not the text is in vertical mode.
1091
+ * @property {string} fontFamily - The possible font family.
1092
+ */
1093
+ /**
1094
+ * Page annotation parameters.
1095
+ *
1096
+ * @typedef {Object} GetAnnotationsParameters
1097
+ * @property {string} [intent] - Determines the annotations that are fetched,
1098
+ * can be 'display' (viewable annotations), 'print' (printable annotations),
1099
+ * or 'any' (all annotations). The default value is 'display'.
1100
+ */
1101
+ /**
1102
+ * Page render parameters.
1103
+ *
1104
+ * @typedef {Object} RenderParameters
1105
+ * @property {CanvasRenderingContext2D} canvasContext - A 2D context of a DOM
1106
+ * Canvas object.
1107
+ * @property {PageViewport} viewport - Rendering viewport obtained by calling
1108
+ * the `PDFPageProxy.getViewport` method.
1109
+ * @property {string} [intent] - Rendering intent, can be 'display', 'print',
1110
+ * or 'any'. The default value is 'display'.
1111
+ * @property {number} [annotationMode] Controls which annotations are rendered
1112
+ * onto the canvas, for annotations with appearance-data; the values from
1113
+ * {@link AnnotationMode} should be used. The following values are supported:
1114
+ * - `AnnotationMode.DISABLE`, which disables all annotations.
1115
+ * - `AnnotationMode.ENABLE`, which includes all possible annotations (thus
1116
+ * it also depends on the `intent`-option, see above).
1117
+ * - `AnnotationMode.ENABLE_FORMS`, which excludes annotations that contain
1118
+ * interactive form elements (those will be rendered in the display layer).
1119
+ * - `AnnotationMode.ENABLE_STORAGE`, which includes all possible annotations
1120
+ * (as above) but where interactive form elements are updated with data
1121
+ * from the {@link AnnotationStorage}-instance; useful e.g. for printing.
1122
+ * The default value is `AnnotationMode.ENABLE`.
1123
+ * @property {Array<any>} [transform] - Additional transform, applied just
1124
+ * before viewport transform.
1125
+ * @property {CanvasGradient | CanvasPattern | string} [background] - Background
1126
+ * to use for the canvas.
1127
+ * Any valid `canvas.fillStyle` can be used: a `DOMString` parsed as CSS
1128
+ * <color> value, a `CanvasGradient` object (a linear or radial gradient) or
1129
+ * a `CanvasPattern` object (a repetitive image). The default value is
1130
+ * 'rgb(255,255,255)'.
1131
+ *
1132
+ * NOTE: This option may be partially, or completely, ignored when the
1133
+ * `pageColors`-option is used.
1134
+ * @property {Object} [pageColors] - Overwrites background and foreground colors
1135
+ * with user defined ones in order to improve readability in high contrast
1136
+ * mode.
1137
+ * @property {Promise<OptionalContentConfig>} [optionalContentConfigPromise] -
1138
+ * A promise that should resolve with an {@link OptionalContentConfig}
1139
+ * created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,
1140
+ * the configuration will be fetched automatically with the default visibility
1141
+ * states set.
1142
+ * @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap] - Map some
1143
+ * annotation ids with canvases used to render them.
1144
+ * @property {PrintAnnotationStorage} [printAnnotationStorage]
1145
+ */
1146
+ /**
1147
+ * Page getOperatorList parameters.
1148
+ *
1149
+ * @typedef {Object} GetOperatorListParameters
1150
+ * @property {string} [intent] - Rendering intent, can be 'display', 'print',
1151
+ * or 'any'. The default value is 'display'.
1152
+ * @property {number} [annotationMode] Controls which annotations are included
1153
+ * in the operatorList, for annotations with appearance-data; the values from
1154
+ * {@link AnnotationMode} should be used. The following values are supported:
1155
+ * - `AnnotationMode.DISABLE`, which disables all annotations.
1156
+ * - `AnnotationMode.ENABLE`, which includes all possible annotations (thus
1157
+ * it also depends on the `intent`-option, see above).
1158
+ * - `AnnotationMode.ENABLE_FORMS`, which excludes annotations that contain
1159
+ * interactive form elements (those will be rendered in the display layer).
1160
+ * - `AnnotationMode.ENABLE_STORAGE`, which includes all possible annotations
1161
+ * (as above) but where interactive form elements are updated with data
1162
+ * from the {@link AnnotationStorage}-instance; useful e.g. for printing.
1163
+ * The default value is `AnnotationMode.ENABLE`.
1164
+ * @property {PrintAnnotationStorage} [printAnnotationStorage]
1165
+ */
1166
+ /**
1167
+ * Structure tree node. The root node will have a role "Root".
1168
+ *
1169
+ * @typedef {Object} StructTreeNode
1170
+ * @property {Array<StructTreeNode | StructTreeContent>} children - Array of
1171
+ * {@link StructTreeNode} and {@link StructTreeContent} objects.
1172
+ * @property {string} role - element's role, already mapped if a role map exists
1173
+ * in the PDF.
1174
+ */
1175
+ /**
1176
+ * Structure tree content.
1177
+ *
1178
+ * @typedef {Object} StructTreeContent
1179
+ * @property {string} type - either "content" for page and stream structure
1180
+ * elements or "object" for object references.
1181
+ * @property {string} id - unique id that will map to the text layer.
1182
+ */
1183
+ /**
1184
+ * PDF page operator list.
1185
+ *
1186
+ * @typedef {Object} PDFOperatorList
1187
+ * @property {Array<number>} fnArray - Array containing the operator functions.
1188
+ * @property {Array<any>} argsArray - Array containing the arguments of the
1189
+ * functions.
1190
+ */
1191
+ /**
1192
+ * Proxy to a `PDFPage` in the worker thread.
1193
+ */
1194
+ export class PDFPageProxy {
1195
+ constructor(pageIndex: any, pageInfo: any, transport: any, pdfBug?: boolean);
1196
+ _pageIndex: any;
1197
+ _pageInfo: any;
1198
+ _transport: any;
1199
+ _stats: StatTimer | null;
1200
+ _pdfBug: boolean;
1201
+ /** @type {PDFObjects} */
1202
+ commonObjs: PDFObjects;
1203
+ objs: PDFObjects;
1204
+ _maybeCleanupAfterRender: boolean;
1205
+ _intentStates: Map<any, any>;
1206
+ destroyed: boolean;
1207
+ /**
1208
+ * @type {number} Page number of the page. First page is 1.
1209
+ */
1210
+ get pageNumber(): number;
1211
+ /**
1212
+ * @type {number} The number of degrees the page is rotated clockwise.
1213
+ */
1214
+ get rotate(): number;
1215
+ /**
1216
+ * @type {RefProxy | null} The reference that points to this page.
1217
+ */
1218
+ get ref(): RefProxy | null;
1219
+ /**
1220
+ * @type {number} The default size of units in 1/72nds of an inch.
1221
+ */
1222
+ get userUnit(): number;
1223
+ /**
1224
+ * @type {Array<number>} An array of the visible portion of the PDF page in
1225
+ * user space units [x1, y1, x2, y2].
1226
+ */
1227
+ get view(): number[];
1228
+ /**
1229
+ * @param {GetViewportParameters} params - Viewport parameters.
1230
+ * @returns {PageViewport} Contains 'width' and 'height' properties
1231
+ * along with transforms required for rendering.
1232
+ */
1233
+ getViewport({ scale, rotation, offsetX, offsetY, dontFlip, }?: GetViewportParameters): PageViewport;
1234
+ /**
1235
+ * @param {GetAnnotationsParameters} params - Annotation parameters.
1236
+ * @returns {Promise<Array<any>>} A promise that is resolved with an
1237
+ * {Array} of the annotation objects.
1238
+ */
1239
+ getAnnotations({ intent }?: GetAnnotationsParameters): Promise<Array<any>>;
1240
+ /**
1241
+ * @returns {Promise<Object>} A promise that is resolved with an
1242
+ * {Object} with JS actions.
1243
+ */
1244
+ getJSActions(): Promise<Object>;
1245
+ /**
1246
+ * @type {Object} The filter factory instance.
1247
+ */
1248
+ get filterFactory(): Object;
1249
+ /**
1250
+ * @type {boolean} True if only XFA form.
1251
+ */
1252
+ get isPureXfa(): boolean;
1253
+ /**
1254
+ * @returns {Promise<Object | null>} A promise that is resolved with
1255
+ * an {Object} with a fake DOM object (a tree structure where elements
1256
+ * are {Object} with a name, attributes (class, style, ...), value and
1257
+ * children, very similar to a HTML DOM tree), or `null` if no XFA exists.
1258
+ */
1259
+ getXfa(): Promise<Object | null>;
1260
+ /**
1261
+ * Begins the process of rendering a page to the desired context.
1262
+ *
1263
+ * @param {RenderParameters} params - Page render parameters.
1264
+ * @returns {RenderTask} An object that contains a promise that is
1265
+ * resolved when the page finishes rendering.
1266
+ */
1267
+ render({ canvasContext, viewport, intent, annotationMode, transform, background, optionalContentConfigPromise, annotationCanvasMap, pageColors, printAnnotationStorage, }: RenderParameters): RenderTask;
1268
+ /**
1269
+ * @param {GetOperatorListParameters} params - Page getOperatorList
1270
+ * parameters.
1271
+ * @returns {Promise<PDFOperatorList>} A promise resolved with an
1272
+ * {@link PDFOperatorList} object that represents the page's operator list.
1273
+ */
1274
+ getOperatorList({ intent, annotationMode, printAnnotationStorage, }?: GetOperatorListParameters): Promise<PDFOperatorList>;
1275
+ /**
1276
+ * NOTE: All occurrences of whitespace will be replaced by
1277
+ * standard spaces (0x20).
1278
+ *
1279
+ * @param {getTextContentParameters} params - getTextContent parameters.
1280
+ * @returns {ReadableStream} Stream for reading text content chunks.
1281
+ */
1282
+ streamTextContent({ includeMarkedContent, disableNormalization, }?: getTextContentParameters): ReadableStream;
1283
+ /**
1284
+ * NOTE: All occurrences of whitespace will be replaced by
1285
+ * standard spaces (0x20).
1286
+ *
1287
+ * @param {getTextContentParameters} params - getTextContent parameters.
1288
+ * @returns {Promise<TextContent>} A promise that is resolved with a
1289
+ * {@link TextContent} object that represents the page's text content.
1290
+ */
1291
+ getTextContent(params?: getTextContentParameters): Promise<TextContent>;
1292
+ /**
1293
+ * @returns {Promise<StructTreeNode>} A promise that is resolved with a
1294
+ * {@link StructTreeNode} object that represents the page's structure tree,
1295
+ * or `null` when no structure tree is present for the current page.
1296
+ */
1297
+ getStructTree(): Promise<StructTreeNode>;
1298
+ /**
1299
+ * Destroys the page object.
1300
+ * @private
1301
+ */
1302
+ private _destroy;
1303
+ /**
1304
+ * Cleans up resources allocated by the page.
1305
+ *
1306
+ * @param {boolean} [resetStats] - Reset page stats, if enabled.
1307
+ * The default value is `false`.
1308
+ * @returns {boolean} Indicates if clean-up was successfully run.
1309
+ */
1310
+ cleanup(resetStats?: boolean | undefined): boolean;
1311
+ /**
1312
+ * @private
1313
+ */
1314
+ private _startRenderPage;
1315
+ /**
1316
+ * @private
1317
+ */
1318
+ private _renderPageChunk;
1319
+ /**
1320
+ * @private
1321
+ */
1322
+ private _pumpOperatorList;
1323
+ /**
1324
+ * @private
1325
+ */
1326
+ private _abortOperatorList;
1327
+ /**
1328
+ * @type {StatTimer | null} Returns page stats, if enabled; returns `null`
1329
+ * otherwise.
1330
+ */
1331
+ get stats(): StatTimer | null;
1332
+ #private;
1333
+ }
1334
+ /**
1335
+ * PDF.js web worker abstraction that controls the instantiation of PDF
1336
+ * documents. Message handlers are used to pass information from the main
1337
+ * thread to the worker thread and vice versa. If the creation of a web
1338
+ * worker is not possible, a "fake" worker will be used instead.
1339
+ *
1340
+ * @param {PDFWorkerParameters} params - The worker initialization parameters.
1341
+ */
1342
+ export class PDFWorker {
1343
+ static "__#35@#workerPorts": WeakMap<object, any>;
1344
+ /**
1345
+ * @param {PDFWorkerParameters} params - The worker initialization parameters.
1346
+ */
1347
+ static fromPort(params: PDFWorkerParameters): any;
1348
+ /**
1349
+ * The current `workerSrc`, when it exists.
1350
+ * @type {string}
1351
+ */
1352
+ static get workerSrc(): string;
1353
+ static get _mainThreadWorkerMessageHandler(): any;
1354
+ static get _setupFakeWorkerGlobal(): any;
1355
+ constructor({ name, port, verbosity, }?: {
1356
+ name?: null | undefined;
1357
+ port?: null | undefined;
1358
+ verbosity?: number | undefined;
1359
+ });
1360
+ name: any;
1361
+ destroyed: boolean;
1362
+ verbosity: number;
1363
+ _readyCapability: PromiseCapability;
1364
+ _port: any;
1365
+ _webWorker: Worker | null;
1366
+ _messageHandler: MessageHandler | null;
1367
+ /**
1368
+ * Promise for worker initialization completion.
1369
+ * @type {Promise<void>}
1370
+ */
1371
+ get promise(): Promise<void>;
1372
+ /**
1373
+ * The current `workerPort`, when it exists.
1374
+ * @type {Worker}
1375
+ */
1376
+ get port(): Worker;
1377
+ /**
1378
+ * The current MessageHandler-instance.
1379
+ * @type {MessageHandler}
1380
+ */
1381
+ get messageHandler(): MessageHandler;
1382
+ _initializeFromPort(port: any): void;
1383
+ _initialize(): void;
1384
+ _setupFakeWorker(): void;
1385
+ /**
1386
+ * Destroys the worker instance.
1387
+ */
1388
+ destroy(): void;
1389
+ }
1390
+ export namespace PDFWorkerUtil {
1391
+ let isWorkerDisabled: boolean;
1392
+ let fallbackWorkerSrc: null;
1393
+ let fakeWorkerId: number;
1394
+ }
1395
+ /**
1396
+ * Allows controlling of the rendering tasks.
1397
+ */
1398
+ export class RenderTask {
1399
+ constructor(internalRenderTask: any);
1400
+ /**
1401
+ * Callback for incremental rendering -- a function that will be called
1402
+ * each time the rendering is paused. To continue rendering call the
1403
+ * function that is the first argument to the callback.
1404
+ * @type {function}
1405
+ */
1406
+ onContinue: Function;
1407
+ /**
1408
+ * Promise for rendering task completion.
1409
+ * @type {Promise<void>}
1410
+ */
1411
+ get promise(): Promise<void>;
1412
+ /**
1413
+ * Cancels the rendering task. If the task is currently rendering it will
1414
+ * not be cancelled until graphics pauses with a timeout. The promise that
1415
+ * this object extends will be rejected when cancelled.
1416
+ *
1417
+ * @param {number} [extraDelay]
1418
+ */
1419
+ cancel(extraDelay?: number | undefined): void;
1420
+ /**
1421
+ * Whether form fields are rendered separately from the main operatorList.
1422
+ * @type {boolean}
1423
+ */
1424
+ get separateAnnots(): boolean;
1425
+ #private;
1426
+ }
1427
+ /** @type {string} */
1428
+ export const version: string;
1429
+ import { PageViewport } from "./display_utils.js";
1430
+ import { OptionalContentConfig } from "./optional_content_config.js";
1431
+ import { PrintAnnotationStorage } from "./annotation_storage.js";
1432
+ import { PromiseCapability } from "../shared/util.js";
1433
+ import { AnnotationStorage } from "./annotation_storage.js";
1434
+ import { info } from "../shared/util.js";
1435
+ import { Metadata } from "./metadata.js";
1436
+ import { StatTimer } from "./display_utils.js";
1437
+ /**
1438
+ * A PDF document and page is built of many objects. E.g. there are objects for
1439
+ * fonts, images, rendering code, etc. These objects may get processed inside of
1440
+ * a worker. This class implements some basic methods to manage these objects.
1441
+ */
1442
+ declare class PDFObjects {
1443
+ /**
1444
+ * If called *without* callback, this returns the data of `objId` but the
1445
+ * object needs to be resolved. If it isn't, this method throws.
1446
+ *
1447
+ * If called *with* a callback, the callback is called with the data of the
1448
+ * object once the object is resolved. That means, if you call this method
1449
+ * and the object is already resolved, the callback gets called right away.
1450
+ *
1451
+ * @param {string} objId
1452
+ * @param {function} [callback]
1453
+ * @returns {any}
1454
+ */
1455
+ get(objId: string, callback?: Function | undefined): any;
1456
+ /**
1457
+ * @param {string} objId
1458
+ * @returns {boolean}
1459
+ */
1460
+ has(objId: string): boolean;
1461
+ /**
1462
+ * Resolves the object `objId` with optional `data`.
1463
+ *
1464
+ * @param {string} objId
1465
+ * @param {any} [data]
1466
+ */
1467
+ resolve(objId: string, data?: any): void;
1468
+ clear(): void;
1469
+ #private;
1470
+ }
1471
+ import { MessageHandler } from "../shared/message_handler.js";
1472
+ export { SVGGraphics };