@vaadin-component-factory/vcf-pdf-viewer 0.9.0 → 0.9.4
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.
- package/README.md +1 -1
- package/package.json +33 -18
- package/{src/display → pdfjs/dist}/display_utils.js +344 -139
- package/{src/display → pdfjs/dist}/fetch_stream.js +115 -97
- package/pdfjs/dist/get.js +1857 -0
- package/pdfjs/dist/index.js +767 -0
- package/pdfjs/dist/l10n_utils.js +140 -0
- package/{src/shared → pdfjs/dist}/message_handler.js +243 -259
- package/{src/display → pdfjs/dist}/network.js +149 -87
- package/{src/display/content_disposition.js → pdfjs/dist/network_utils.js} +167 -55
- package/{src/display → pdfjs/dist}/node_stream.js +133 -98
- package/pdfjs/dist/pdf.js +12778 -0
- package/pdfjs/dist/pdf_link_service.js +638 -0
- package/pdfjs/dist/pdf_rendering_queue.js +199 -0
- package/pdfjs/dist/pdf_thumbnail_viewer.js +819 -0
- package/pdfjs/dist/pdf_viewer.js +3598 -0
- package/pdfjs/dist/typeof.js +100 -0
- package/pdfjs/dist/ui_utils.js +1033 -0
- package/{src/shared → pdfjs/dist}/util.js +301 -287
- package/pdfjs/dist/worker.js +62813 -0
- package/src/vcf-pdf-viewer.js +77 -27
- package/theme/lumo/vcf-pdf-viewer-styles.js +1 -1
- package/theme/material/vcf-pdf-viewer.js +2 -2
- package/src/core/.eslintrc +0 -13
- package/src/core/annotation.js +0 -2948
- package/src/core/arithmetic_decoder.js +0 -182
- package/src/core/ascii_85_stream.js +0 -98
- package/src/core/ascii_hex_stream.js +0 -79
- package/src/core/base_stream.js +0 -110
- package/src/core/bidi.js +0 -438
- package/src/core/calibri_factors.js +0 -308
- package/src/core/catalog.js +0 -1459
- package/src/core/ccitt.js +0 -1062
- package/src/core/ccitt_stream.js +0 -60
- package/src/core/cff_font.js +0 -116
- package/src/core/cff_parser.js +0 -1949
- package/src/core/charsets.js +0 -119
- package/src/core/chunked_stream.js +0 -557
- package/src/core/cmap.js +0 -1039
- package/src/core/colorspace.js +0 -1533
- package/src/core/core_utils.js +0 -464
- package/src/core/crypto.js +0 -1900
- package/src/core/decode_stream.js +0 -170
- package/src/core/decrypt_stream.js +0 -59
- package/src/core/default_appearance.js +0 -99
- package/src/core/document.js +0 -1456
- package/src/core/encodings.js +0 -301
- package/src/core/evaluator.js +0 -4601
- package/src/core/file_spec.js +0 -108
- package/src/core/flate_stream.js +0 -402
- package/src/core/font_renderer.js +0 -882
- package/src/core/fonts.js +0 -3260
- package/src/core/fonts_utils.js +0 -221
- package/src/core/function.js +0 -1257
- package/src/core/glyf.js +0 -706
- package/src/core/glyphlist.js +0 -4558
- package/src/core/helvetica_factors.js +0 -353
- package/src/core/image.js +0 -802
- package/src/core/image_utils.js +0 -291
- package/src/core/jbig2.js +0 -2572
- package/src/core/jbig2_stream.js +0 -73
- package/src/core/jpeg_stream.js +0 -105
- package/src/core/jpg.js +0 -1416
- package/src/core/jpx.js +0 -2343
- package/src/core/jpx_stream.js +0 -87
- package/src/core/liberationsans_widths.js +0 -221
- package/src/core/lzw_stream.js +0 -150
- package/src/core/metadata_parser.js +0 -146
- package/src/core/metrics.js +0 -2970
- package/src/core/murmurhash3.js +0 -139
- package/src/core/myriadpro_factors.js +0 -290
- package/src/core/name_number_tree.js +0 -153
- package/src/core/object_loader.js +0 -149
- package/src/core/opentype_file_builder.js +0 -154
- package/src/core/operator_list.js +0 -734
- package/src/core/parser.js +0 -1416
- package/src/core/pattern.js +0 -985
- package/src/core/pdf_manager.js +0 -217
- package/src/core/predictor_stream.js +0 -238
- package/src/core/primitives.js +0 -402
- package/src/core/ps_parser.js +0 -272
- package/src/core/run_length_stream.js +0 -61
- package/src/core/segoeui_factors.js +0 -308
- package/src/core/standard_fonts.js +0 -817
- package/src/core/stream.js +0 -103
- package/src/core/struct_tree.js +0 -335
- package/src/core/to_unicode_map.js +0 -103
- package/src/core/type1_font.js +0 -421
- package/src/core/type1_parser.js +0 -776
- package/src/core/unicode.js +0 -1649
- package/src/core/worker.js +0 -848
- package/src/core/worker_stream.js +0 -135
- package/src/core/writer.js +0 -278
- package/src/core/xfa/bind.js +0 -652
- package/src/core/xfa/builder.js +0 -207
- package/src/core/xfa/config.js +0 -1926
- package/src/core/xfa/connection_set.js +0 -202
- package/src/core/xfa/data.js +0 -82
- package/src/core/xfa/datasets.js +0 -76
- package/src/core/xfa/factory.js +0 -111
- package/src/core/xfa/fonts.js +0 -181
- package/src/core/xfa/formcalc_lexer.js +0 -385
- package/src/core/xfa/formcalc_parser.js +0 -1340
- package/src/core/xfa/html_utils.js +0 -639
- package/src/core/xfa/layout.js +0 -383
- package/src/core/xfa/locale_set.js +0 -345
- package/src/core/xfa/namespaces.js +0 -81
- package/src/core/xfa/parser.js +0 -184
- package/src/core/xfa/setup.js +0 -38
- package/src/core/xfa/signature.js +0 -40
- package/src/core/xfa/som.js +0 -338
- package/src/core/xfa/stylesheet.js +0 -40
- package/src/core/xfa/template.js +0 -6260
- package/src/core/xfa/text.js +0 -290
- package/src/core/xfa/unknown.js +0 -29
- package/src/core/xfa/utils.js +0 -217
- package/src/core/xfa/xdp.js +0 -59
- package/src/core/xfa/xfa_object.js +0 -1130
- package/src/core/xfa/xhtml.js +0 -543
- package/src/core/xfa_fonts.js +0 -208
- package/src/core/xml_parser.js +0 -507
- package/src/core/xref.js +0 -899
- package/src/display/annotation_layer.js +0 -2107
- package/src/display/annotation_storage.js +0 -113
- package/src/display/api.js +0 -3292
- package/src/display/base_factory.js +0 -180
- package/src/display/canvas.js +0 -2828
- package/src/display/font_loader.js +0 -484
- package/src/display/metadata.js +0 -41
- package/src/display/network_utils.js +0 -100
- package/src/display/node_utils.js +0 -83
- package/src/display/optional_content_config.js +0 -189
- package/src/display/pattern_helper.js +0 -659
- package/src/display/svg.js +0 -1709
- package/src/display/text_layer.js +0 -847
- package/src/display/transport_stream.js +0 -303
- package/src/display/worker_options.js +0 -40
- package/src/display/xfa_layer.js +0 -204
- package/src/doc_helper.js +0 -25
- package/src/images/logo.svg +0 -41
- package/src/interfaces.js +0 -169
- package/src/license_header.js +0 -14
- package/src/license_header_libre.js +0 -21
- package/src/pdf.image_decoders.js +0 -46
- package/src/pdf.js +0 -146
- package/src/pdf.sandbox.external.js +0 -181
- package/src/pdf.sandbox.js +0 -151
- package/src/pdf.scripting.js +0 -25
- package/src/pdf.worker.entry.js +0 -19
- package/src/pdf.worker.js +0 -23
- package/src/scripting_api/aform.js +0 -608
- package/src/scripting_api/app.js +0 -621
- package/src/scripting_api/color.js +0 -129
- package/src/scripting_api/common.js +0 -58
- package/src/scripting_api/console.js +0 -38
- package/src/scripting_api/constants.js +0 -208
- package/src/scripting_api/doc.js +0 -1195
- package/src/scripting_api/error.js +0 -23
- package/src/scripting_api/event.js +0 -232
- package/src/scripting_api/field.js +0 -620
- package/src/scripting_api/fullscreen.js +0 -145
- package/src/scripting_api/initialization.js +0 -223
- package/src/scripting_api/pdf_object.js +0 -24
- package/src/scripting_api/print_params.js +0 -146
- package/src/scripting_api/proxy.js +0 -139
- package/src/scripting_api/thermometer.js +0 -69
- package/src/scripting_api/util.js +0 -581
- package/src/shared/.eslintrc +0 -13
- package/src/shared/cffStandardStrings.js +0 -311
- package/src/shared/compatibility.js +0 -114
- package/src/shared/fonts_utils.js +0 -429
- package/src/shared/is_node.js +0 -27
- package/src/shared/scripting_utils.js +0 -85
- package/src/worker_loader.js +0 -32
|
@@ -1,202 +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
|
-
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
|
17
|
-
import { StringObject, XFAObject, XFAObjectArray } from "./xfa_object.js";
|
|
18
|
-
|
|
19
|
-
const CONNECTION_SET_NS_ID = NamespaceIds.connectionSet.id;
|
|
20
|
-
|
|
21
|
-
class ConnectionSet extends XFAObject {
|
|
22
|
-
constructor(attributes) {
|
|
23
|
-
super(CONNECTION_SET_NS_ID, "connectionSet", /* hasChildren = */ true);
|
|
24
|
-
this.wsdlConnection = new XFAObjectArray();
|
|
25
|
-
this.xmlConnection = new XFAObjectArray();
|
|
26
|
-
this.xsdConnection = new XFAObjectArray();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
class EffectiveInputPolicy extends XFAObject {
|
|
31
|
-
constructor(attributes) {
|
|
32
|
-
super(CONNECTION_SET_NS_ID, "effectiveInputPolicy");
|
|
33
|
-
this.id = attributes.id || "";
|
|
34
|
-
this.name = attributes.name || "";
|
|
35
|
-
this.use = attributes.use || "";
|
|
36
|
-
this.usehref = attributes.usehref || "";
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
class EffectiveOutputPolicy extends XFAObject {
|
|
41
|
-
constructor(attributes) {
|
|
42
|
-
super(CONNECTION_SET_NS_ID, "effectiveOutputPolicy");
|
|
43
|
-
this.id = attributes.id || "";
|
|
44
|
-
this.name = attributes.name || "";
|
|
45
|
-
this.use = attributes.use || "";
|
|
46
|
-
this.usehref = attributes.usehref || "";
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
class Operation extends StringObject {
|
|
51
|
-
constructor(attributes) {
|
|
52
|
-
super(CONNECTION_SET_NS_ID, "operation");
|
|
53
|
-
this.id = attributes.id || "";
|
|
54
|
-
this.input = attributes.input || "";
|
|
55
|
-
this.name = attributes.name || "";
|
|
56
|
-
this.output = attributes.output || "";
|
|
57
|
-
this.use = attributes.use || "";
|
|
58
|
-
this.usehref = attributes.usehref || "";
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
class RootElement extends StringObject {
|
|
63
|
-
constructor(attributes) {
|
|
64
|
-
super(CONNECTION_SET_NS_ID, "rootElement");
|
|
65
|
-
this.id = attributes.id || "";
|
|
66
|
-
this.name = attributes.name || "";
|
|
67
|
-
this.use = attributes.use || "";
|
|
68
|
-
this.usehref = attributes.usehref || "";
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
class SoapAction extends StringObject {
|
|
73
|
-
constructor(attributes) {
|
|
74
|
-
super(CONNECTION_SET_NS_ID, "soapAction");
|
|
75
|
-
this.id = attributes.id || "";
|
|
76
|
-
this.name = attributes.name || "";
|
|
77
|
-
this.use = attributes.use || "";
|
|
78
|
-
this.usehref = attributes.usehref || "";
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
class SoapAddress extends StringObject {
|
|
83
|
-
constructor(attributes) {
|
|
84
|
-
super(CONNECTION_SET_NS_ID, "soapAddress");
|
|
85
|
-
this.id = attributes.id || "";
|
|
86
|
-
this.name = attributes.name || "";
|
|
87
|
-
this.use = attributes.use || "";
|
|
88
|
-
this.usehref = attributes.usehref || "";
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
class Uri extends StringObject {
|
|
93
|
-
constructor(attributes) {
|
|
94
|
-
super(CONNECTION_SET_NS_ID, "uri");
|
|
95
|
-
this.id = attributes.id || "";
|
|
96
|
-
this.name = attributes.name || "";
|
|
97
|
-
this.use = attributes.use || "";
|
|
98
|
-
this.usehref = attributes.usehref || "";
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
class WsdlAddress extends StringObject {
|
|
103
|
-
constructor(attributes) {
|
|
104
|
-
super(CONNECTION_SET_NS_ID, "wsdlAddress");
|
|
105
|
-
this.id = attributes.id || "";
|
|
106
|
-
this.name = attributes.name || "";
|
|
107
|
-
this.use = attributes.use || "";
|
|
108
|
-
this.usehref = attributes.usehref || "";
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
class WsdlConnection extends XFAObject {
|
|
113
|
-
constructor(attributes) {
|
|
114
|
-
super(CONNECTION_SET_NS_ID, "wsdlConnection", /* hasChildren = */ true);
|
|
115
|
-
this.dataDescription = attributes.dataDescription || "";
|
|
116
|
-
this.name = attributes.name || "";
|
|
117
|
-
this.effectiveInputPolicy = null;
|
|
118
|
-
this.effectiveOutputPolicy = null;
|
|
119
|
-
this.operation = null;
|
|
120
|
-
this.soapAction = null;
|
|
121
|
-
this.soapAddress = null;
|
|
122
|
-
this.wsdlAddress = null;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
class XmlConnection extends XFAObject {
|
|
127
|
-
constructor(attributes) {
|
|
128
|
-
super(CONNECTION_SET_NS_ID, "xmlConnection", /* hasChildren = */ true);
|
|
129
|
-
this.dataDescription = attributes.dataDescription || "";
|
|
130
|
-
this.name = attributes.name || "";
|
|
131
|
-
this.uri = null;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
class XsdConnection extends XFAObject {
|
|
136
|
-
constructor(attributes) {
|
|
137
|
-
super(CONNECTION_SET_NS_ID, "xsdConnection", /* hasChildren = */ true);
|
|
138
|
-
this.dataDescription = attributes.dataDescription || "";
|
|
139
|
-
this.name = attributes.name || "";
|
|
140
|
-
this.rootElement = null;
|
|
141
|
-
this.uri = null;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
class ConnectionSetNamespace {
|
|
146
|
-
static [$buildXFAObject](name, attributes) {
|
|
147
|
-
if (ConnectionSetNamespace.hasOwnProperty(name)) {
|
|
148
|
-
return ConnectionSetNamespace[name](attributes);
|
|
149
|
-
}
|
|
150
|
-
return undefined;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
static connectionSet(attrs) {
|
|
154
|
-
return new ConnectionSet(attrs);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
static effectiveInputPolicy(attrs) {
|
|
158
|
-
return new EffectiveInputPolicy(attrs);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
static effectiveOutputPolicy(attrs) {
|
|
162
|
-
return new EffectiveOutputPolicy(attrs);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
static operation(attrs) {
|
|
166
|
-
return new Operation(attrs);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
static rootElement(attrs) {
|
|
170
|
-
return new RootElement(attrs);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
static soapAction(attrs) {
|
|
174
|
-
return new SoapAction(attrs);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
static soapAddress(attrs) {
|
|
178
|
-
return new SoapAddress(attrs);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
static uri(attrs) {
|
|
182
|
-
return new Uri(attrs);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
static wsdlAddress(attrs) {
|
|
186
|
-
return new WsdlAddress(attrs);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
static wsdlConnection(attrs) {
|
|
190
|
-
return new WsdlConnection(attrs);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
static xmlConnection(attrs) {
|
|
194
|
-
return new XmlConnection(attrs);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
static xsdConnection(attrs) {
|
|
198
|
-
return new XsdConnection(attrs);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export { ConnectionSetNamespace };
|
package/src/core/xfa/data.js
DELETED
|
@@ -1,82 +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
|
-
import {
|
|
17
|
-
$getAttributes,
|
|
18
|
-
$getChildren,
|
|
19
|
-
$nodeName,
|
|
20
|
-
$setValue,
|
|
21
|
-
$toString,
|
|
22
|
-
$uid,
|
|
23
|
-
} from "./xfa_object.js";
|
|
24
|
-
|
|
25
|
-
class DataHandler {
|
|
26
|
-
constructor(root, data) {
|
|
27
|
-
this.data = data;
|
|
28
|
-
this.dataset = root.datasets || null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
serialize(storage) {
|
|
32
|
-
const stack = [[-1, this.data[$getChildren]()]];
|
|
33
|
-
|
|
34
|
-
while (stack.length > 0) {
|
|
35
|
-
const last = stack[stack.length - 1];
|
|
36
|
-
const [i, children] = last;
|
|
37
|
-
if (i + 1 === children.length) {
|
|
38
|
-
stack.pop();
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const child = children[++last[0]];
|
|
43
|
-
const storageEntry = storage.get(child[$uid]);
|
|
44
|
-
if (storageEntry) {
|
|
45
|
-
child[$setValue](storageEntry);
|
|
46
|
-
} else {
|
|
47
|
-
const attributes = child[$getAttributes]();
|
|
48
|
-
for (const value of attributes.values()) {
|
|
49
|
-
const entry = storage.get(value[$uid]);
|
|
50
|
-
if (entry) {
|
|
51
|
-
value[$setValue](entry);
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const nodes = child[$getChildren]();
|
|
58
|
-
if (nodes.length > 0) {
|
|
59
|
-
stack.push([-1, nodes]);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const buf = [
|
|
64
|
-
`<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">`,
|
|
65
|
-
];
|
|
66
|
-
if (this.dataset) {
|
|
67
|
-
// Dump nodes other than data: they can contains for example
|
|
68
|
-
// some data for choice lists.
|
|
69
|
-
for (const child of this.dataset[$getChildren]()) {
|
|
70
|
-
if (child[$nodeName] !== "data") {
|
|
71
|
-
child[$toString](buf);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
this.data[$toString](buf);
|
|
76
|
-
buf.push("</xfa:datasets>");
|
|
77
|
-
|
|
78
|
-
return buf.join("");
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export { DataHandler };
|
package/src/core/xfa/datasets.js
DELETED
|
@@ -1,76 +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
|
-
import {
|
|
17
|
-
$appendChild,
|
|
18
|
-
$isNsAgnostic,
|
|
19
|
-
$namespaceId,
|
|
20
|
-
$nodeName,
|
|
21
|
-
$onChild,
|
|
22
|
-
XFAObject,
|
|
23
|
-
XmlObject,
|
|
24
|
-
} from "./xfa_object.js";
|
|
25
|
-
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
|
26
|
-
|
|
27
|
-
const DATASETS_NS_ID = NamespaceIds.datasets.id;
|
|
28
|
-
|
|
29
|
-
class Data extends XmlObject {
|
|
30
|
-
constructor(attributes) {
|
|
31
|
-
super(DATASETS_NS_ID, "data", attributes);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
[$isNsAgnostic]() {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
class Datasets extends XFAObject {
|
|
40
|
-
constructor(attributes) {
|
|
41
|
-
super(DATASETS_NS_ID, "datasets", /* hasChildren = */ true);
|
|
42
|
-
this.data = null;
|
|
43
|
-
this.Signature = null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
[$onChild](child) {
|
|
47
|
-
const name = child[$nodeName];
|
|
48
|
-
if (
|
|
49
|
-
(name === "data" && child[$namespaceId] === DATASETS_NS_ID) ||
|
|
50
|
-
(name === "Signature" &&
|
|
51
|
-
child[$namespaceId] === NamespaceIds.signature.id)
|
|
52
|
-
) {
|
|
53
|
-
this[name] = child;
|
|
54
|
-
}
|
|
55
|
-
this[$appendChild](child);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
class DatasetsNamespace {
|
|
60
|
-
static [$buildXFAObject](name, attributes) {
|
|
61
|
-
if (DatasetsNamespace.hasOwnProperty(name)) {
|
|
62
|
-
return DatasetsNamespace[name](attributes);
|
|
63
|
-
}
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
static datasets(attributes) {
|
|
68
|
-
return new Datasets(attributes);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
static data(attributes) {
|
|
72
|
-
return new Data(attributes);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export { DatasetsNamespace };
|
package/src/core/xfa/factory.js
DELETED
|
@@ -1,111 +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
|
-
import { $globalData, $toHTML } from "./xfa_object.js";
|
|
17
|
-
import { Binder } from "./bind.js";
|
|
18
|
-
import { DataHandler } from "./data.js";
|
|
19
|
-
import { FontFinder } from "./fonts.js";
|
|
20
|
-
import { stripQuotes } from "./utils.js";
|
|
21
|
-
import { warn } from "../../shared/util.js";
|
|
22
|
-
import { XFAParser } from "./parser.js";
|
|
23
|
-
|
|
24
|
-
class XFAFactory {
|
|
25
|
-
constructor(data) {
|
|
26
|
-
try {
|
|
27
|
-
this.root = new XFAParser().parse(XFAFactory._createDocument(data));
|
|
28
|
-
const binder = new Binder(this.root);
|
|
29
|
-
this.form = binder.bind();
|
|
30
|
-
this.dataHandler = new DataHandler(this.root, binder.getData());
|
|
31
|
-
this.form[$globalData].template = this.form;
|
|
32
|
-
} catch (e) {
|
|
33
|
-
warn(`XFA - an error occurred during parsing and binding: ${e}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
isValid() {
|
|
38
|
-
return this.root && this.form;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
_createPages() {
|
|
42
|
-
try {
|
|
43
|
-
this.pages = this.form[$toHTML]();
|
|
44
|
-
this.dims = this.pages.children.map(c => {
|
|
45
|
-
const { width, height } = c.attributes.style;
|
|
46
|
-
return [0, 0, parseInt(width), parseInt(height)];
|
|
47
|
-
});
|
|
48
|
-
} catch (e) {
|
|
49
|
-
warn(`XFA - an error occurred during layout: ${e}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
getBoundingBox(pageIndex) {
|
|
54
|
-
return this.dims[pageIndex];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
get numberPages() {
|
|
58
|
-
if (!this.pages) {
|
|
59
|
-
this._createPages();
|
|
60
|
-
}
|
|
61
|
-
return this.dims.length;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
setImages(images) {
|
|
65
|
-
this.form[$globalData].images = images;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
setFonts(fonts) {
|
|
69
|
-
this.form[$globalData].fontFinder = new FontFinder(fonts);
|
|
70
|
-
const missingFonts = [];
|
|
71
|
-
for (let typeface of this.form[$globalData].usedTypefaces) {
|
|
72
|
-
typeface = stripQuotes(typeface);
|
|
73
|
-
const font = this.form[$globalData].fontFinder.find(typeface);
|
|
74
|
-
if (!font) {
|
|
75
|
-
missingFonts.push(typeface);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (missingFonts.length > 0) {
|
|
80
|
-
return missingFonts;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
appendFonts(fonts, reallyMissingFonts) {
|
|
87
|
-
this.form[$globalData].fontFinder.add(fonts, reallyMissingFonts);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
getPages() {
|
|
91
|
-
if (!this.pages) {
|
|
92
|
-
this._createPages();
|
|
93
|
-
}
|
|
94
|
-
const pages = this.pages;
|
|
95
|
-
this.pages = null;
|
|
96
|
-
return pages;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
serializeData(storage) {
|
|
100
|
-
return this.dataHandler.serialize(storage);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
static _createDocument(data) {
|
|
104
|
-
if (!data["/xdp:xdp"]) {
|
|
105
|
-
return data["xdp:xdp"];
|
|
106
|
-
}
|
|
107
|
-
return Object.values(data).join("");
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export { XFAFactory };
|
package/src/core/xfa/fonts.js
DELETED
|
@@ -1,181 +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
|
-
import { warn } from "../../shared/util.js";
|
|
17
|
-
|
|
18
|
-
class FontFinder {
|
|
19
|
-
constructor(pdfFonts) {
|
|
20
|
-
this.fonts = new Map();
|
|
21
|
-
this.cache = new Map();
|
|
22
|
-
this.warned = new Set();
|
|
23
|
-
this.defaultFont = null;
|
|
24
|
-
this.add(pdfFonts);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
add(pdfFonts, reallyMissingFonts = null) {
|
|
28
|
-
for (const pdfFont of pdfFonts) {
|
|
29
|
-
this.addPdfFont(pdfFont);
|
|
30
|
-
}
|
|
31
|
-
for (const pdfFont of this.fonts.values()) {
|
|
32
|
-
if (!pdfFont.regular) {
|
|
33
|
-
pdfFont.regular = pdfFont.italic || pdfFont.bold || pdfFont.bolditalic;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!reallyMissingFonts || reallyMissingFonts.size === 0) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const myriad = this.fonts.get("PdfJS-Fallback-PdfJS-XFA");
|
|
41
|
-
for (const missing of reallyMissingFonts) {
|
|
42
|
-
this.fonts.set(missing, myriad);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
addPdfFont(pdfFont) {
|
|
47
|
-
const cssFontInfo = pdfFont.cssFontInfo;
|
|
48
|
-
const name = cssFontInfo.fontFamily;
|
|
49
|
-
let font = this.fonts.get(name);
|
|
50
|
-
if (!font) {
|
|
51
|
-
font = Object.create(null);
|
|
52
|
-
this.fonts.set(name, font);
|
|
53
|
-
if (!this.defaultFont) {
|
|
54
|
-
this.defaultFont = font;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
let property = "";
|
|
58
|
-
const fontWeight = parseFloat(cssFontInfo.fontWeight);
|
|
59
|
-
if (parseFloat(cssFontInfo.italicAngle) !== 0) {
|
|
60
|
-
property = fontWeight >= 700 ? "bolditalic" : "italic";
|
|
61
|
-
} else if (fontWeight >= 700) {
|
|
62
|
-
property = "bold";
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!property) {
|
|
66
|
-
if (
|
|
67
|
-
pdfFont.name.includes("Bold") ||
|
|
68
|
-
(pdfFont.psName && pdfFont.psName.includes("Bold"))
|
|
69
|
-
) {
|
|
70
|
-
property = "bold";
|
|
71
|
-
}
|
|
72
|
-
if (
|
|
73
|
-
pdfFont.name.includes("Italic") ||
|
|
74
|
-
pdfFont.name.endsWith("It") ||
|
|
75
|
-
(pdfFont.psName &&
|
|
76
|
-
(pdfFont.psName.includes("Italic") || pdfFont.psName.endsWith("It")))
|
|
77
|
-
) {
|
|
78
|
-
property += "italic";
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (!property) {
|
|
83
|
-
property = "regular";
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
font[property] = pdfFont;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
getDefault() {
|
|
90
|
-
return this.defaultFont;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
find(fontName, mustWarn = true) {
|
|
94
|
-
let font = this.fonts.get(fontName) || this.cache.get(fontName);
|
|
95
|
-
if (font) {
|
|
96
|
-
return font;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const pattern = /,|-|_| |bolditalic|bold|italic|regular|it/gi;
|
|
100
|
-
let name = fontName.replace(pattern, "");
|
|
101
|
-
font = this.fonts.get(name);
|
|
102
|
-
if (font) {
|
|
103
|
-
this.cache.set(fontName, font);
|
|
104
|
-
return font;
|
|
105
|
-
}
|
|
106
|
-
name = name.toLowerCase();
|
|
107
|
-
|
|
108
|
-
const maybe = [];
|
|
109
|
-
for (const [family, pdfFont] of this.fonts.entries()) {
|
|
110
|
-
if (family.replace(pattern, "").toLowerCase().startsWith(name)) {
|
|
111
|
-
maybe.push(pdfFont);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (maybe.length === 0) {
|
|
116
|
-
for (const [, pdfFont] of this.fonts.entries()) {
|
|
117
|
-
if (
|
|
118
|
-
pdfFont.regular.name &&
|
|
119
|
-
pdfFont.regular.name
|
|
120
|
-
.replace(pattern, "")
|
|
121
|
-
.toLowerCase()
|
|
122
|
-
.startsWith(name)
|
|
123
|
-
) {
|
|
124
|
-
maybe.push(pdfFont);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (maybe.length === 0) {
|
|
130
|
-
name = name.replace(/psmt|mt/gi, "");
|
|
131
|
-
for (const [family, pdfFont] of this.fonts.entries()) {
|
|
132
|
-
if (family.replace(pattern, "").toLowerCase().startsWith(name)) {
|
|
133
|
-
maybe.push(pdfFont);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (maybe.length === 0) {
|
|
139
|
-
for (const pdfFont of this.fonts.values()) {
|
|
140
|
-
if (
|
|
141
|
-
pdfFont.regular.name &&
|
|
142
|
-
pdfFont.regular.name
|
|
143
|
-
.replace(pattern, "")
|
|
144
|
-
.toLowerCase()
|
|
145
|
-
.startsWith(name)
|
|
146
|
-
) {
|
|
147
|
-
maybe.push(pdfFont);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (maybe.length >= 1) {
|
|
153
|
-
if (maybe.length !== 1 && mustWarn) {
|
|
154
|
-
warn(`XFA - Too many choices to guess the correct font: ${fontName}`);
|
|
155
|
-
}
|
|
156
|
-
this.cache.set(fontName, maybe[0]);
|
|
157
|
-
return maybe[0];
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (mustWarn && !this.warned.has(fontName)) {
|
|
161
|
-
this.warned.add(fontName);
|
|
162
|
-
warn(`XFA - Cannot find the font: ${fontName}`);
|
|
163
|
-
}
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function selectFont(xfaFont, typeface) {
|
|
169
|
-
if (xfaFont.posture === "italic") {
|
|
170
|
-
if (xfaFont.weight === "bold") {
|
|
171
|
-
return typeface.bolditalic;
|
|
172
|
-
}
|
|
173
|
-
return typeface.italic;
|
|
174
|
-
} else if (xfaFont.weight === "bold") {
|
|
175
|
-
return typeface.bold;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return typeface.regular;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export { FontFinder, selectFont };
|