@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,303 +0,0 @@
1
- /* Copyright 2012 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 { assert, createPromiseCapability } from "../shared/util.js";
17
- import { isPdfFile } from "./display_utils.js";
18
-
19
- /** @implements {IPDFStream} */
20
- class PDFDataTransportStream {
21
- constructor(params, pdfDataRangeTransport) {
22
- assert(
23
- pdfDataRangeTransport,
24
- 'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'
25
- );
26
-
27
- this._queuedChunks = [];
28
- this._progressiveDone = params.progressiveDone || false;
29
- this._contentDispositionFilename =
30
- params.contentDispositionFilename || null;
31
-
32
- const initialData = params.initialData;
33
- if (initialData?.length > 0) {
34
- const buffer = new Uint8Array(initialData).buffer;
35
- this._queuedChunks.push(buffer);
36
- }
37
-
38
- this._pdfDataRangeTransport = pdfDataRangeTransport;
39
- this._isStreamingSupported = !params.disableStream;
40
- this._isRangeSupported = !params.disableRange;
41
- this._contentLength = params.length;
42
-
43
- this._fullRequestReader = null;
44
- this._rangeReaders = [];
45
-
46
- this._pdfDataRangeTransport.addRangeListener((begin, chunk) => {
47
- this._onReceiveData({ begin, chunk });
48
- });
49
-
50
- this._pdfDataRangeTransport.addProgressListener((loaded, total) => {
51
- this._onProgress({ loaded, total });
52
- });
53
-
54
- this._pdfDataRangeTransport.addProgressiveReadListener(chunk => {
55
- this._onReceiveData({ chunk });
56
- });
57
-
58
- this._pdfDataRangeTransport.addProgressiveDoneListener(() => {
59
- this._onProgressiveDone();
60
- });
61
-
62
- this._pdfDataRangeTransport.transportReady();
63
- }
64
-
65
- _onReceiveData(args) {
66
- const buffer = new Uint8Array(args.chunk).buffer;
67
- if (args.begin === undefined) {
68
- if (this._fullRequestReader) {
69
- this._fullRequestReader._enqueue(buffer);
70
- } else {
71
- this._queuedChunks.push(buffer);
72
- }
73
- } else {
74
- const found = this._rangeReaders.some(function (rangeReader) {
75
- if (rangeReader._begin !== args.begin) {
76
- return false;
77
- }
78
- rangeReader._enqueue(buffer);
79
- return true;
80
- });
81
- assert(
82
- found,
83
- "_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."
84
- );
85
- }
86
- }
87
-
88
- get _progressiveDataLength() {
89
- return this._fullRequestReader?._loaded ?? 0;
90
- }
91
-
92
- _onProgress(evt) {
93
- if (evt.total === undefined) {
94
- // Reporting to first range reader, if it exists.
95
- const firstReader = this._rangeReaders[0];
96
- if (firstReader?.onProgress) {
97
- firstReader.onProgress({ loaded: evt.loaded });
98
- }
99
- } else {
100
- const fullReader = this._fullRequestReader;
101
- if (fullReader?.onProgress) {
102
- fullReader.onProgress({ loaded: evt.loaded, total: evt.total });
103
- }
104
- }
105
- }
106
-
107
- _onProgressiveDone() {
108
- if (this._fullRequestReader) {
109
- this._fullRequestReader.progressiveDone();
110
- }
111
- this._progressiveDone = true;
112
- }
113
-
114
- _removeRangeReader(reader) {
115
- const i = this._rangeReaders.indexOf(reader);
116
- if (i >= 0) {
117
- this._rangeReaders.splice(i, 1);
118
- }
119
- }
120
-
121
- getFullReader() {
122
- assert(
123
- !this._fullRequestReader,
124
- "PDFDataTransportStream.getFullReader can only be called once."
125
- );
126
- const queuedChunks = this._queuedChunks;
127
- this._queuedChunks = null;
128
- return new PDFDataTransportStreamReader(
129
- this,
130
- queuedChunks,
131
- this._progressiveDone,
132
- this._contentDispositionFilename
133
- );
134
- }
135
-
136
- getRangeReader(begin, end) {
137
- if (end <= this._progressiveDataLength) {
138
- return null;
139
- }
140
- const reader = new PDFDataTransportStreamRangeReader(this, begin, end);
141
- this._pdfDataRangeTransport.requestDataRange(begin, end);
142
- this._rangeReaders.push(reader);
143
- return reader;
144
- }
145
-
146
- cancelAllRequests(reason) {
147
- if (this._fullRequestReader) {
148
- this._fullRequestReader.cancel(reason);
149
- }
150
- for (const reader of this._rangeReaders.slice(0)) {
151
- reader.cancel(reason);
152
- }
153
- this._pdfDataRangeTransport.abort();
154
- }
155
- }
156
-
157
- /** @implements {IPDFStreamReader} */
158
- class PDFDataTransportStreamReader {
159
- constructor(
160
- stream,
161
- queuedChunks,
162
- progressiveDone = false,
163
- contentDispositionFilename = null
164
- ) {
165
- this._stream = stream;
166
- this._done = progressiveDone || false;
167
- this._filename = isPdfFile(contentDispositionFilename)
168
- ? contentDispositionFilename
169
- : null;
170
- this._queuedChunks = queuedChunks || [];
171
- this._loaded = 0;
172
- for (const chunk of this._queuedChunks) {
173
- this._loaded += chunk.byteLength;
174
- }
175
- this._requests = [];
176
- this._headersReady = Promise.resolve();
177
- stream._fullRequestReader = this;
178
-
179
- this.onProgress = null;
180
- }
181
-
182
- _enqueue(chunk) {
183
- if (this._done) {
184
- return; // Ignore new data.
185
- }
186
- if (this._requests.length > 0) {
187
- const requestCapability = this._requests.shift();
188
- requestCapability.resolve({ value: chunk, done: false });
189
- } else {
190
- this._queuedChunks.push(chunk);
191
- }
192
- this._loaded += chunk.byteLength;
193
- }
194
-
195
- get headersReady() {
196
- return this._headersReady;
197
- }
198
-
199
- get filename() {
200
- return this._filename;
201
- }
202
-
203
- get isRangeSupported() {
204
- return this._stream._isRangeSupported;
205
- }
206
-
207
- get isStreamingSupported() {
208
- return this._stream._isStreamingSupported;
209
- }
210
-
211
- get contentLength() {
212
- return this._stream._contentLength;
213
- }
214
-
215
- async read() {
216
- if (this._queuedChunks.length > 0) {
217
- const chunk = this._queuedChunks.shift();
218
- return { value: chunk, done: false };
219
- }
220
- if (this._done) {
221
- return { value: undefined, done: true };
222
- }
223
- const requestCapability = createPromiseCapability();
224
- this._requests.push(requestCapability);
225
- return requestCapability.promise;
226
- }
227
-
228
- cancel(reason) {
229
- this._done = true;
230
- for (const requestCapability of this._requests) {
231
- requestCapability.resolve({ value: undefined, done: true });
232
- }
233
- this._requests.length = 0;
234
- }
235
-
236
- progressiveDone() {
237
- if (this._done) {
238
- return;
239
- }
240
- this._done = true;
241
- }
242
- }
243
-
244
- /** @implements {IPDFStreamRangeReader} */
245
- class PDFDataTransportStreamRangeReader {
246
- constructor(stream, begin, end) {
247
- this._stream = stream;
248
- this._begin = begin;
249
- this._end = end;
250
- this._queuedChunk = null;
251
- this._requests = [];
252
- this._done = false;
253
-
254
- this.onProgress = null;
255
- }
256
-
257
- _enqueue(chunk) {
258
- if (this._done) {
259
- return; // ignore new data
260
- }
261
- if (this._requests.length === 0) {
262
- this._queuedChunk = chunk;
263
- } else {
264
- const requestsCapability = this._requests.shift();
265
- requestsCapability.resolve({ value: chunk, done: false });
266
- for (const requestCapability of this._requests) {
267
- requestCapability.resolve({ value: undefined, done: true });
268
- }
269
- this._requests.length = 0;
270
- }
271
- this._done = true;
272
- this._stream._removeRangeReader(this);
273
- }
274
-
275
- get isStreamingSupported() {
276
- return false;
277
- }
278
-
279
- async read() {
280
- if (this._queuedChunk) {
281
- const chunk = this._queuedChunk;
282
- this._queuedChunk = null;
283
- return { value: chunk, done: false };
284
- }
285
- if (this._done) {
286
- return { value: undefined, done: true };
287
- }
288
- const requestCapability = createPromiseCapability();
289
- this._requests.push(requestCapability);
290
- return requestCapability.promise;
291
- }
292
-
293
- cancel(reason) {
294
- this._done = true;
295
- for (const requestCapability of this._requests) {
296
- requestCapability.resolve({ value: undefined, done: true });
297
- }
298
- this._requests.length = 0;
299
- this._stream._removeRangeReader(this);
300
- }
301
- }
302
-
303
- export { PDFDataTransportStream };
@@ -1,40 +0,0 @@
1
- /* Copyright 2018 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
- /**
17
- * @typedef {Object} GlobalWorkerOptionsType
18
- * @property {Worker | null} workerPort - Defines global port for worker
19
- * process. Overrides the `workerSrc` option.
20
- * @property {string} workerSrc - A string containing the path and filename
21
- * of the worker file.
22
- *
23
- * NOTE: The `workerSrc` option should always be set, in order to prevent any
24
- * issues when using the PDF.js library.
25
- */
26
-
27
- /** @type {GlobalWorkerOptionsType} */
28
- const GlobalWorkerOptions = Object.create(null);
29
-
30
- GlobalWorkerOptions.workerPort =
31
- GlobalWorkerOptions.workerPort === undefined
32
- ? null
33
- : GlobalWorkerOptions.workerPort;
34
-
35
- GlobalWorkerOptions.workerSrc =
36
- GlobalWorkerOptions.workerSrc === undefined
37
- ? ""
38
- : GlobalWorkerOptions.workerSrc;
39
-
40
- export { GlobalWorkerOptions };
@@ -1,204 +0,0 @@
1
- /* Copyright 2021 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
- class XfaLayer {
17
- static setupStorage(html, id, element, storage, intent) {
18
- const storedData = storage.getValue(id, { value: null });
19
- switch (element.name) {
20
- case "textarea":
21
- if (storedData.value !== null) {
22
- html.textContent = storedData.value;
23
- }
24
- if (intent === "print") {
25
- break;
26
- }
27
- html.addEventListener("input", event => {
28
- storage.setValue(id, { value: event.target.value });
29
- });
30
- break;
31
- case "input":
32
- if (
33
- element.attributes.type === "radio" ||
34
- element.attributes.type === "checkbox"
35
- ) {
36
- if (storedData.value === element.attributes.xfaOn) {
37
- html.setAttribute("checked", true);
38
- }
39
- if (intent === "print") {
40
- break;
41
- }
42
- html.addEventListener("change", event => {
43
- storage.setValue(id, { value: event.target.getAttribute("xfaOn") });
44
- });
45
- } else {
46
- if (storedData.value !== null) {
47
- html.setAttribute("value", storedData.value);
48
- }
49
- if (intent === "print") {
50
- break;
51
- }
52
- html.addEventListener("input", event => {
53
- storage.setValue(id, { value: event.target.value });
54
- });
55
- }
56
- break;
57
- case "select":
58
- if (storedData.value !== null) {
59
- for (const option of element.children) {
60
- if (option.attributes.value === storedData.value) {
61
- option.attributes.selected = true;
62
- }
63
- }
64
- }
65
- html.addEventListener("input", event => {
66
- const options = event.target.options;
67
- const value =
68
- options.selectedIndex === -1
69
- ? ""
70
- : options[options.selectedIndex].value;
71
- storage.setValue(id, { value });
72
- });
73
- break;
74
- }
75
- }
76
-
77
- static setAttributes(html, element, storage, intent) {
78
- const { attributes } = element;
79
- if (attributes.type === "radio") {
80
- // Avoid to have a radio group when printing with the same as one
81
- // already displayed.
82
- attributes.name = `${attributes.name}-${intent}`;
83
- }
84
- for (const [key, value] of Object.entries(attributes)) {
85
- // We don't need to add dataId in the html object but it can
86
- // be useful to know its value when writing printing tests:
87
- // in this case, don't skip dataId to have its value.
88
- if (value === null || value === undefined || key === "dataId") {
89
- continue;
90
- }
91
-
92
- if (key !== "style") {
93
- if (key === "textContent") {
94
- html.textContent = value;
95
- } else if (key === "class") {
96
- html.setAttribute(key, value.join(" "));
97
- } else {
98
- html.setAttribute(key, value);
99
- }
100
- } else {
101
- Object.assign(html.style, value);
102
- }
103
- }
104
-
105
- // Set the value after the others to be sure overwrite
106
- // any other values.
107
- if (storage && attributes.dataId) {
108
- this.setupStorage(html, attributes.dataId, element, storage);
109
- }
110
- }
111
-
112
- static render(parameters) {
113
- const storage = parameters.annotationStorage;
114
- const root = parameters.xfa;
115
- const intent = parameters.intent || "display";
116
- const rootHtml = document.createElement(root.name);
117
- if (root.attributes) {
118
- this.setAttributes(rootHtml, root);
119
- }
120
- const stack = [[root, -1, rootHtml]];
121
-
122
- const rootDiv = parameters.div;
123
- rootDiv.appendChild(rootHtml);
124
- const transform = `matrix(${parameters.viewport.transform.join(",")})`;
125
- rootDiv.style.transform = transform;
126
-
127
- // Set defaults.
128
- rootDiv.setAttribute("class", "xfaLayer xfaFont");
129
-
130
- while (stack.length > 0) {
131
- const [parent, i, html] = stack[stack.length - 1];
132
- if (i + 1 === parent.children.length) {
133
- stack.pop();
134
- continue;
135
- }
136
-
137
- const child = parent.children[++stack[stack.length - 1][1]];
138
- if (child === null) {
139
- continue;
140
- }
141
-
142
- const { name } = child;
143
- if (name === "#text") {
144
- html.appendChild(document.createTextNode(child.value));
145
- continue;
146
- }
147
-
148
- let childHtml;
149
- if (child?.attributes?.xmlns) {
150
- childHtml = document.createElementNS(child.attributes.xmlns, name);
151
- } else {
152
- childHtml = document.createElement(name);
153
- }
154
-
155
- html.appendChild(childHtml);
156
- if (child.attributes) {
157
- this.setAttributes(childHtml, child, storage, intent);
158
- }
159
-
160
- if (child.children && child.children.length > 0) {
161
- stack.push([child, -1, childHtml]);
162
- } else if (child.value) {
163
- childHtml.appendChild(document.createTextNode(child.value));
164
- }
165
- }
166
-
167
- /**
168
- * TODO: re-enable that stuff once we've JS implementation.
169
- * See https://bugzilla.mozilla.org/show_bug.cgi?id=1719465.
170
- *
171
- * for (const el of rootDiv.querySelectorAll(
172
- * ".xfaDisabled input, .xfaDisabled textarea"
173
- * )) {
174
- * el.setAttribute("disabled", true);
175
- * }
176
- * for (const el of rootDiv.querySelectorAll(
177
- * ".xfaReadOnly input, .xfaReadOnly textarea"
178
- * )) {
179
- * el.setAttribute("readOnly", true);
180
- * }
181
- */
182
-
183
- for (const el of rootDiv.querySelectorAll(
184
- ".xfaNonInteractive input, .xfaNonInteractive textarea"
185
- )) {
186
- el.setAttribute("readOnly", true);
187
- }
188
- }
189
-
190
- /**
191
- * Update the xfa layer.
192
- *
193
- * @public
194
- * @param {XfaLayerParameters} parameters
195
- * @memberof XfaLayer
196
- */
197
- static update(parameters) {
198
- const transform = `matrix(${parameters.viewport.transform.join(",")})`;
199
- parameters.div.style.transform = transform;
200
- parameters.div.hidden = false;
201
- }
202
- }
203
-
204
- export { XfaLayer };
package/src/doc_helper.js DELETED
@@ -1,25 +0,0 @@
1
- /* Copyright 2012 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
- /*
17
- NOTE: This file is created as a helper to assist with JSDoc html files.
18
- It is not for use in the executable code.
19
- */
20
-
21
- /**
22
- * Represents the eventual result of an asynchronous operation.
23
- * @external Promise
24
- * @see {@link http://promisesaplus.com/ Promise/A+}
25
- */
@@ -1,41 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <svg
3
- xmlns="http://www.w3.org/2000/svg"
4
- width="64"
5
- height="64">
6
- <path
7
- d="M 4.8364028,0.4891005 32.096378,4.5726641 59.163597,0.4891005 54.680408,57.805097 32.096378,63.510899 8.3116209,57.805097 z"
8
- style="fill:#e5e7e8;fill-opacity:1;fill-rule:nonzero;stroke:#cccccc" />
9
- <path
10
- d="M 32.096378,10.745857 53.925414,6.8301117 51.016574,53.81906 32.096378,58.517955 z"
11
- style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" />
12
- <rect
13
- width="34.027256"
14
- height="19.136194"
15
- x="3.7557135"
16
- y="22.431904"
17
- style="fill:#ff2600;fill-opacity:1;fill-rule:nonzero;stroke:none" />
18
- <rect
19
- width="23.480518"
20
- height="19.136194"
21
- x="36.763767"
22
- y="22.431904"
23
- style="fill:#ff501a;fill-opacity:1;fill-rule:nonzero;stroke:none" />
24
- <g transform="matrix(0.42778543,0,0,0.42778543,58.617711,9.6737064)">
25
- <path
26
- d="m -120.53125,34.59375 0,35.1875 6.53125,0 0,-5.9375 0,-5.96875 8.875,0 4.15625,-3.71875 0,-7.71875 0,-7.71875 -4.21875,-4.125 -15.34375,0 z m 6.53125,6.8125 6.21875,0 0,10.21875 -6.21875,0 0,-10.21875 z"
27
- style="fill:#ffffff;fill-opacity:1" />
28
- <path
29
- d="m -98.125,34.59375 0,35.1875 16.125,0 3.75,-3.625 0,-27.96875 -3.96875,-3.59375 -15.90625,0 z m 6.8125,6.8125 6.8125,0 0,21.5625 -6.8125,0 0,-21.5625 z" id="path3056"
30
- style="fill:#ffffff;fill-opacity:1" />
31
- <path
32
- d="m -74.856072,34.602929 c 5.485697,0 10.971394,0 16.457091,0 0,2.269943 0,4.539887 0,6.80983 -3.404915,0 -6.809831,0 -10.214746,0 0,2.472069 0,4.944138 0,7.416206 2.93201,0.110496 5.864021,-0.110494 8.796031,0 l 0,3.366025 0,3.375914 c -2.93201,0.110495 -5.864021,-0.110495 -8.796031,0 l 0,7.146446 0,7.069702 c -2.080782,0 -4.161563,0 -6.242345,0 0,-11.728041 0,-23.456082 0,-35.184123 z"
33
- style="fill:#ffffff;fill-opacity:1" />
34
- <path
35
- d="m -42.8813,67.942723 -2.181762,-1.844329 c 0,-1.986871 0,-3.973742 0,-5.960613 2.175363,6.7e-4 4.350725,0.0013 6.526088,0.002 0,0.94581 0,1.891619 0,2.837429 1.891619,0 3.783239,0 5.674858,0 0,-9.458098 0,-18.916195 0,-28.374293 2.175363,-1.26e-4 4.350725,-2.52e-4 6.526088,-3.78e-4 0,10.498614 0,20.997229 0,31.495843 -1.454508,1.229554 -2.909019,2.459106 -4.363529,3.688658 -3.333325,0 -6.666651,0 -9.999976,0 -0.727237,-0.614768 -1.454563,-1.229595 -2.181767,-1.844308 z"
36
- style="fill:#ffffff;fill-opacity:1" />
37
- <path
38
- d="m -21.316836,67.942723 -2.109122,-1.844329 0,-5.978379 c 2.061011,0 4.392437,0.01978 6.453448,0.01978 0,0.94581 0,1.891619 0,2.837429 2.269943,0 4.539887,0 6.80983,0 0,-2.459105 0,-4.918211 0,-7.377316 -3.196954,0 -6.393909,0 -9.590863,0 l -3.745055,-3.688659 0,-6.80983 0,-6.80983 3.745055,-3.688658 c 3.863156,0 7.726313,0 11.5894692,0 l 4.2511106,3.688658 c -0.00204,1.797039 -0.00472,3.594077 -0.00737,5.391115 -2.0807816,0 -4.1615632,0 -6.2423448,0 0,-0.756648 0,-1.513295 0,-2.269943 -2.269943,0 -4.539887,0 -6.80983,0 0,2.459105 0,4.918211 0,7.377316 2.990126,0 5.980253,0 8.9703792,0 1.3605964,1.204585 4.0817956,3.613749 4.0817956,3.613749 0,4.555246 0,9.110492 0,13.665738 l -2.0892845,1.858745 -2.0892901,1.858745 -5.5180792,0 -5.51808,0 z"
39
- style="fill:#ffffff;fill-opacity:1" />
40
- </g>
41
- </svg>