pdfjs-dist 2.5.207 → 2.6.347
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.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/bower.json +1 -1
- package/build/pdf.js +867 -216
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +10214 -8547
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/es5/build/pdf.js +2023 -1046
- package/es5/build/pdf.js.map +1 -1
- package/es5/build/pdf.min.js +22 -0
- package/es5/build/pdf.worker.js +11136 -8144
- package/es5/build/pdf.worker.js.map +1 -1
- package/es5/build/pdf.worker.min.js +22 -0
- package/es5/image_decoders/pdf.image_decoders.js +12529 -0
- package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
- package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/pdf_viewer.css +8 -5
- package/es5/web/pdf_viewer.js +195 -51
- package/es5/web/pdf_viewer.js.map +1 -1
- package/image_decoders/pdf.image_decoders.js +24 -16
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +1 -1
- package/lib/core/annotation.js +479 -43
- package/lib/core/cff_parser.js +643 -615
- package/lib/core/chunked_stream.js +64 -50
- package/lib/core/colorspace.js +126 -104
- package/lib/core/crypto.js +37 -0
- package/lib/core/document.js +128 -75
- package/lib/core/evaluator.js +3015 -2754
- package/lib/core/fonts.js +47 -46
- package/lib/core/function.js +79 -6
- package/lib/core/image.js +364 -357
- package/lib/core/image_utils.js +109 -8
- package/lib/core/jpg.js +8 -3
- package/lib/core/obj.js +255 -34
- package/lib/core/operator_list.js +17 -15
- package/lib/core/parser.js +40 -3
- package/lib/core/pattern.js +24 -11
- package/lib/core/primitives.js +112 -53
- package/lib/core/type1_parser.js +2 -0
- package/lib/core/worker.js +102 -37
- package/lib/core/writer.js +242 -0
- package/lib/display/annotation_layer.js +51 -10
- package/lib/display/annotation_storage.js +89 -0
- package/lib/display/api.js +140 -54
- package/lib/display/canvas.js +215 -46
- package/lib/display/display_utils.js +55 -18
- package/lib/display/fetch_stream.js +6 -0
- package/lib/display/font_loader.js +26 -15
- package/lib/display/metadata.js +1 -7
- package/lib/display/network.js +0 -14
- package/lib/display/node_utils.js +87 -0
- package/lib/display/optional_content_config.js +184 -0
- package/lib/display/svg.js +1 -1
- package/lib/display/text_layer.js +4 -1
- package/lib/pdf.js +2 -2
- package/lib/pdf.worker.js +2 -2
- package/lib/shared/is_node.js +1 -1
- package/lib/shared/util.js +13 -10
- package/lib/test/unit/annotation_spec.js +520 -50
- package/lib/test/unit/annotation_storage_spec.js +83 -0
- package/lib/test/unit/api_spec.js +16 -6
- package/lib/test/unit/cmap_spec.js +4 -4
- package/lib/test/unit/colorspace_spec.js +216 -24
- package/lib/test/unit/crypto_spec.js +51 -4
- package/lib/test/unit/custom_spec.js +129 -1
- package/lib/test/unit/document_spec.js +112 -1
- package/lib/test/unit/evaluator_spec.js +29 -10
- package/lib/test/unit/jasmine-boot.js +1 -1
- package/lib/test/unit/metadata_spec.js +3 -3
- package/lib/test/unit/primitives_spec.js +242 -63
- package/lib/test/unit/test_utils.js +42 -89
- package/lib/test/unit/testreporter.js +17 -6
- package/lib/test/unit/util_spec.js +13 -12
- package/lib/test/unit/writer_spec.js +84 -0
- package/lib/web/annotation_layer_builder.js +13 -9
- package/lib/web/app.js +231 -26
- package/lib/web/app_options.js +1 -6
- package/lib/web/base_tree_viewer.js +100 -0
- package/lib/web/base_viewer.js +53 -4
- package/lib/web/download_manager.js +3 -10
- package/lib/web/firefox_print_service.js +32 -12
- package/lib/web/firefoxcom.js +20 -6
- package/lib/web/interfaces.js +1 -1
- package/lib/web/pdf_attachment_viewer.js +80 -38
- package/lib/web/pdf_find_controller.js +2 -1
- package/lib/web/pdf_layer_viewer.js +208 -0
- package/lib/web/pdf_outline_viewer.js +24 -57
- package/lib/web/pdf_page_view.js +29 -6
- package/lib/web/pdf_print_service.js +13 -11
- package/lib/web/pdf_sidebar.js +46 -25
- package/lib/web/pdf_thumbnail_view.js +16 -3
- package/lib/web/pdf_thumbnail_viewer.js +17 -1
- package/lib/web/pdf_viewer.component.js +2 -2
- package/lib/web/preferences.js +1 -1
- package/lib/web/toolbar.js +1 -1
- package/lib/web/ui_utils.js +7 -1
- package/package.json +3 -1
- package/types/display/annotation_layer.d.ts +61 -0
- package/types/display/annotation_storage.d.ts +36 -0
- package/types/display/api.d.ts +1107 -0
- package/types/display/api_compatibility.d.ts +1 -0
- package/types/display/canvas.d.ts +4 -0
- package/types/display/content_disposition.d.ts +7 -0
- package/types/display/display_utils.d.ts +243 -0
- package/types/display/fetch_stream.d.ts +67 -0
- package/types/display/font_loader.d.ts +19 -0
- package/types/display/metadata.d.ts +9 -0
- package/types/display/network.d.ts +80 -0
- package/types/display/network_utils.d.ts +14 -0
- package/types/display/node_stream.d.ts +72 -0
- package/types/display/node_utils.d.ts +6 -0
- package/types/display/optional_content_config.d.ts +12 -0
- package/types/display/pattern_helper.d.ts +5 -0
- package/types/display/svg.d.ts +2 -0
- package/types/display/text_layer.d.ts +83 -0
- package/types/display/transport_stream.d.ts +57 -0
- package/types/display/webgl.d.ts +20 -0
- package/types/display/worker_options.d.ts +27 -0
- package/types/display/xml_parser.d.ts +35 -0
- package/types/pdf.d.ts +33 -0
- package/types/shared/compatibility.d.ts +1 -0
- package/types/shared/is_node.d.ts +1 -0
- package/types/shared/message_handler.d.ts +62 -0
- package/types/shared/util.d.ts +421 -0
- package/web/images/shadow.png +0 -0
- package/web/pdf_viewer.css +8 -5
- package/web/pdf_viewer.js +109 -33
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +1 -9
- package/es5/web/images/texture.png +0 -0
- package/web/images/texture.png +0 -0
@@ -0,0 +1,1107 @@
|
|
1
|
+
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
2
|
+
/**
|
3
|
+
* Document initialization / loading parameters object.
|
4
|
+
*/
|
5
|
+
export type DocumentInitParameters = {
|
6
|
+
/**
|
7
|
+
* - The URL of the PDF.
|
8
|
+
*/
|
9
|
+
url?: string;
|
10
|
+
/**
|
11
|
+
* - Binary PDF data. Use
|
12
|
+
* typed arrays (Uint8Array) to improve the memory usage. If PDF data is
|
13
|
+
* BASE64-encoded, use `atob()` to convert it to a binary string first.
|
14
|
+
*/
|
15
|
+
data?: TypedArray | Array<number> | string;
|
16
|
+
/**
|
17
|
+
* - Basic authentication headers.
|
18
|
+
*/
|
19
|
+
httpHeaders?: Object;
|
20
|
+
/**
|
21
|
+
* - Indicates whether or not
|
22
|
+
* cross-site Access-Control requests should be made using credentials such
|
23
|
+
* as cookies or authorization headers. The default is `false`.
|
24
|
+
*/
|
25
|
+
withCredentials?: boolean;
|
26
|
+
/**
|
27
|
+
* - For decrypting password-protected PDFs.
|
28
|
+
*/
|
29
|
+
password?: string;
|
30
|
+
/**
|
31
|
+
* - A typed array with the first portion
|
32
|
+
* or all of the pdf data. Used by the extension since some data is already
|
33
|
+
* loaded before the switch to range requests.
|
34
|
+
*/
|
35
|
+
initialData?: TypedArray;
|
36
|
+
/**
|
37
|
+
* - The PDF file length. It's used for progress
|
38
|
+
* reports and range requests operations.
|
39
|
+
*/
|
40
|
+
length?: number;
|
41
|
+
/**
|
42
|
+
* - Allows for using a custom range
|
43
|
+
* transport implementation.
|
44
|
+
*/
|
45
|
+
range?: PDFDataRangeTransport;
|
46
|
+
/**
|
47
|
+
* - Specify maximum number of bytes fetched
|
48
|
+
* per range request. The default value is {@link DEFAULT_RANGE_CHUNK_SIZE}.
|
49
|
+
*/
|
50
|
+
rangeChunkSize?: number;
|
51
|
+
/**
|
52
|
+
* - The worker that will be used for loading and
|
53
|
+
* parsing the PDF data.
|
54
|
+
*/
|
55
|
+
worker?: any;
|
56
|
+
/**
|
57
|
+
* - Controls the logging level; the constants
|
58
|
+
* from {@link VerbosityLevel} should be used.
|
59
|
+
*/
|
60
|
+
verbosity?: number;
|
61
|
+
/**
|
62
|
+
* - The base URL of the document, used when
|
63
|
+
* attempting to recover valid absolute URLs for annotations, and outline
|
64
|
+
* items, that (incorrectly) only specify relative URLs.
|
65
|
+
*/
|
66
|
+
docBaseUrl?: string;
|
67
|
+
/**
|
68
|
+
* - The URL where the predefined Adobe CMaps are
|
69
|
+
* located. Include the trailing slash.
|
70
|
+
*/
|
71
|
+
cMapUrl?: string;
|
72
|
+
/**
|
73
|
+
* - Specifies if the Adobe CMaps are binary
|
74
|
+
* packed or not.
|
75
|
+
*/
|
76
|
+
cMapPacked?: boolean;
|
77
|
+
/**
|
78
|
+
* - The factory that will be used when
|
79
|
+
* reading built-in CMap files. Providing a custom factory is useful for
|
80
|
+
* environments without Fetch API or `XMLHttpRequest` support, such as
|
81
|
+
* Node.js. The default value is {DOMCMapReaderFactory}.
|
82
|
+
*/
|
83
|
+
CMapReaderFactory?: Object;
|
84
|
+
/**
|
85
|
+
* - Reject certain promises, e.g.
|
86
|
+
* `getOperatorList`, `getTextContent`, and `RenderTask`, when the associated
|
87
|
+
* PDF data cannot be successfully parsed, instead of attempting to recover
|
88
|
+
* whatever possible of the data. The default value is `false`.
|
89
|
+
*/
|
90
|
+
stopAtErrors?: boolean;
|
91
|
+
/**
|
92
|
+
* - The maximum allowed image size in total
|
93
|
+
* pixels, i.e. width * height. Images above this value will not be rendered.
|
94
|
+
* Use -1 for no limit, which is also the default value.
|
95
|
+
*/
|
96
|
+
maxImageSize?: number;
|
97
|
+
/**
|
98
|
+
* - Determines if we can evaluate strings
|
99
|
+
* as JavaScript. Primarily used to improve performance of font rendering, and
|
100
|
+
* when parsing PDF functions. The default value is `true`.
|
101
|
+
*/
|
102
|
+
isEvalSupported?: boolean;
|
103
|
+
/**
|
104
|
+
* - By default fonts are converted to
|
105
|
+
* OpenType fonts and loaded via `@font-face` rules. If disabled, fonts will
|
106
|
+
* be rendered using a built-in font renderer that constructs the glyphs with
|
107
|
+
* primitive path commands. The default value is `false`.
|
108
|
+
*/
|
109
|
+
disableFontFace?: boolean;
|
110
|
+
/**
|
111
|
+
* - Include additional properties,
|
112
|
+
* which are unused during rendering of PDF documents, when exporting the
|
113
|
+
* parsed font data from the worker-thread. This may be useful for debugging
|
114
|
+
* purposes (and backwards compatibility), but note that it will lead to
|
115
|
+
* increased memory usage. The default value is `false`.
|
116
|
+
*/
|
117
|
+
fontExtraProperties?: boolean;
|
118
|
+
/**
|
119
|
+
* - Specify an explicit document
|
120
|
+
* context to create elements with and to load resources, such as fonts,
|
121
|
+
* into. Defaults to the current document.
|
122
|
+
*/
|
123
|
+
ownerDocument?: HTMLDocument;
|
124
|
+
/**
|
125
|
+
* - Disable range request loading of PDF
|
126
|
+
* files. When enabled, and if the server supports partial content requests,
|
127
|
+
* then the PDF will be fetched in chunks. The default value is `false`.
|
128
|
+
*/
|
129
|
+
disableRange?: boolean;
|
130
|
+
/**
|
131
|
+
* - Disable streaming of PDF file data.
|
132
|
+
* By default PDF.js attempts to load PDF files in chunks. The default value
|
133
|
+
* is `false`.
|
134
|
+
*/
|
135
|
+
disableStream?: boolean;
|
136
|
+
/**
|
137
|
+
* - Disable pre-fetching of PDF file
|
138
|
+
* data. When range requests are enabled PDF.js will automatically keep
|
139
|
+
* fetching more data even if it isn't needed to display the current page.
|
140
|
+
* The default value is `false`.
|
141
|
+
*
|
142
|
+
* NOTE: It is also necessary to disable streaming, see above, in order for
|
143
|
+
* disabling of pre-fetching to work correctly.
|
144
|
+
*/
|
145
|
+
disableAutoFetch?: boolean;
|
146
|
+
/**
|
147
|
+
* - Enables special hooks for debugging PDF.js
|
148
|
+
* (see `web/debugger.js`). The default value is `false`.
|
149
|
+
*/
|
150
|
+
pdfBug?: boolean;
|
151
|
+
};
|
152
|
+
export type PDFDocumentStats = {
|
153
|
+
/**
|
154
|
+
* - Used stream types in the
|
155
|
+
* document (an item is set to true if specific stream ID was used in the
|
156
|
+
* document).
|
157
|
+
*/
|
158
|
+
streamTypes: {
|
159
|
+
[x: string]: boolean;
|
160
|
+
};
|
161
|
+
/**
|
162
|
+
* - Used font types in the
|
163
|
+
* document (an item is set to true if specific font ID was used in the
|
164
|
+
* document).
|
165
|
+
*/
|
166
|
+
fontTypes: {
|
167
|
+
[x: string]: boolean;
|
168
|
+
};
|
169
|
+
};
|
170
|
+
export type IPDFStreamFactory = Function;
|
171
|
+
/**
|
172
|
+
* The loading task controls the operations required to load a PDF document
|
173
|
+
* (such as network requests) and provides a way to listen for completion,
|
174
|
+
* after which individual pages can be rendered.
|
175
|
+
*/
|
176
|
+
export type PDFDocumentLoadingTask = {
|
177
|
+
/**
|
178
|
+
* - Unique identifier for the document loading task.
|
179
|
+
*/
|
180
|
+
docId: string;
|
181
|
+
/**
|
182
|
+
* - Whether the loading task is destroyed or not.
|
183
|
+
*/
|
184
|
+
destroyed: boolean;
|
185
|
+
/**
|
186
|
+
* - Callback to request a password if a wrong
|
187
|
+
* or no password was provided. The callback receives two parameters: a
|
188
|
+
* function that should be called with the new password, and a reason (see
|
189
|
+
* {@link PasswordResponses}).
|
190
|
+
*/
|
191
|
+
onPassword?: Function;
|
192
|
+
/**
|
193
|
+
* - Callback to be able to monitor the
|
194
|
+
* loading progress of the PDF file (necessary to implement e.g. a loading
|
195
|
+
* bar). The callback receives an {Object} with the properties `loaded`
|
196
|
+
* ({number}) and `total` ({number}) that indicate how many bytes are loaded.
|
197
|
+
*/
|
198
|
+
onProgress?: Function;
|
199
|
+
/**
|
200
|
+
* - Callback for when an
|
201
|
+
* unsupported feature is used in the PDF document. The callback receives an
|
202
|
+
* {@link UNSUPPORTED_FEATURES} argument.
|
203
|
+
*/
|
204
|
+
onUnsupportedFeature?: Function;
|
205
|
+
/**
|
206
|
+
* - Promise for document loading
|
207
|
+
* task completion.
|
208
|
+
*/
|
209
|
+
promise: Promise<PDFDocumentProxy>;
|
210
|
+
/**
|
211
|
+
* - Abort all network requests and destroy
|
212
|
+
* the worker. Returns a promise that is resolved when destruction is
|
213
|
+
* completed.
|
214
|
+
*/
|
215
|
+
destroy: Function;
|
216
|
+
};
|
217
|
+
/**
|
218
|
+
* Page getViewport parameters.
|
219
|
+
*/
|
220
|
+
export type GetViewportParameters = {
|
221
|
+
/**
|
222
|
+
* - The desired scale of the viewport.
|
223
|
+
*/
|
224
|
+
scale: number;
|
225
|
+
/**
|
226
|
+
* - The desired rotation, in degrees, of
|
227
|
+
* the viewport. If omitted it defaults to the page rotation.
|
228
|
+
*/
|
229
|
+
rotation?: number;
|
230
|
+
/**
|
231
|
+
* - The horizontal, i.e. x-axis, offset.
|
232
|
+
* The default value is `0`.
|
233
|
+
*/
|
234
|
+
offsetX?: number;
|
235
|
+
/**
|
236
|
+
* - The vertical, i.e. y-axis, offset.
|
237
|
+
* The default value is `0`.
|
238
|
+
*/
|
239
|
+
offsetY?: number;
|
240
|
+
/**
|
241
|
+
* - If true, the y-axis will not be
|
242
|
+
* flipped. The default value is `false`.
|
243
|
+
*/
|
244
|
+
dontFlip?: boolean;
|
245
|
+
};
|
246
|
+
/**
|
247
|
+
* Page getTextContent parameters.
|
248
|
+
*/
|
249
|
+
export type getTextContentParameters = {
|
250
|
+
/**
|
251
|
+
* - Replaces all occurrences of
|
252
|
+
* whitespace with standard spaces (0x20). The default value is `false`.
|
253
|
+
*/
|
254
|
+
normalizeWhitespace: boolean;
|
255
|
+
/**
|
256
|
+
* - Do not attempt to combine
|
257
|
+
* same line {@link TextItem}'s. The default value is `false`.
|
258
|
+
*/
|
259
|
+
disableCombineTextItems: boolean;
|
260
|
+
};
|
261
|
+
/**
|
262
|
+
* Page text content.
|
263
|
+
*/
|
264
|
+
export type TextContent = {
|
265
|
+
/**
|
266
|
+
* - Array of {@link TextItem} objects.
|
267
|
+
*/
|
268
|
+
items: Array<TextItem>;
|
269
|
+
/**
|
270
|
+
* - {@link TextStyle} objects,
|
271
|
+
* indexed by font name.
|
272
|
+
*/
|
273
|
+
styles: {
|
274
|
+
[x: string]: TextStyle;
|
275
|
+
};
|
276
|
+
};
|
277
|
+
/**
|
278
|
+
* Page text content part.
|
279
|
+
*/
|
280
|
+
export type TextItem = {
|
281
|
+
/**
|
282
|
+
* - Text content.
|
283
|
+
*/
|
284
|
+
str: string;
|
285
|
+
/**
|
286
|
+
* - Text direction: 'ttb', 'ltr' or 'rtl'.
|
287
|
+
*/
|
288
|
+
dir: string;
|
289
|
+
/**
|
290
|
+
* - Transformation matrix.
|
291
|
+
*/
|
292
|
+
transform: Array<any>;
|
293
|
+
/**
|
294
|
+
* - Width in device space.
|
295
|
+
*/
|
296
|
+
width: number;
|
297
|
+
/**
|
298
|
+
* - Height in device space.
|
299
|
+
*/
|
300
|
+
height: number;
|
301
|
+
/**
|
302
|
+
* - Font name used by PDF.js for converted font.
|
303
|
+
*/
|
304
|
+
fontName: string;
|
305
|
+
};
|
306
|
+
/**
|
307
|
+
* Text style.
|
308
|
+
*/
|
309
|
+
export type TextStyle = {
|
310
|
+
/**
|
311
|
+
* - Font ascent.
|
312
|
+
*/
|
313
|
+
ascent: number;
|
314
|
+
/**
|
315
|
+
* - Font descent.
|
316
|
+
*/
|
317
|
+
descent: number;
|
318
|
+
/**
|
319
|
+
* - Whether or not the text is in vertical mode.
|
320
|
+
*/
|
321
|
+
vertical: boolean;
|
322
|
+
/**
|
323
|
+
* - The possible font family.
|
324
|
+
*/
|
325
|
+
fontFamily: string;
|
326
|
+
};
|
327
|
+
/**
|
328
|
+
* Page annotation parameters.
|
329
|
+
*/
|
330
|
+
export type GetAnnotationsParameters = {
|
331
|
+
/**
|
332
|
+
* - Determines the annotations that will be fetched,
|
333
|
+
* can be either 'display' (viewable annotations) or 'print' (printable
|
334
|
+
* annotations). If the parameter is omitted, all annotations are fetched.
|
335
|
+
*/
|
336
|
+
intent: string;
|
337
|
+
};
|
338
|
+
/**
|
339
|
+
* Page render parameters.
|
340
|
+
*/
|
341
|
+
export type RenderParameters = {
|
342
|
+
/**
|
343
|
+
* - A 2D context of a DOM Canvas object.
|
344
|
+
*/
|
345
|
+
canvasContext: Object;
|
346
|
+
/**
|
347
|
+
* - Rendering viewport obtained by calling
|
348
|
+
* the `PDFPageProxy.getViewport` method.
|
349
|
+
*/
|
350
|
+
viewport: PageViewport;
|
351
|
+
/**
|
352
|
+
* - Rendering intent, can be 'display' or 'print'.
|
353
|
+
* The default value is 'display'.
|
354
|
+
*/
|
355
|
+
intent?: string;
|
356
|
+
/**
|
357
|
+
* - Enables WebGL accelerated rendering for
|
358
|
+
* some operations. The default value is `false`.
|
359
|
+
*/
|
360
|
+
enableWebGL?: boolean;
|
361
|
+
/**
|
362
|
+
* - Whether or not interactive
|
363
|
+
* form elements are rendered in the display layer. If so, we do not render
|
364
|
+
* them on the canvas as well.
|
365
|
+
*/
|
366
|
+
renderInteractiveForms?: boolean;
|
367
|
+
/**
|
368
|
+
* - Additional transform, applied just
|
369
|
+
* before viewport transform.
|
370
|
+
*/
|
371
|
+
transform?: Array<any>;
|
372
|
+
/**
|
373
|
+
* - An object that has `beginLayout`,
|
374
|
+
* `endLayout` and `appendImage` functions.
|
375
|
+
*/
|
376
|
+
imageLayer?: Object;
|
377
|
+
/**
|
378
|
+
* - The factory instance that will be used
|
379
|
+
* when creating canvases. The default value is {new DOMCanvasFactory()}.
|
380
|
+
*/
|
381
|
+
canvasFactory?: Object;
|
382
|
+
/**
|
383
|
+
* - Background to use for the canvas.
|
384
|
+
* Any valid `canvas.fillStyle` can be used: a `DOMString` parsed as CSS
|
385
|
+
* <color> value, a `CanvasGradient` object (a linear or radial gradient) or
|
386
|
+
* a `CanvasPattern` object (a repetitive image). The default value is
|
387
|
+
* 'rgb(255,255,255)'.
|
388
|
+
*/
|
389
|
+
background?: Object | string;
|
390
|
+
/**
|
391
|
+
* - Storage for annotation
|
392
|
+
* data in forms.
|
393
|
+
*/
|
394
|
+
annotationStorage?: AnnotationStorage;
|
395
|
+
/**
|
396
|
+
* -
|
397
|
+
* A promise that should resolve with an {@link OptionalContentConfig}
|
398
|
+
* created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,
|
399
|
+
* the configuration will be fetched automatically with the default visibility
|
400
|
+
* states set.
|
401
|
+
*/
|
402
|
+
optionalContentConfigPromise?: Promise<OptionalContentConfig>;
|
403
|
+
};
|
404
|
+
/**
|
405
|
+
* PDF page operator list.
|
406
|
+
*/
|
407
|
+
export type PDFOperatorList = {
|
408
|
+
/**
|
409
|
+
* - Array containing the operator functions.
|
410
|
+
*/
|
411
|
+
fnArray: Array<number>;
|
412
|
+
/**
|
413
|
+
* - Array containing the arguments of the
|
414
|
+
* functions.
|
415
|
+
*/
|
416
|
+
argsArray: Array<any>;
|
417
|
+
};
|
418
|
+
export type PDFWorkerParameters = {
|
419
|
+
/**
|
420
|
+
* - The name of the worker.
|
421
|
+
*/
|
422
|
+
name?: string;
|
423
|
+
/**
|
424
|
+
* - The `workerPort` object.
|
425
|
+
*/
|
426
|
+
port?: Object;
|
427
|
+
/**
|
428
|
+
* - Controls the logging level; the
|
429
|
+
* constants from {@link VerbosityLevel} should be used.
|
430
|
+
*/
|
431
|
+
verbosity?: number;
|
432
|
+
};
|
433
|
+
/**
|
434
|
+
* @typedef { Int8Array | Uint8Array | Uint8ClampedArray |
|
435
|
+
* Int16Array | Uint16Array |
|
436
|
+
* Int32Array | Uint32Array | Float32Array |
|
437
|
+
* Float64Array
|
438
|
+
* } TypedArray
|
439
|
+
*/
|
440
|
+
/**
|
441
|
+
* Document initialization / loading parameters object.
|
442
|
+
*
|
443
|
+
* @typedef {Object} DocumentInitParameters
|
444
|
+
* @property {string} [url] - The URL of the PDF.
|
445
|
+
* @property {TypedArray|Array<number>|string} [data] - Binary PDF data. Use
|
446
|
+
* typed arrays (Uint8Array) to improve the memory usage. If PDF data is
|
447
|
+
* BASE64-encoded, use `atob()` to convert it to a binary string first.
|
448
|
+
* @property {Object} [httpHeaders] - Basic authentication headers.
|
449
|
+
* @property {boolean} [withCredentials] - Indicates whether or not
|
450
|
+
* cross-site Access-Control requests should be made using credentials such
|
451
|
+
* as cookies or authorization headers. The default is `false`.
|
452
|
+
* @property {string} [password] - For decrypting password-protected PDFs.
|
453
|
+
* @property {TypedArray} [initialData] - A typed array with the first portion
|
454
|
+
* or all of the pdf data. Used by the extension since some data is already
|
455
|
+
* loaded before the switch to range requests.
|
456
|
+
* @property {number} [length] - The PDF file length. It's used for progress
|
457
|
+
* reports and range requests operations.
|
458
|
+
* @property {PDFDataRangeTransport} [range] - Allows for using a custom range
|
459
|
+
* transport implementation.
|
460
|
+
* @property {number} [rangeChunkSize] - Specify maximum number of bytes fetched
|
461
|
+
* per range request. The default value is {@link DEFAULT_RANGE_CHUNK_SIZE}.
|
462
|
+
* @property {PDFWorker} [worker] - The worker that will be used for loading and
|
463
|
+
* parsing the PDF data.
|
464
|
+
* @property {number} [verbosity] - Controls the logging level; the constants
|
465
|
+
* from {@link VerbosityLevel} should be used.
|
466
|
+
* @property {string} [docBaseUrl] - The base URL of the document, used when
|
467
|
+
* attempting to recover valid absolute URLs for annotations, and outline
|
468
|
+
* items, that (incorrectly) only specify relative URLs.
|
469
|
+
* @property {string} [cMapUrl] - The URL where the predefined Adobe CMaps are
|
470
|
+
* located. Include the trailing slash.
|
471
|
+
* @property {boolean} [cMapPacked] - Specifies if the Adobe CMaps are binary
|
472
|
+
* packed or not.
|
473
|
+
* @property {Object} [CMapReaderFactory] - The factory that will be used when
|
474
|
+
* reading built-in CMap files. Providing a custom factory is useful for
|
475
|
+
* environments without Fetch API or `XMLHttpRequest` support, such as
|
476
|
+
* Node.js. The default value is {DOMCMapReaderFactory}.
|
477
|
+
* @property {boolean} [stopAtErrors] - Reject certain promises, e.g.
|
478
|
+
* `getOperatorList`, `getTextContent`, and `RenderTask`, when the associated
|
479
|
+
* PDF data cannot be successfully parsed, instead of attempting to recover
|
480
|
+
* whatever possible of the data. The default value is `false`.
|
481
|
+
* @property {number} [maxImageSize] - The maximum allowed image size in total
|
482
|
+
* pixels, i.e. width * height. Images above this value will not be rendered.
|
483
|
+
* Use -1 for no limit, which is also the default value.
|
484
|
+
* @property {boolean} [isEvalSupported] - Determines if we can evaluate strings
|
485
|
+
* as JavaScript. Primarily used to improve performance of font rendering, and
|
486
|
+
* when parsing PDF functions. The default value is `true`.
|
487
|
+
* @property {boolean} [disableFontFace] - By default fonts are converted to
|
488
|
+
* OpenType fonts and loaded via `@font-face` rules. If disabled, fonts will
|
489
|
+
* be rendered using a built-in font renderer that constructs the glyphs with
|
490
|
+
* primitive path commands. The default value is `false`.
|
491
|
+
* @property {boolean} [fontExtraProperties] - Include additional properties,
|
492
|
+
* which are unused during rendering of PDF documents, when exporting the
|
493
|
+
* parsed font data from the worker-thread. This may be useful for debugging
|
494
|
+
* purposes (and backwards compatibility), but note that it will lead to
|
495
|
+
* increased memory usage. The default value is `false`.
|
496
|
+
* @property {HTMLDocument} [ownerDocument] - Specify an explicit document
|
497
|
+
* context to create elements with and to load resources, such as fonts,
|
498
|
+
* into. Defaults to the current document.
|
499
|
+
* @property {boolean} [disableRange] - Disable range request loading of PDF
|
500
|
+
* files. When enabled, and if the server supports partial content requests,
|
501
|
+
* then the PDF will be fetched in chunks. The default value is `false`.
|
502
|
+
* @property {boolean} [disableStream] - Disable streaming of PDF file data.
|
503
|
+
* By default PDF.js attempts to load PDF files in chunks. The default value
|
504
|
+
* is `false`.
|
505
|
+
* @property {boolean} [disableAutoFetch] - Disable pre-fetching of PDF file
|
506
|
+
* data. When range requests are enabled PDF.js will automatically keep
|
507
|
+
* fetching more data even if it isn't needed to display the current page.
|
508
|
+
* The default value is `false`.
|
509
|
+
*
|
510
|
+
* NOTE: It is also necessary to disable streaming, see above, in order for
|
511
|
+
* disabling of pre-fetching to work correctly.
|
512
|
+
* @property {boolean} [pdfBug] - Enables special hooks for debugging PDF.js
|
513
|
+
* (see `web/debugger.js`). The default value is `false`.
|
514
|
+
*/
|
515
|
+
/**
|
516
|
+
* @typedef {Object} PDFDocumentStats
|
517
|
+
* @property {Object<string, boolean>} streamTypes - Used stream types in the
|
518
|
+
* document (an item is set to true if specific stream ID was used in the
|
519
|
+
* document).
|
520
|
+
* @property {Object<string, boolean>} fontTypes - Used font types in the
|
521
|
+
* document (an item is set to true if specific font ID was used in the
|
522
|
+
* document).
|
523
|
+
*/
|
524
|
+
/**
|
525
|
+
* This is the main entry point for loading a PDF and interacting with it.
|
526
|
+
*
|
527
|
+
* NOTE: If a URL is used to fetch the PDF data a standard Fetch API call (or
|
528
|
+
* XHR as fallback) is used, which means it must follow same origin rules,
|
529
|
+
* e.g. no cross-domain requests without CORS.
|
530
|
+
*
|
531
|
+
* @param {string|TypedArray|DocumentInitParameters|PDFDataRangeTransport} src -
|
532
|
+
* Can be a URL to where a PDF file is located, a typed array (Uint8Array)
|
533
|
+
* already populated with data or parameter object.
|
534
|
+
* @returns {PDFDocumentLoadingTask}
|
535
|
+
*/
|
536
|
+
export function getDocument(src: string | TypedArray | DocumentInitParameters | PDFDataRangeTransport): PDFDocumentLoadingTask;
|
537
|
+
export class LoopbackPort {
|
538
|
+
constructor(defer?: boolean);
|
539
|
+
_listeners: any[];
|
540
|
+
_defer: boolean;
|
541
|
+
_deferred: Promise<undefined>;
|
542
|
+
postMessage(obj: any, transfers: any): void;
|
543
|
+
addEventListener(name: any, listener: any): void;
|
544
|
+
removeEventListener(name: any, listener: any): void;
|
545
|
+
terminate(): void;
|
546
|
+
}
|
547
|
+
/**
|
548
|
+
* Abstract class to support range requests file loading.
|
549
|
+
*/
|
550
|
+
export class PDFDataRangeTransport {
|
551
|
+
/**
|
552
|
+
* @param {number} length
|
553
|
+
* @param {Uint8Array} initialData
|
554
|
+
* @param {boolean} [progressiveDone]
|
555
|
+
*/
|
556
|
+
constructor(length: number, initialData: Uint8Array, progressiveDone?: boolean | undefined);
|
557
|
+
length: number;
|
558
|
+
initialData: Uint8Array;
|
559
|
+
progressiveDone: boolean;
|
560
|
+
_rangeListeners: any[];
|
561
|
+
_progressListeners: any[];
|
562
|
+
_progressiveReadListeners: any[];
|
563
|
+
_progressiveDoneListeners: any[];
|
564
|
+
_readyCapability: import("../shared/util.js").PromiseCapability;
|
565
|
+
addRangeListener(listener: any): void;
|
566
|
+
addProgressListener(listener: any): void;
|
567
|
+
addProgressiveReadListener(listener: any): void;
|
568
|
+
addProgressiveDoneListener(listener: any): void;
|
569
|
+
onDataRange(begin: any, chunk: any): void;
|
570
|
+
onDataProgress(loaded: any, total: any): void;
|
571
|
+
onDataProgressiveRead(chunk: any): void;
|
572
|
+
onDataProgressiveDone(): void;
|
573
|
+
transportReady(): void;
|
574
|
+
requestDataRange(begin: any, end: any): void;
|
575
|
+
abort(): void;
|
576
|
+
}
|
577
|
+
/**
|
578
|
+
* @typedef {Object} PDFWorkerParameters
|
579
|
+
* @property {string} [name] - The name of the worker.
|
580
|
+
* @property {Object} [port] - The `workerPort` object.
|
581
|
+
* @property {number} [verbosity] - Controls the logging level; the
|
582
|
+
* constants from {@link VerbosityLevel} should be used.
|
583
|
+
*/
|
584
|
+
/** @type {any} */
|
585
|
+
export const PDFWorker: any;
|
586
|
+
/**
|
587
|
+
* Proxy to a `PDFDocument` in the worker thread.
|
588
|
+
*/
|
589
|
+
export class PDFDocumentProxy {
|
590
|
+
constructor(pdfInfo: any, transport: any);
|
591
|
+
_pdfInfo: any;
|
592
|
+
_transport: any;
|
593
|
+
/**
|
594
|
+
* @type {AnnotationStorage} Storage for annotation data in forms.
|
595
|
+
*/
|
596
|
+
get annotationStorage(): AnnotationStorage;
|
597
|
+
/**
|
598
|
+
* @type {number} Total number of pages in the PDF file.
|
599
|
+
*/
|
600
|
+
get numPages(): number;
|
601
|
+
/**
|
602
|
+
* @type {string} A (not guaranteed to be) unique ID to identify a PDF.
|
603
|
+
*/
|
604
|
+
get fingerprint(): string;
|
605
|
+
/**
|
606
|
+
* @param {number} pageNumber - The page number to get. The first page is 1.
|
607
|
+
* @returns {Promise<PDFPageProxy>} A promise that is resolved with
|
608
|
+
* a {@link PDFPageProxy} object.
|
609
|
+
*/
|
610
|
+
getPage(pageNumber: number): Promise<PDFPageProxy>;
|
611
|
+
/**
|
612
|
+
* @param {{num: number, gen: number}} ref - The page reference. Must have
|
613
|
+
* the `num` and `gen` properties.
|
614
|
+
* @returns {Promise<{num: number, gen: number}>} A promise that is resolved
|
615
|
+
* with the page index (starting from zero) that is associated with the
|
616
|
+
* reference.
|
617
|
+
*/
|
618
|
+
getPageIndex(ref: {
|
619
|
+
num: number;
|
620
|
+
gen: number;
|
621
|
+
}): Promise<{
|
622
|
+
num: number;
|
623
|
+
gen: number;
|
624
|
+
}>;
|
625
|
+
/**
|
626
|
+
* @returns {Promise<Object<string, Array<any>>>} A promise that is resolved
|
627
|
+
* with a mapping from named destinations to references.
|
628
|
+
*
|
629
|
+
* This can be slow for large documents. Use `getDestination` instead.
|
630
|
+
*/
|
631
|
+
getDestinations(): Promise<{
|
632
|
+
[x: string]: Array<any>;
|
633
|
+
}>;
|
634
|
+
/**
|
635
|
+
* @param {string} id - The named destination to get.
|
636
|
+
* @returns {Promise<Array<any>>} A promise that is resolved with all
|
637
|
+
* information of the given named destination.
|
638
|
+
*/
|
639
|
+
getDestination(id: string): Promise<Array<any>>;
|
640
|
+
/**
|
641
|
+
* @returns {Promise<Array<string> | null>} A promise that is resolved with
|
642
|
+
* an {Array} containing the page labels that correspond to the page
|
643
|
+
* indexes, or `null` when no page labels are present in the PDF file.
|
644
|
+
*/
|
645
|
+
getPageLabels(): Promise<Array<string> | null>;
|
646
|
+
/**
|
647
|
+
* @returns {Promise<string>} A promise that is resolved with a {string}
|
648
|
+
* containing the page layout name.
|
649
|
+
*/
|
650
|
+
getPageLayout(): Promise<string>;
|
651
|
+
/**
|
652
|
+
* @returns {Promise<string>} A promise that is resolved with a {string}
|
653
|
+
* containing the page mode name.
|
654
|
+
*/
|
655
|
+
getPageMode(): Promise<string>;
|
656
|
+
/**
|
657
|
+
* @returns {Promise<Object | null>} A promise that is resolved with an
|
658
|
+
* {Object} containing the viewer preferences, or `null` when no viewer
|
659
|
+
* preferences are present in the PDF file.
|
660
|
+
*/
|
661
|
+
getViewerPreferences(): Promise<Object | null>;
|
662
|
+
/**
|
663
|
+
* @returns {Promise<any | null>} A promise that is resolved with an {Array}
|
664
|
+
* containing the destination, or `null` when no open action is present
|
665
|
+
* in the PDF.
|
666
|
+
*/
|
667
|
+
getOpenAction(): Promise<any | null>;
|
668
|
+
/**
|
669
|
+
* @returns {Promise<any>} A promise that is resolved with a lookup table
|
670
|
+
* for mapping named attachments to their content.
|
671
|
+
*/
|
672
|
+
getAttachments(): Promise<any>;
|
673
|
+
/**
|
674
|
+
* @returns {Promise<Array<string> | null>} A promise that is resolved with
|
675
|
+
* an {Array} of all the JavaScript strings in the name tree, or `null`
|
676
|
+
* if no JavaScript exists.
|
677
|
+
*/
|
678
|
+
getJavaScript(): Promise<Array<string> | null>;
|
679
|
+
/**
|
680
|
+
* @typedef {Object} OutlineNode
|
681
|
+
* @property {string} title
|
682
|
+
* @property {boolean} bold
|
683
|
+
* @property {boolean} italic
|
684
|
+
* @property {Uint8ClampedArray} color - The color in RGB format to use for
|
685
|
+
* display purposes.
|
686
|
+
* @property {string | Array<any> | null} dest
|
687
|
+
* @property {string | null} url
|
688
|
+
* @property {string | undefined} unsafeUrl
|
689
|
+
* @property {boolean | undefined} newWindow
|
690
|
+
* @property {number | undefined} count
|
691
|
+
* @property {Array<OutlineNode>} items
|
692
|
+
*/
|
693
|
+
/**
|
694
|
+
* @returns {Promise<Array<OutlineNode>>} A promise that is resolved with an
|
695
|
+
* {Array} that is a tree outline (if it has one) of the PDF file.
|
696
|
+
*/
|
697
|
+
getOutline(): Promise<{
|
698
|
+
title: string;
|
699
|
+
bold: boolean;
|
700
|
+
italic: boolean;
|
701
|
+
/**
|
702
|
+
* - The color in RGB format to use for
|
703
|
+
* display purposes.
|
704
|
+
*/
|
705
|
+
color: Uint8ClampedArray;
|
706
|
+
dest: string | Array<any> | null;
|
707
|
+
url: string | null;
|
708
|
+
unsafeUrl: string | undefined;
|
709
|
+
newWindow: boolean | undefined;
|
710
|
+
count: number | undefined;
|
711
|
+
items: any[];
|
712
|
+
}[]>;
|
713
|
+
/**
|
714
|
+
* @returns {Promise<OptionalContentConfig>} A promise that is resolved with
|
715
|
+
* an {@link OptionalContentConfig} that contains all the optional content
|
716
|
+
* groups (assuming that the document has any).
|
717
|
+
*/
|
718
|
+
getOptionalContentConfig(): Promise<OptionalContentConfig>;
|
719
|
+
/**
|
720
|
+
* @returns {Promise<Array<number> | null>} A promise that is resolved with
|
721
|
+
* an {Array} that contains the permission flags for the PDF document, or
|
722
|
+
* `null` when no permissions are present in the PDF file.
|
723
|
+
*/
|
724
|
+
getPermissions(): Promise<Array<number> | null>;
|
725
|
+
/**
|
726
|
+
* @returns {Promise<{ info: Object, metadata: Metadata }>} A promise that is
|
727
|
+
* resolved with an {Object} that has `info` and `metadata` properties.
|
728
|
+
* `info` is an {Object} filled with anything available in the information
|
729
|
+
* dictionary and similarly `metadata` is a {Metadata} object with
|
730
|
+
* information from the metadata section of the PDF.
|
731
|
+
*/
|
732
|
+
getMetadata(): Promise<{
|
733
|
+
info: Object;
|
734
|
+
metadata: Metadata;
|
735
|
+
}>;
|
736
|
+
/**
|
737
|
+
* @returns {Promise<TypedArray>} A promise that is resolved with a
|
738
|
+
* {TypedArray} that has the raw data from the PDF.
|
739
|
+
*/
|
740
|
+
getData(): Promise<TypedArray>;
|
741
|
+
/**
|
742
|
+
* @returns {Promise<{ length: number }>} A promise that is resolved when the
|
743
|
+
* document's data is loaded. It is resolved with an {Object} that contains
|
744
|
+
* the `length` property that indicates size of the PDF data in bytes.
|
745
|
+
*/
|
746
|
+
getDownloadInfo(): Promise<{
|
747
|
+
length: number;
|
748
|
+
}>;
|
749
|
+
/**
|
750
|
+
* @returns {Promise<PDFDocumentStats>} A promise this is resolved with
|
751
|
+
* current statistics about document structures (see
|
752
|
+
* {@link PDFDocumentStats}).
|
753
|
+
*/
|
754
|
+
getStats(): Promise<PDFDocumentStats>;
|
755
|
+
/**
|
756
|
+
* Cleans up resources allocated by the document on both the main and worker
|
757
|
+
* threads.
|
758
|
+
*
|
759
|
+
* NOTE: Do not, under any circumstances, call this method when rendering is
|
760
|
+
* currently ongoing since that may lead to rendering errors.
|
761
|
+
*
|
762
|
+
* @returns {Promise} A promise that is resolved when clean-up has finished.
|
763
|
+
*/
|
764
|
+
cleanup(): Promise<any>;
|
765
|
+
/**
|
766
|
+
* Destroys the current document instance and terminates the worker.
|
767
|
+
*/
|
768
|
+
destroy(): any;
|
769
|
+
/**
|
770
|
+
* @type {DocumentInitParameters} A subset of the current
|
771
|
+
* {DocumentInitParameters}, which are either needed in the viewer and/or
|
772
|
+
* whose default values may be affected by the `apiCompatibilityParams`.
|
773
|
+
*/
|
774
|
+
get loadingParams(): DocumentInitParameters;
|
775
|
+
/**
|
776
|
+
* @type {PDFDocumentLoadingTask} The loadingTask for the current document.
|
777
|
+
*/
|
778
|
+
get loadingTask(): PDFDocumentLoadingTask;
|
779
|
+
/**
|
780
|
+
* @param {AnnotationStorage} annotationStorage - Storage for annotation
|
781
|
+
* data in forms.
|
782
|
+
* @returns {Promise<Uint8Array>} A promise that is resolved with a
|
783
|
+
* {Uint8Array} containing the full data of the saved document.
|
784
|
+
*/
|
785
|
+
saveDocument(annotationStorage: AnnotationStorage): Promise<Uint8Array>;
|
786
|
+
}
|
787
|
+
/**
|
788
|
+
* Page getViewport parameters.
|
789
|
+
*
|
790
|
+
* @typedef {Object} GetViewportParameters
|
791
|
+
* @property {number} scale - The desired scale of the viewport.
|
792
|
+
* @property {number} [rotation] - The desired rotation, in degrees, of
|
793
|
+
* the viewport. If omitted it defaults to the page rotation.
|
794
|
+
* @property {number} [offsetX] - The horizontal, i.e. x-axis, offset.
|
795
|
+
* The default value is `0`.
|
796
|
+
* @property {number} [offsetY] - The vertical, i.e. y-axis, offset.
|
797
|
+
* The default value is `0`.
|
798
|
+
* @property {boolean} [dontFlip] - If true, the y-axis will not be
|
799
|
+
* flipped. The default value is `false`.
|
800
|
+
*/
|
801
|
+
/**
|
802
|
+
* Page getTextContent parameters.
|
803
|
+
*
|
804
|
+
* @typedef {Object} getTextContentParameters
|
805
|
+
* @property {boolean} normalizeWhitespace - Replaces all occurrences of
|
806
|
+
* whitespace with standard spaces (0x20). The default value is `false`.
|
807
|
+
* @property {boolean} disableCombineTextItems - Do not attempt to combine
|
808
|
+
* same line {@link TextItem}'s. The default value is `false`.
|
809
|
+
*/
|
810
|
+
/**
|
811
|
+
* Page text content.
|
812
|
+
*
|
813
|
+
* @typedef {Object} TextContent
|
814
|
+
* @property {Array<TextItem>} items - Array of {@link TextItem} objects.
|
815
|
+
* @property {Object<string, TextStyle>} styles - {@link TextStyle} objects,
|
816
|
+
* indexed by font name.
|
817
|
+
*/
|
818
|
+
/**
|
819
|
+
* Page text content part.
|
820
|
+
*
|
821
|
+
* @typedef {Object} TextItem
|
822
|
+
* @property {string} str - Text content.
|
823
|
+
* @property {string} dir - Text direction: 'ttb', 'ltr' or 'rtl'.
|
824
|
+
* @property {Array<any>} transform - Transformation matrix.
|
825
|
+
* @property {number} width - Width in device space.
|
826
|
+
* @property {number} height - Height in device space.
|
827
|
+
* @property {string} fontName - Font name used by PDF.js for converted font.
|
828
|
+
*/
|
829
|
+
/**
|
830
|
+
* Text style.
|
831
|
+
*
|
832
|
+
* @typedef {Object} TextStyle
|
833
|
+
* @property {number} ascent - Font ascent.
|
834
|
+
* @property {number} descent - Font descent.
|
835
|
+
* @property {boolean} vertical - Whether or not the text is in vertical mode.
|
836
|
+
* @property {string} fontFamily - The possible font family.
|
837
|
+
*/
|
838
|
+
/**
|
839
|
+
* Page annotation parameters.
|
840
|
+
*
|
841
|
+
* @typedef {Object} GetAnnotationsParameters
|
842
|
+
* @property {string} intent - Determines the annotations that will be fetched,
|
843
|
+
* can be either 'display' (viewable annotations) or 'print' (printable
|
844
|
+
* annotations). If the parameter is omitted, all annotations are fetched.
|
845
|
+
*/
|
846
|
+
/**
|
847
|
+
* Page render parameters.
|
848
|
+
*
|
849
|
+
* @typedef {Object} RenderParameters
|
850
|
+
* @property {Object} canvasContext - A 2D context of a DOM Canvas object.
|
851
|
+
* @property {PageViewport} viewport - Rendering viewport obtained by calling
|
852
|
+
* the `PDFPageProxy.getViewport` method.
|
853
|
+
* @property {string} [intent] - Rendering intent, can be 'display' or 'print'.
|
854
|
+
* The default value is 'display'.
|
855
|
+
* @property {boolean} [enableWebGL] - Enables WebGL accelerated rendering for
|
856
|
+
* some operations. The default value is `false`.
|
857
|
+
* @property {boolean} [renderInteractiveForms] - Whether or not interactive
|
858
|
+
* form elements are rendered in the display layer. If so, we do not render
|
859
|
+
* them on the canvas as well.
|
860
|
+
* @property {Array<any>} [transform] - Additional transform, applied just
|
861
|
+
* before viewport transform.
|
862
|
+
* @property {Object} [imageLayer] - An object that has `beginLayout`,
|
863
|
+
* `endLayout` and `appendImage` functions.
|
864
|
+
* @property {Object} [canvasFactory] - The factory instance that will be used
|
865
|
+
* when creating canvases. The default value is {new DOMCanvasFactory()}.
|
866
|
+
* @property {Object | string} [background] - Background to use for the canvas.
|
867
|
+
* Any valid `canvas.fillStyle` can be used: a `DOMString` parsed as CSS
|
868
|
+
* <color> value, a `CanvasGradient` object (a linear or radial gradient) or
|
869
|
+
* a `CanvasPattern` object (a repetitive image). The default value is
|
870
|
+
* 'rgb(255,255,255)'.
|
871
|
+
* @property {AnnotationStorage} [annotationStorage] - Storage for annotation
|
872
|
+
* data in forms.
|
873
|
+
* @property {Promise<OptionalContentConfig>} [optionalContentConfigPromise] -
|
874
|
+
* A promise that should resolve with an {@link OptionalContentConfig}
|
875
|
+
* created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,
|
876
|
+
* the configuration will be fetched automatically with the default visibility
|
877
|
+
* states set.
|
878
|
+
*/
|
879
|
+
/**
|
880
|
+
* PDF page operator list.
|
881
|
+
*
|
882
|
+
* @typedef {Object} PDFOperatorList
|
883
|
+
* @property {Array<number>} fnArray - Array containing the operator functions.
|
884
|
+
* @property {Array<any>} argsArray - Array containing the arguments of the
|
885
|
+
* functions.
|
886
|
+
*/
|
887
|
+
/**
|
888
|
+
* Proxy to a `PDFPage` in the worker thread.
|
889
|
+
*/
|
890
|
+
export class PDFPageProxy {
|
891
|
+
constructor(pageIndex: any, pageInfo: any, transport: any, ownerDocument: any, pdfBug?: boolean);
|
892
|
+
_pageIndex: any;
|
893
|
+
_pageInfo: any;
|
894
|
+
_ownerDocument: any;
|
895
|
+
_transport: any;
|
896
|
+
_stats: StatTimer | null;
|
897
|
+
_pdfBug: boolean;
|
898
|
+
commonObjs: any;
|
899
|
+
objs: PDFObjects;
|
900
|
+
cleanupAfterRender: boolean;
|
901
|
+
pendingCleanup: boolean;
|
902
|
+
_intentStates: Map<any, any>;
|
903
|
+
destroyed: boolean;
|
904
|
+
/**
|
905
|
+
* @type {number} Page number of the page. First page is 1.
|
906
|
+
*/
|
907
|
+
get pageNumber(): number;
|
908
|
+
/**
|
909
|
+
* @type {number} The number of degrees the page is rotated clockwise.
|
910
|
+
*/
|
911
|
+
get rotate(): number;
|
912
|
+
/**
|
913
|
+
* @type {Object} The reference that points to this page. It has `num` and
|
914
|
+
* `gen` properties.
|
915
|
+
*/
|
916
|
+
get ref(): Object;
|
917
|
+
/**
|
918
|
+
* @type {number} The default size of units in 1/72nds of an inch.
|
919
|
+
*/
|
920
|
+
get userUnit(): number;
|
921
|
+
/**
|
922
|
+
* @type {Array<number>} An array of the visible portion of the PDF page in
|
923
|
+
* user space units [x1, y1, x2, y2].
|
924
|
+
*/
|
925
|
+
get view(): number[];
|
926
|
+
/**
|
927
|
+
* @param {GetViewportParameters} params - Viewport parameters.
|
928
|
+
* @returns {PageViewport} Contains 'width' and 'height' properties
|
929
|
+
* along with transforms required for rendering.
|
930
|
+
*/
|
931
|
+
getViewport({ scale, rotation, offsetX, offsetY, dontFlip, }?: GetViewportParameters): PageViewport;
|
932
|
+
/**
|
933
|
+
* @param {GetAnnotationsParameters} params - Annotation parameters.
|
934
|
+
* @returns {Promise<Array<any>>} A promise that is resolved with an
|
935
|
+
* {Array} of the annotation objects.
|
936
|
+
*/
|
937
|
+
getAnnotations({ intent }?: GetAnnotationsParameters): Promise<Array<any>>;
|
938
|
+
annotationsPromise: any;
|
939
|
+
annotationsIntent: string | undefined;
|
940
|
+
/**
|
941
|
+
* Begins the process of rendering a page to the desired context.
|
942
|
+
*
|
943
|
+
* @param {RenderParameters} params Page render parameters.
|
944
|
+
* @returns {RenderTask} An object that contains a promise that is
|
945
|
+
* resolved when the page finishes rendering.
|
946
|
+
*/
|
947
|
+
render({ canvasContext, viewport, intent, enableWebGL, renderInteractiveForms, transform, imageLayer, canvasFactory, background, annotationStorage, optionalContentConfigPromise, }: RenderParameters): RenderTask;
|
948
|
+
/**
|
949
|
+
* @returns {Promise<PDFOperatorList>} A promise resolved with an
|
950
|
+
* {@link PDFOperatorList} object that represents page's operator list.
|
951
|
+
*/
|
952
|
+
getOperatorList(): Promise<PDFOperatorList>;
|
953
|
+
/**
|
954
|
+
* @param {getTextContentParameters} params - getTextContent parameters.
|
955
|
+
* @returns {ReadableStream} Stream for reading text content chunks.
|
956
|
+
*/
|
957
|
+
streamTextContent({ normalizeWhitespace, disableCombineTextItems, }?: getTextContentParameters): ReadableStream;
|
958
|
+
/**
|
959
|
+
* @param {getTextContentParameters} params - getTextContent parameters.
|
960
|
+
* @returns {Promise<TextContent>} A promise that is resolved with a
|
961
|
+
* {@link TextContent} object that represents the page's text content.
|
962
|
+
*/
|
963
|
+
getTextContent(params?: getTextContentParameters): Promise<TextContent>;
|
964
|
+
/**
|
965
|
+
* Destroys the page object.
|
966
|
+
* @private
|
967
|
+
*/
|
968
|
+
private _destroy;
|
969
|
+
/**
|
970
|
+
* Cleans up resources allocated by the page.
|
971
|
+
*
|
972
|
+
* @param {boolean} [resetStats] - Reset page stats, if enabled.
|
973
|
+
* The default value is `false`.
|
974
|
+
* @returns {boolean} Indicates if clean-up was successfully run.
|
975
|
+
*/
|
976
|
+
cleanup(resetStats?: boolean | undefined): boolean;
|
977
|
+
/**
|
978
|
+
* Attempts to clean up if rendering is in a state where that's possible.
|
979
|
+
* @private
|
980
|
+
*/
|
981
|
+
private _tryCleanup;
|
982
|
+
/**
|
983
|
+
* @private
|
984
|
+
*/
|
985
|
+
private _startRenderPage;
|
986
|
+
/**
|
987
|
+
* @private
|
988
|
+
*/
|
989
|
+
private _renderPageChunk;
|
990
|
+
/**
|
991
|
+
* @private
|
992
|
+
*/
|
993
|
+
private _pumpOperatorList;
|
994
|
+
/**
|
995
|
+
* @private
|
996
|
+
*/
|
997
|
+
private _abortOperatorList;
|
998
|
+
/**
|
999
|
+
* @type {Object} Returns page stats, if enabled; returns `null` otherwise.
|
1000
|
+
*/
|
1001
|
+
get stats(): Object;
|
1002
|
+
}
|
1003
|
+
/**
|
1004
|
+
* Sets the function that instantiates an {IPDFStream} as an alternative PDF
|
1005
|
+
* data transport.
|
1006
|
+
*
|
1007
|
+
* @param {IPDFStreamFactory} pdfNetworkStreamFactory - The factory function
|
1008
|
+
* that takes document initialization parameters (including a "url") and
|
1009
|
+
* returns a promise which is resolved with an instance of {IPDFStream}.
|
1010
|
+
* @ignore
|
1011
|
+
*/
|
1012
|
+
export function setPDFNetworkStreamFactory(pdfNetworkStreamFactory: IPDFStreamFactory): void;
|
1013
|
+
/** @type {string} */
|
1014
|
+
export const version: string;
|
1015
|
+
/** @type {string} */
|
1016
|
+
export const build: string;
|
1017
|
+
import { PageViewport } from "./display_utils.js";
|
1018
|
+
import { AnnotationStorage } from "./annotation_storage.js";
|
1019
|
+
import { OptionalContentConfig } from "./optional_content_config.js";
|
1020
|
+
/**
|
1021
|
+
* The loading task controls the operations required to load a PDF document
|
1022
|
+
* (such as network requests) and provides a way to listen for completion,
|
1023
|
+
* after which individual pages can be rendered.
|
1024
|
+
*
|
1025
|
+
* @typedef {Object} PDFDocumentLoadingTask
|
1026
|
+
* @property {string} docId - Unique identifier for the document loading task.
|
1027
|
+
* @property {boolean} destroyed - Whether the loading task is destroyed or not.
|
1028
|
+
* @property {function} [onPassword] - Callback to request a password if a wrong
|
1029
|
+
* or no password was provided. The callback receives two parameters: a
|
1030
|
+
* function that should be called with the new password, and a reason (see
|
1031
|
+
* {@link PasswordResponses}).
|
1032
|
+
* @property {function} [onProgress] - Callback to be able to monitor the
|
1033
|
+
* loading progress of the PDF file (necessary to implement e.g. a loading
|
1034
|
+
* bar). The callback receives an {Object} with the properties `loaded`
|
1035
|
+
* ({number}) and `total` ({number}) that indicate how many bytes are loaded.
|
1036
|
+
* @property {function} [onUnsupportedFeature] - Callback for when an
|
1037
|
+
* unsupported feature is used in the PDF document. The callback receives an
|
1038
|
+
* {@link UNSUPPORTED_FEATURES} argument.
|
1039
|
+
* @property {Promise<PDFDocumentProxy>} promise - Promise for document loading
|
1040
|
+
* task completion.
|
1041
|
+
* @property {function} destroy - Abort all network requests and destroy
|
1042
|
+
* the worker. Returns a promise that is resolved when destruction is
|
1043
|
+
* completed.
|
1044
|
+
*/
|
1045
|
+
/**
|
1046
|
+
* @type {any}
|
1047
|
+
* @ignore
|
1048
|
+
*/
|
1049
|
+
declare const PDFDocumentLoadingTask: any;
|
1050
|
+
import { info } from "../shared/util.js";
|
1051
|
+
import { Metadata } from "./metadata.js";
|
1052
|
+
import { StatTimer } from "./display_utils.js";
|
1053
|
+
/**
|
1054
|
+
* A PDF document and page is built of many objects. E.g. there are objects for
|
1055
|
+
* fonts, images, rendering code, etc. These objects may get processed inside of
|
1056
|
+
* a worker. This class implements some basic methods to manage these objects.
|
1057
|
+
* @ignore
|
1058
|
+
*/
|
1059
|
+
declare class PDFObjects {
|
1060
|
+
_objs: any;
|
1061
|
+
/**
|
1062
|
+
* Ensures there is an object defined for `objId`.
|
1063
|
+
* @private
|
1064
|
+
*/
|
1065
|
+
private _ensureObj;
|
1066
|
+
/**
|
1067
|
+
* If called *without* callback, this returns the data of `objId` but the
|
1068
|
+
* object needs to be resolved. If it isn't, this method throws.
|
1069
|
+
*
|
1070
|
+
* If called *with* a callback, the callback is called with the data of the
|
1071
|
+
* object once the object is resolved. That means, if you call this method
|
1072
|
+
* and the object is already resolved, the callback gets called right away.
|
1073
|
+
*/
|
1074
|
+
get(objId: any, callback?: any): any;
|
1075
|
+
has(objId: any): any;
|
1076
|
+
/**
|
1077
|
+
* Resolves the object `objId` with optional `data`.
|
1078
|
+
*/
|
1079
|
+
resolve(objId: any, data: any): void;
|
1080
|
+
clear(): void;
|
1081
|
+
}
|
1082
|
+
/**
|
1083
|
+
* Allows controlling of the rendering tasks.
|
1084
|
+
*/
|
1085
|
+
declare class RenderTask {
|
1086
|
+
constructor(internalRenderTask: any);
|
1087
|
+
_internalRenderTask: any;
|
1088
|
+
/**
|
1089
|
+
* Callback for incremental rendering -- a function that will be called
|
1090
|
+
* each time the rendering is paused. To continue rendering call the
|
1091
|
+
* function that is the first argument to the callback.
|
1092
|
+
* @type {function}
|
1093
|
+
*/
|
1094
|
+
onContinue: Function;
|
1095
|
+
/**
|
1096
|
+
* Promise for rendering task completion.
|
1097
|
+
* @type {Promise<void>}
|
1098
|
+
*/
|
1099
|
+
get promise(): Promise<void>;
|
1100
|
+
/**
|
1101
|
+
* Cancels the rendering task. If the task is currently rendering it will
|
1102
|
+
* not be cancelled until graphics pauses with a timeout. The promise that
|
1103
|
+
* this object extends will be rejected when cancelled.
|
1104
|
+
*/
|
1105
|
+
cancel(): void;
|
1106
|
+
}
|
1107
|
+
export {};
|