@vaadin-component-factory/vcf-pdf-viewer 0.9.0 → 1.0.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 (172) hide show
  1. package/README.md +1 -1
  2. package/package.json +42 -26
  3. package/{src/display → pdfjs/dist}/display_utils.js +344 -139
  4. package/{src/display → pdfjs/dist}/fetch_stream.js +115 -97
  5. package/pdfjs/dist/l10n_utils.js +140 -0
  6. package/{src/shared → pdfjs/dist}/message_handler.js +243 -259
  7. package/{src/display → pdfjs/dist}/network.js +149 -87
  8. package/{src/display/content_disposition.js → pdfjs/dist/network_utils.js} +167 -55
  9. package/{src/display → pdfjs/dist}/node_stream.js +133 -98
  10. package/pdfjs/dist/pdf.js +12778 -0
  11. package/pdfjs/dist/pdf_link_service.js +638 -0
  12. package/pdfjs/dist/pdf_rendering_queue.js +199 -0
  13. package/pdfjs/dist/pdf_thumbnail_viewer.js +819 -0
  14. package/pdfjs/dist/pdf_viewer.js +3598 -0
  15. package/pdfjs/dist/ui_utils.js +1033 -0
  16. package/{src/shared → pdfjs/dist}/util.js +301 -287
  17. package/pdfjs/dist/worker.js +62813 -0
  18. package/src/vcf-pdf-viewer.js +98 -46
  19. package/theme/lumo/vcf-pdf-viewer-styles.js +4 -4
  20. package/theme/material/vcf-pdf-viewer-styles.js +4 -4
  21. package/theme/material/vcf-pdf-viewer.js +2 -2
  22. package/src/core/.eslintrc +0 -13
  23. package/src/core/annotation.js +0 -2948
  24. package/src/core/arithmetic_decoder.js +0 -182
  25. package/src/core/ascii_85_stream.js +0 -98
  26. package/src/core/ascii_hex_stream.js +0 -79
  27. package/src/core/base_stream.js +0 -110
  28. package/src/core/bidi.js +0 -438
  29. package/src/core/calibri_factors.js +0 -308
  30. package/src/core/catalog.js +0 -1459
  31. package/src/core/ccitt.js +0 -1062
  32. package/src/core/ccitt_stream.js +0 -60
  33. package/src/core/cff_font.js +0 -116
  34. package/src/core/cff_parser.js +0 -1949
  35. package/src/core/charsets.js +0 -119
  36. package/src/core/chunked_stream.js +0 -557
  37. package/src/core/cmap.js +0 -1039
  38. package/src/core/colorspace.js +0 -1533
  39. package/src/core/core_utils.js +0 -464
  40. package/src/core/crypto.js +0 -1900
  41. package/src/core/decode_stream.js +0 -170
  42. package/src/core/decrypt_stream.js +0 -59
  43. package/src/core/default_appearance.js +0 -99
  44. package/src/core/document.js +0 -1456
  45. package/src/core/encodings.js +0 -301
  46. package/src/core/evaluator.js +0 -4601
  47. package/src/core/file_spec.js +0 -108
  48. package/src/core/flate_stream.js +0 -402
  49. package/src/core/font_renderer.js +0 -882
  50. package/src/core/fonts.js +0 -3260
  51. package/src/core/fonts_utils.js +0 -221
  52. package/src/core/function.js +0 -1257
  53. package/src/core/glyf.js +0 -706
  54. package/src/core/glyphlist.js +0 -4558
  55. package/src/core/helvetica_factors.js +0 -353
  56. package/src/core/image.js +0 -802
  57. package/src/core/image_utils.js +0 -291
  58. package/src/core/jbig2.js +0 -2572
  59. package/src/core/jbig2_stream.js +0 -73
  60. package/src/core/jpeg_stream.js +0 -105
  61. package/src/core/jpg.js +0 -1416
  62. package/src/core/jpx.js +0 -2343
  63. package/src/core/jpx_stream.js +0 -87
  64. package/src/core/liberationsans_widths.js +0 -221
  65. package/src/core/lzw_stream.js +0 -150
  66. package/src/core/metadata_parser.js +0 -146
  67. package/src/core/metrics.js +0 -2970
  68. package/src/core/murmurhash3.js +0 -139
  69. package/src/core/myriadpro_factors.js +0 -290
  70. package/src/core/name_number_tree.js +0 -153
  71. package/src/core/object_loader.js +0 -149
  72. package/src/core/opentype_file_builder.js +0 -154
  73. package/src/core/operator_list.js +0 -734
  74. package/src/core/parser.js +0 -1416
  75. package/src/core/pattern.js +0 -985
  76. package/src/core/pdf_manager.js +0 -217
  77. package/src/core/predictor_stream.js +0 -238
  78. package/src/core/primitives.js +0 -402
  79. package/src/core/ps_parser.js +0 -272
  80. package/src/core/run_length_stream.js +0 -61
  81. package/src/core/segoeui_factors.js +0 -308
  82. package/src/core/standard_fonts.js +0 -817
  83. package/src/core/stream.js +0 -103
  84. package/src/core/struct_tree.js +0 -335
  85. package/src/core/to_unicode_map.js +0 -103
  86. package/src/core/type1_font.js +0 -421
  87. package/src/core/type1_parser.js +0 -776
  88. package/src/core/unicode.js +0 -1649
  89. package/src/core/worker.js +0 -848
  90. package/src/core/worker_stream.js +0 -135
  91. package/src/core/writer.js +0 -278
  92. package/src/core/xfa/bind.js +0 -652
  93. package/src/core/xfa/builder.js +0 -207
  94. package/src/core/xfa/config.js +0 -1926
  95. package/src/core/xfa/connection_set.js +0 -202
  96. package/src/core/xfa/data.js +0 -82
  97. package/src/core/xfa/datasets.js +0 -76
  98. package/src/core/xfa/factory.js +0 -111
  99. package/src/core/xfa/fonts.js +0 -181
  100. package/src/core/xfa/formcalc_lexer.js +0 -385
  101. package/src/core/xfa/formcalc_parser.js +0 -1340
  102. package/src/core/xfa/html_utils.js +0 -639
  103. package/src/core/xfa/layout.js +0 -383
  104. package/src/core/xfa/locale_set.js +0 -345
  105. package/src/core/xfa/namespaces.js +0 -81
  106. package/src/core/xfa/parser.js +0 -184
  107. package/src/core/xfa/setup.js +0 -38
  108. package/src/core/xfa/signature.js +0 -40
  109. package/src/core/xfa/som.js +0 -338
  110. package/src/core/xfa/stylesheet.js +0 -40
  111. package/src/core/xfa/template.js +0 -6260
  112. package/src/core/xfa/text.js +0 -290
  113. package/src/core/xfa/unknown.js +0 -29
  114. package/src/core/xfa/utils.js +0 -217
  115. package/src/core/xfa/xdp.js +0 -59
  116. package/src/core/xfa/xfa_object.js +0 -1130
  117. package/src/core/xfa/xhtml.js +0 -543
  118. package/src/core/xfa_fonts.js +0 -208
  119. package/src/core/xml_parser.js +0 -507
  120. package/src/core/xref.js +0 -899
  121. package/src/display/annotation_layer.js +0 -2107
  122. package/src/display/annotation_storage.js +0 -113
  123. package/src/display/api.js +0 -3292
  124. package/src/display/base_factory.js +0 -180
  125. package/src/display/canvas.js +0 -2828
  126. package/src/display/font_loader.js +0 -484
  127. package/src/display/metadata.js +0 -41
  128. package/src/display/network_utils.js +0 -100
  129. package/src/display/node_utils.js +0 -83
  130. package/src/display/optional_content_config.js +0 -189
  131. package/src/display/pattern_helper.js +0 -659
  132. package/src/display/svg.js +0 -1709
  133. package/src/display/text_layer.js +0 -847
  134. package/src/display/transport_stream.js +0 -303
  135. package/src/display/worker_options.js +0 -40
  136. package/src/display/xfa_layer.js +0 -204
  137. package/src/doc_helper.js +0 -25
  138. package/src/images/logo.svg +0 -41
  139. package/src/interfaces.js +0 -169
  140. package/src/license_header.js +0 -14
  141. package/src/license_header_libre.js +0 -21
  142. package/src/pdf.image_decoders.js +0 -46
  143. package/src/pdf.js +0 -146
  144. package/src/pdf.sandbox.external.js +0 -181
  145. package/src/pdf.sandbox.js +0 -151
  146. package/src/pdf.scripting.js +0 -25
  147. package/src/pdf.worker.entry.js +0 -19
  148. package/src/pdf.worker.js +0 -23
  149. package/src/scripting_api/aform.js +0 -608
  150. package/src/scripting_api/app.js +0 -621
  151. package/src/scripting_api/color.js +0 -129
  152. package/src/scripting_api/common.js +0 -58
  153. package/src/scripting_api/console.js +0 -38
  154. package/src/scripting_api/constants.js +0 -208
  155. package/src/scripting_api/doc.js +0 -1195
  156. package/src/scripting_api/error.js +0 -23
  157. package/src/scripting_api/event.js +0 -232
  158. package/src/scripting_api/field.js +0 -620
  159. package/src/scripting_api/fullscreen.js +0 -145
  160. package/src/scripting_api/initialization.js +0 -223
  161. package/src/scripting_api/pdf_object.js +0 -24
  162. package/src/scripting_api/print_params.js +0 -146
  163. package/src/scripting_api/proxy.js +0 -139
  164. package/src/scripting_api/thermometer.js +0 -69
  165. package/src/scripting_api/util.js +0 -581
  166. package/src/shared/.eslintrc +0 -13
  167. package/src/shared/cffStandardStrings.js +0 -311
  168. package/src/shared/compatibility.js +0 -114
  169. package/src/shared/fonts_utils.js +0 -429
  170. package/src/shared/is_node.js +0 -27
  171. package/src/shared/scripting_utils.js +0 -85
  172. package/src/worker_loader.js +0 -32
@@ -1,1195 +0,0 @@
1
- /* Copyright 2020 Mozilla Foundation
2
- *
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
-
16
- import { createActionsMap } from "./common.js";
17
- import { PDFObject } from "./pdf_object.js";
18
- import { PrintParams } from "./print_params.js";
19
- import { ZoomType } from "./constants.js";
20
-
21
- class InfoProxyHandler {
22
- static get(obj, prop) {
23
- return obj[prop.toLowerCase()];
24
- }
25
-
26
- static set(obj, prop, value) {
27
- throw new Error(`doc.info.${prop} is read-only`);
28
- }
29
- }
30
-
31
- class Doc extends PDFObject {
32
- constructor(data) {
33
- super(data);
34
-
35
- // In a script doc === this.
36
- // So adding a property to the doc means adding it to this
37
- this._expandos = globalThis;
38
-
39
- this._baseURL = data.baseURL || "";
40
- this._calculate = true;
41
- this._delay = false;
42
- this._dirty = false;
43
- this._disclosed = false;
44
- this._media = undefined;
45
- this._metadata = data.metadata || "";
46
- this._noautocomplete = undefined;
47
- this._nocache = undefined;
48
- this._spellDictionaryOrder = [];
49
- this._spellLanguageOrder = [];
50
-
51
- this._printParams = null;
52
- this._fields = new Map();
53
- this._fieldNames = [];
54
- this._event = null;
55
-
56
- this._author = data.Author || "";
57
- this._creator = data.Creator || "";
58
- this._creationDate = this._getDate(data.CreationDate) || null;
59
- this._docID = data.docID || ["", ""];
60
- this._documentFileName = data.filename || "";
61
- this._filesize = data.filesize || 0;
62
- this._keywords = data.Keywords || "";
63
- this._layout = data.layout || "";
64
- this._modDate = this._getDate(data.ModDate) || null;
65
- this._numFields = 0;
66
- this._numPages = data.numPages || 1;
67
- this._pageNum = data.pageNum || 0;
68
- this._producer = data.Producer || "";
69
- this._subject = data.Subject || "";
70
- this._title = data.Title || "";
71
- this._URL = data.URL || "";
72
-
73
- // info has case insensitive properties
74
- // and they're are read-only.
75
- this._info = new Proxy(
76
- {
77
- title: this._title,
78
- author: this._author,
79
- authors: data.authors || [this._author],
80
- subject: this._subject,
81
- keywords: this._keywords,
82
- creator: this._creator,
83
- producer: this._producer,
84
- creationdate: this._creationDate,
85
- moddate: this._modDate,
86
- trapped: data.Trapped || "Unknown",
87
- },
88
- InfoProxyHandler
89
- );
90
-
91
- this._zoomType = ZoomType.none;
92
- this._zoom = data.zoom || 100;
93
- this._actions = createActionsMap(data.actions);
94
- this._globalEval = data.globalEval;
95
- this._pageActions = new Map();
96
- }
97
-
98
- _dispatchDocEvent(name) {
99
- if (name === "Open") {
100
- const dontRun = new Set([
101
- "WillClose",
102
- "WillSave",
103
- "DidSave",
104
- "WillPrint",
105
- "DidPrint",
106
- "OpenAction",
107
- ]);
108
- for (const actionName of this._actions.keys()) {
109
- if (!dontRun.has(actionName)) {
110
- this._runActions(actionName);
111
- }
112
- }
113
- this._runActions("OpenAction");
114
- } else {
115
- this._runActions(name);
116
- }
117
- }
118
-
119
- _dispatchPageEvent(name, actions, pageNumber) {
120
- if (name === "PageOpen") {
121
- if (!this._pageActions.has(pageNumber)) {
122
- this._pageActions.set(pageNumber, createActionsMap(actions));
123
- }
124
- this._pageNum = pageNumber - 1;
125
- }
126
-
127
- actions = this._pageActions.get(pageNumber)?.get(name);
128
- if (actions) {
129
- for (const action of actions) {
130
- this._globalEval(action);
131
- }
132
- }
133
- }
134
-
135
- _runActions(name) {
136
- const actions = this._actions.get(name);
137
- if (actions) {
138
- for (const action of actions) {
139
- this._globalEval(action);
140
- }
141
- }
142
- }
143
-
144
- _addField(name, field) {
145
- this._fields.set(name, field);
146
- this._fieldNames.push(name);
147
- this._numFields++;
148
- }
149
-
150
- _getDate(date) {
151
- // date format is D:YYYYMMDDHHmmSS[OHH'mm']
152
- if (!date || date.length < 15 || !date.startsWith("D:")) {
153
- return date;
154
- }
155
-
156
- date = date.substring(2);
157
- const year = date.substring(0, 4);
158
- const month = date.substring(4, 6);
159
- const day = date.substring(6, 8);
160
- const hour = date.substring(8, 10);
161
- const minute = date.substring(10, 12);
162
- const o = date.charAt(12);
163
- let second, offsetPos;
164
- if (o === "Z" || o === "+" || o === "-") {
165
- second = "00";
166
- offsetPos = 12;
167
- } else {
168
- second = date.substring(12, 14);
169
- offsetPos = 14;
170
- }
171
- const offset = date.substring(offsetPos).replaceAll("'", "");
172
- return new Date(
173
- `${year}-${month}-${day}T${hour}:${minute}:${second}${offset}`
174
- );
175
- }
176
-
177
- get author() {
178
- return this._author;
179
- }
180
-
181
- set author(_) {
182
- throw new Error("doc.author is read-only");
183
- }
184
-
185
- get baseURL() {
186
- return this._baseURL;
187
- }
188
-
189
- set baseURL(baseURL) {
190
- this._baseURL = baseURL;
191
- }
192
-
193
- get bookmarkRoot() {
194
- return undefined;
195
- }
196
-
197
- set bookmarkRoot(_) {
198
- throw new Error("doc.bookmarkRoot is read-only");
199
- }
200
-
201
- get calculate() {
202
- return this._calculate;
203
- }
204
-
205
- set calculate(calculate) {
206
- this._calculate = calculate;
207
- }
208
-
209
- get creator() {
210
- return this._creator;
211
- }
212
-
213
- set creator(_) {
214
- throw new Error("doc.creator is read-only");
215
- }
216
-
217
- get dataObjects() {
218
- return [];
219
- }
220
-
221
- set dataObjects(_) {
222
- throw new Error("doc.dataObjects is read-only");
223
- }
224
-
225
- get delay() {
226
- return this._delay;
227
- }
228
-
229
- set delay(delay) {
230
- this._delay = delay;
231
- }
232
-
233
- get dirty() {
234
- return this._dirty;
235
- }
236
-
237
- set dirty(dirty) {
238
- this._dirty = dirty;
239
- }
240
-
241
- get disclosed() {
242
- return this._disclosed;
243
- }
244
-
245
- set disclosed(disclosed) {
246
- this._disclosed = disclosed;
247
- }
248
-
249
- get docID() {
250
- return this._docID;
251
- }
252
-
253
- set docID(_) {
254
- throw new Error("doc.docID is read-only");
255
- }
256
-
257
- get documentFileName() {
258
- return this._documentFileName;
259
- }
260
-
261
- set documentFileName(_) {
262
- throw new Error("doc.documentFileName is read-only");
263
- }
264
-
265
- get dynamicXFAForm() {
266
- return false;
267
- }
268
-
269
- set dynamicXFAForm(_) {
270
- throw new Error("doc.dynamicXFAForm is read-only");
271
- }
272
-
273
- get external() {
274
- return true;
275
- }
276
-
277
- set external(_) {
278
- throw new Error("doc.external is read-only");
279
- }
280
-
281
- get filesize() {
282
- return this._filesize;
283
- }
284
-
285
- set filesize(_) {
286
- throw new Error("doc.filesize is read-only");
287
- }
288
-
289
- get hidden() {
290
- return false;
291
- }
292
-
293
- set hidden(_) {
294
- throw new Error("doc.hidden is read-only");
295
- }
296
-
297
- get hostContainer() {
298
- return undefined;
299
- }
300
-
301
- set hostContainer(_) {
302
- throw new Error("doc.hostContainer is read-only");
303
- }
304
-
305
- get icons() {
306
- return undefined;
307
- }
308
-
309
- set icons(_) {
310
- throw new Error("doc.icons is read-only");
311
- }
312
-
313
- get info() {
314
- return this._info;
315
- }
316
-
317
- set info(_) {
318
- throw new Error("doc.info is read-only");
319
- }
320
-
321
- get innerAppWindowRect() {
322
- return [0, 0, 0, 0];
323
- }
324
-
325
- set innerAppWindowRect(_) {
326
- throw new Error("doc.innerAppWindowRect is read-only");
327
- }
328
-
329
- get innerDocWindowRect() {
330
- return [0, 0, 0, 0];
331
- }
332
-
333
- set innerDocWindowRect(_) {
334
- throw new Error("doc.innerDocWindowRect is read-only");
335
- }
336
-
337
- get isModal() {
338
- return false;
339
- }
340
-
341
- set isModal(_) {
342
- throw new Error("doc.isModal is read-only");
343
- }
344
-
345
- get keywords() {
346
- return this._keywords;
347
- }
348
-
349
- set keywords(_) {
350
- throw new Error("doc.keywords is read-only");
351
- }
352
-
353
- get layout() {
354
- return this._layout;
355
- }
356
-
357
- set layout(value) {
358
- if (typeof value !== "string") {
359
- return;
360
- }
361
-
362
- if (
363
- value !== "SinglePage" &&
364
- value !== "OneColumn" &&
365
- value !== "TwoColumnLeft" &&
366
- value !== "TwoPageLeft" &&
367
- value !== "TwoColumnRight" &&
368
- value !== "TwoPageRight"
369
- ) {
370
- value = "SinglePage";
371
- }
372
- this._send({ command: "layout", value });
373
- this._layout = value;
374
- }
375
-
376
- get media() {
377
- return this._media;
378
- }
379
-
380
- set media(media) {
381
- this._media = media;
382
- }
383
-
384
- get metadata() {
385
- return this._metadata;
386
- }
387
-
388
- set metadata(metadata) {
389
- this._metadata = metadata;
390
- }
391
-
392
- get modDate() {
393
- return this._modDate;
394
- }
395
-
396
- set modDate(_) {
397
- throw new Error("doc.modDate is read-only");
398
- }
399
-
400
- get mouseX() {
401
- return 0;
402
- }
403
-
404
- set mouseX(_) {
405
- throw new Error("doc.mouseX is read-only");
406
- }
407
-
408
- get mouseY() {
409
- return 0;
410
- }
411
-
412
- set mouseY(_) {
413
- throw new Error("doc.mouseY is read-only");
414
- }
415
-
416
- get noautocomplete() {
417
- return this._noautocomplete;
418
- }
419
-
420
- set noautocomplete(noautocomplete) {
421
- this._noautocomplete = noautocomplete;
422
- }
423
-
424
- get nocache() {
425
- return this._nocache;
426
- }
427
-
428
- set nocache(nocache) {
429
- this._nocache = nocache;
430
- }
431
-
432
- get numFields() {
433
- return this._numFields;
434
- }
435
-
436
- set numFields(_) {
437
- throw new Error("doc.numFields is read-only");
438
- }
439
-
440
- get numPages() {
441
- return this._numPages;
442
- }
443
-
444
- set numPages(_) {
445
- throw new Error("doc.numPages is read-only");
446
- }
447
-
448
- get numTemplates() {
449
- return 0;
450
- }
451
-
452
- set numTemplates(_) {
453
- throw new Error("doc.numTemplates is read-only");
454
- }
455
-
456
- get outerAppWindowRect() {
457
- return [0, 0, 0, 0];
458
- }
459
-
460
- set outerAppWindowRect(_) {
461
- throw new Error("doc.outerAppWindowRect is read-only");
462
- }
463
-
464
- get outerDocWindowRect() {
465
- return [0, 0, 0, 0];
466
- }
467
-
468
- set outerDocWindowRect(_) {
469
- throw new Error("doc.outerDocWindowRect is read-only");
470
- }
471
-
472
- get pageNum() {
473
- return this._pageNum;
474
- }
475
-
476
- set pageNum(value) {
477
- if (typeof value !== "number" || value < 0 || value >= this._numPages) {
478
- return;
479
- }
480
- this._send({ command: "page-num", value });
481
- this._pageNum = value;
482
- }
483
-
484
- get pageWindowRect() {
485
- return [0, 0, 0, 0];
486
- }
487
-
488
- set pageWindowRect(_) {
489
- throw new Error("doc.pageWindowRect is read-only");
490
- }
491
-
492
- get path() {
493
- return "";
494
- }
495
-
496
- set path(_) {
497
- throw new Error("doc.path is read-only");
498
- }
499
-
500
- get permStatusReady() {
501
- return true;
502
- }
503
-
504
- set permStatusReady(_) {
505
- throw new Error("doc.permStatusReady is read-only");
506
- }
507
-
508
- get producer() {
509
- return this._producer;
510
- }
511
-
512
- set producer(_) {
513
- throw new Error("doc.producer is read-only");
514
- }
515
-
516
- get requiresFullSave() {
517
- return false;
518
- }
519
-
520
- set requiresFullSave(_) {
521
- throw new Error("doc.requiresFullSave is read-only");
522
- }
523
-
524
- get securityHandler() {
525
- return null;
526
- }
527
-
528
- set securityHandler(_) {
529
- throw new Error("doc.securityHandler is read-only");
530
- }
531
-
532
- get selectedAnnots() {
533
- return [];
534
- }
535
-
536
- set selectedAnnots(_) {
537
- throw new Error("doc.selectedAnnots is read-only");
538
- }
539
-
540
- get sounds() {
541
- return [];
542
- }
543
-
544
- set sounds(_) {
545
- throw new Error("doc.sounds is read-only");
546
- }
547
-
548
- get spellDictionaryOrder() {
549
- return this._spellDictionaryOrder;
550
- }
551
-
552
- set spellDictionaryOrder(spellDictionaryOrder) {
553
- this._spellDictionaryOrder = spellDictionaryOrder;
554
- }
555
-
556
- get spellLanguageOrder() {
557
- return this._spellLanguageOrder;
558
- }
559
-
560
- set spellLanguageOrder(spellLanguageOrder) {
561
- this._spellLanguageOrder = spellLanguageOrder;
562
- }
563
-
564
- get subject() {
565
- return this._subject;
566
- }
567
-
568
- set subject(_) {
569
- throw new Error("doc.subject is read-only");
570
- }
571
-
572
- get templates() {
573
- return [];
574
- }
575
-
576
- set templates(_) {
577
- throw new Error("doc.templates is read-only");
578
- }
579
-
580
- get title() {
581
- return this._title;
582
- }
583
-
584
- set title(_) {
585
- throw new Error("doc.title is read-only");
586
- }
587
-
588
- get URL() {
589
- return this._URL;
590
- }
591
-
592
- set URL(_) {
593
- throw new Error("doc.URL is read-only");
594
- }
595
-
596
- get viewState() {
597
- return undefined;
598
- }
599
-
600
- set viewState(_) {
601
- throw new Error("doc.viewState is read-only");
602
- }
603
-
604
- get xfa() {
605
- return this._xfa;
606
- }
607
-
608
- set xfa(_) {
609
- throw new Error("doc.xfa is read-only");
610
- }
611
-
612
- get XFAForeground() {
613
- return false;
614
- }
615
-
616
- set XFAForeground(_) {
617
- throw new Error("doc.XFAForeground is read-only");
618
- }
619
-
620
- get zoomType() {
621
- return this._zoomType;
622
- }
623
-
624
- set zoomType(type) {
625
- if (typeof type !== "string") {
626
- return;
627
- }
628
- switch (type) {
629
- case ZoomType.none:
630
- this._send({ command: "zoom", value: 1 });
631
- break;
632
- case ZoomType.fitP:
633
- this._send({ command: "zoom", value: "page-fit" });
634
- break;
635
- case ZoomType.fitW:
636
- this._send({ command: "zoom", value: "page-width" });
637
- break;
638
- case ZoomType.fitH:
639
- this._send({ command: "zoom", value: "page-height" });
640
- break;
641
- case ZoomType.fitV:
642
- this._send({ command: "zoom", value: "auto" });
643
- break;
644
- case ZoomType.pref:
645
- case ZoomType.refW:
646
- break;
647
- default:
648
- return;
649
- }
650
-
651
- this._zoomType = type;
652
- }
653
-
654
- get zoom() {
655
- return this._zoom;
656
- }
657
-
658
- set zoom(value) {
659
- if (typeof value !== "number" || value < 8.33 || value > 6400) {
660
- return;
661
- }
662
-
663
- this._send({ command: "zoom", value: value / 100 });
664
- }
665
-
666
- addAnnot() {
667
- /* Not implemented */
668
- }
669
-
670
- addField() {
671
- /* Not implemented */
672
- }
673
-
674
- addIcon() {
675
- /* Not implemented */
676
- }
677
-
678
- addLink() {
679
- /* Not implemented */
680
- }
681
-
682
- addRecipientListCryptFilter() {
683
- /* Not implemented */
684
- }
685
-
686
- addRequirement() {
687
- /* Not implemented */
688
- }
689
-
690
- addScript() {
691
- /* Not implemented */
692
- }
693
-
694
- addThumbnails() {
695
- /* Not implemented */
696
- }
697
-
698
- addWatermarkFromFile() {
699
- /* Not implemented */
700
- }
701
-
702
- addWatermarkFromText() {
703
- /* Not implemented */
704
- }
705
-
706
- addWeblinks() {
707
- /* Not implemented */
708
- }
709
-
710
- bringToFront() {
711
- /* Not implemented */
712
- }
713
-
714
- calculateNow() {
715
- this._eventDispatcher.calculateNow();
716
- }
717
-
718
- closeDoc() {
719
- /* Not implemented */
720
- }
721
-
722
- colorConvertPage() {
723
- /* Not implemented */
724
- }
725
-
726
- createDataObject() {
727
- /* Not implemented */
728
- }
729
-
730
- createTemplate() {
731
- /* Not implemented */
732
- }
733
-
734
- deletePages() {
735
- /* Not implemented */
736
- }
737
-
738
- deleteSound() {
739
- /* Not implemented */
740
- }
741
-
742
- embedDocAsDataObject() {
743
- /* Not implemented */
744
- }
745
-
746
- embedOutputIntent() {
747
- /* Not implemented */
748
- }
749
-
750
- encryptForRecipients() {
751
- /* Not implemented */
752
- }
753
-
754
- encryptUsingPolicy() {
755
- /* Not implemented */
756
- }
757
-
758
- exportAsFDF() {
759
- /* Not implemented */
760
- }
761
-
762
- exportAsFDFStr() {
763
- /* Not implemented */
764
- }
765
-
766
- exportAsText() {
767
- /* Not implemented */
768
- }
769
-
770
- exportAsXFDF() {
771
- /* Not implemented */
772
- }
773
-
774
- exportAsXFDFStr() {
775
- /* Not implemented */
776
- }
777
-
778
- exportDataObject() {
779
- /* Not implemented */
780
- }
781
-
782
- exportXFAData() {
783
- /* Not implemented */
784
- }
785
-
786
- extractPages() {
787
- /* Not implemented */
788
- }
789
-
790
- flattenPages() {
791
- /* Not implemented */
792
- }
793
-
794
- getAnnot() {
795
- /* TODO */
796
- }
797
-
798
- getAnnots() {
799
- /* TODO */
800
- }
801
-
802
- getAnnot3D() {
803
- /* Not implemented */
804
- }
805
-
806
- getAnnots3D() {
807
- /* Not implemented */
808
- }
809
-
810
- getColorConvertAction() {
811
- /* Not implemented */
812
- }
813
-
814
- getDataObject() {
815
- /* Not implemented */
816
- }
817
-
818
- getDataObjectContents() {
819
- /* Not implemented */
820
- }
821
-
822
- getField(cName) {
823
- if (typeof cName === "object") {
824
- cName = cName.cName;
825
- }
826
- if (typeof cName !== "string") {
827
- throw new TypeError("Invalid field name: must be a string");
828
- }
829
- const searchedField = this._fields.get(cName);
830
- if (searchedField) {
831
- return searchedField;
832
- }
833
-
834
- const parts = cName.split("#");
835
- let childIndex = NaN;
836
- if (parts.length === 2) {
837
- childIndex = Math.floor(parseFloat(parts[1]));
838
- cName = parts[0];
839
- }
840
-
841
- for (const [name, field] of this._fields.entries()) {
842
- if (name.endsWith(cName)) {
843
- if (!isNaN(childIndex)) {
844
- const children = this._getChildren(name);
845
- if (childIndex < 0 || childIndex >= children.length) {
846
- childIndex = 0;
847
- }
848
- if (childIndex < children.length) {
849
- this._fields.set(cName, children[childIndex]);
850
- return children[childIndex];
851
- }
852
- }
853
- this._fields.set(cName, field);
854
- return field;
855
- }
856
- }
857
-
858
- return null;
859
- }
860
-
861
- _getChildren(fieldName) {
862
- // Children of foo.bar are foo.bar.oof, foo.bar.rab
863
- // but not foo.bar.oof.FOO.
864
- const len = fieldName.length;
865
- const children = [];
866
- const pattern = /^\.[^.]+$/;
867
- for (const [name, field] of this._fields.entries()) {
868
- if (name.startsWith(fieldName)) {
869
- const finalPart = name.slice(len);
870
- if (finalPart.match(pattern)) {
871
- children.push(field);
872
- }
873
- }
874
- }
875
- return children;
876
- }
877
-
878
- getIcon() {
879
- /* Not implemented */
880
- }
881
-
882
- getLegalWarnings() {
883
- /* Not implemented */
884
- }
885
-
886
- getLinks() {
887
- /* Not implemented */
888
- }
889
-
890
- getNthFieldName(nIndex) {
891
- if (typeof nIndex === "object") {
892
- nIndex = nIndex.nIndex;
893
- }
894
- if (typeof nIndex !== "number") {
895
- throw new TypeError("Invalid field index: must be a number");
896
- }
897
- if (0 <= nIndex && nIndex < this.numFields) {
898
- return this._fieldNames[Math.trunc(nIndex)];
899
- }
900
- return null;
901
- }
902
-
903
- getNthTemplate() {
904
- return null;
905
- }
906
-
907
- getOCGs() {
908
- /* Not implemented */
909
- }
910
-
911
- getOCGOrder() {
912
- /* Not implemented */
913
- }
914
-
915
- getPageBox() {
916
- /* TODO */
917
- }
918
-
919
- getPageLabel() {
920
- /* TODO */
921
- }
922
-
923
- getPageNthWord() {
924
- /* TODO or not */
925
- }
926
-
927
- getPageNthWordQuads() {
928
- /* TODO or not */
929
- }
930
-
931
- getPageNumWords() {
932
- /* TODO or not */
933
- }
934
-
935
- getPageRotation() {
936
- /* TODO */
937
- }
938
-
939
- getPageTransition() {
940
- /* Not implemented */
941
- }
942
-
943
- getPrintParams() {
944
- if (!this._printParams) {
945
- this._printParams = new PrintParams({ lastPage: this._numPages - 1 });
946
- }
947
- return this._printParams;
948
- }
949
-
950
- getSound() {
951
- /* Not implemented */
952
- }
953
-
954
- getTemplate() {
955
- /* Not implemented */
956
- }
957
-
958
- getURL() {
959
- /* Not implemented because unsafe */
960
- }
961
-
962
- gotoNamedDest() {
963
- /* TODO */
964
- }
965
-
966
- importAnFDF() {
967
- /* Not implemented */
968
- }
969
-
970
- importAnXFDF() {
971
- /* Not implemented */
972
- }
973
-
974
- importDataObject() {
975
- /* Not implemented */
976
- }
977
-
978
- importIcon() {
979
- /* Not implemented */
980
- }
981
-
982
- importSound() {
983
- /* Not implemented */
984
- }
985
-
986
- importTextData() {
987
- /* Not implemented */
988
- }
989
-
990
- importXFAData() {
991
- /* Not implemented */
992
- }
993
-
994
- insertPages() {
995
- /* Not implemented */
996
- }
997
-
998
- mailDoc() {
999
- /* TODO or not */
1000
- }
1001
-
1002
- mailForm() {
1003
- /* TODO or not */
1004
- }
1005
-
1006
- movePage() {
1007
- /* Not implemented */
1008
- }
1009
-
1010
- newPage() {
1011
- /* Not implemented */
1012
- }
1013
-
1014
- openDataObject() {
1015
- /* Not implemented */
1016
- }
1017
-
1018
- print(
1019
- bUI = true,
1020
- nStart = 0,
1021
- nEnd = -1,
1022
- bSilent = false,
1023
- bShrinkToFit = false,
1024
- bPrintAsImage = false,
1025
- bReverse = false,
1026
- bAnnotations = true,
1027
- printParams = null
1028
- ) {
1029
- if (typeof bUI === "object") {
1030
- nStart = bUI.nStart;
1031
- nEnd = bUI.nEnd;
1032
- bSilent = bUI.bSilent;
1033
- bShrinkToFit = bUI.bShrinkToFit;
1034
- bPrintAsImage = bUI.bPrintAsImage;
1035
- bReverse = bUI.bReverse;
1036
- bAnnotations = bUI.bAnnotations;
1037
- printParams = bUI.printParams;
1038
- bUI = bUI.bUI;
1039
- }
1040
-
1041
- // TODO: for now just use nStart and nEnd
1042
- // so need to see how to deal with the other params
1043
- // (if possible)
1044
- if (printParams) {
1045
- nStart = printParams.firstPage;
1046
- nEnd = printParams.lastPage;
1047
- }
1048
-
1049
- if (typeof nStart === "number") {
1050
- nStart = Math.max(0, Math.trunc(nStart));
1051
- } else {
1052
- nStart = 0;
1053
- }
1054
-
1055
- if (typeof nEnd === "number") {
1056
- nEnd = Math.max(0, Math.trunc(nEnd));
1057
- } else {
1058
- nEnd = -1;
1059
- }
1060
-
1061
- this._send({ command: "print", start: nStart, end: nEnd });
1062
- }
1063
-
1064
- removeDataObject() {
1065
- /* Not implemented */
1066
- }
1067
-
1068
- removeField() {
1069
- /* TODO or not */
1070
- }
1071
-
1072
- removeIcon() {
1073
- /* Not implemented */
1074
- }
1075
-
1076
- removeLinks() {
1077
- /* Not implemented */
1078
- }
1079
-
1080
- removeRequirement() {
1081
- /* Not implemented */
1082
- }
1083
-
1084
- removeScript() {
1085
- /* Not implemented */
1086
- }
1087
-
1088
- removeTemplate() {
1089
- /* Not implemented */
1090
- }
1091
-
1092
- removeThumbnails() {
1093
- /* Not implemented */
1094
- }
1095
-
1096
- removeWeblinks() {
1097
- /* Not implemented */
1098
- }
1099
-
1100
- replacePages() {
1101
- /* Not implemented */
1102
- }
1103
-
1104
- resetForm(aFields = null) {
1105
- if (aFields && !Array.isArray(aFields) && typeof aFields === "object") {
1106
- aFields = aFields.aFields;
1107
- }
1108
- let mustCalculate = false;
1109
- if (aFields) {
1110
- for (const fieldName of aFields) {
1111
- if (!fieldName) {
1112
- continue;
1113
- }
1114
- const field = this.getField(fieldName);
1115
- if (!field) {
1116
- continue;
1117
- }
1118
- field.value = field.defaultValue;
1119
- field.valueAsString = field.value;
1120
- mustCalculate = true;
1121
- }
1122
- } else {
1123
- mustCalculate = this._fields.size !== 0;
1124
- for (const field of this._fields.values()) {
1125
- field.value = field.defaultValue;
1126
- field.valueAsString = field.value;
1127
- }
1128
- }
1129
- if (mustCalculate) {
1130
- this.calculateNow();
1131
- }
1132
- }
1133
-
1134
- saveAs() {
1135
- /* Not implemented */
1136
- }
1137
-
1138
- scroll() {
1139
- /* TODO */
1140
- }
1141
-
1142
- selectPageNthWord() {
1143
- /* TODO */
1144
- }
1145
-
1146
- setAction() {
1147
- /* TODO */
1148
- }
1149
-
1150
- setDataObjectContents() {
1151
- /* Not implemented */
1152
- }
1153
-
1154
- setOCGOrder() {
1155
- /* Not implemented */
1156
- }
1157
-
1158
- setPageAction() {
1159
- /* TODO */
1160
- }
1161
-
1162
- setPageBoxes() {
1163
- /* Not implemented */
1164
- }
1165
-
1166
- setPageLabels() {
1167
- /* Not implemented */
1168
- }
1169
-
1170
- setPageRotations() {
1171
- /* TODO */
1172
- }
1173
-
1174
- setPageTabOrder() {
1175
- /* Not implemented */
1176
- }
1177
-
1178
- setPageTransitions() {
1179
- /* Not implemented */
1180
- }
1181
-
1182
- spawnPageFromTemplate() {
1183
- /* Not implemented */
1184
- }
1185
-
1186
- submitForm() {
1187
- /* TODO or not */
1188
- }
1189
-
1190
- syncAnnotScan() {
1191
- /* Not implemented */
1192
- }
1193
- }
1194
-
1195
- export { Doc };