@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,170 +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 { BaseStream } from "./base_stream.js";
|
|
17
|
-
import { Stream } from "./stream.js";
|
|
18
|
-
|
|
19
|
-
// Lots of DecodeStreams are created whose buffers are never used. For these
|
|
20
|
-
// we share a single empty buffer. This is (a) space-efficient and (b) avoids
|
|
21
|
-
// having special cases that would be required if we used |null| for an empty
|
|
22
|
-
// buffer.
|
|
23
|
-
const emptyBuffer = new Uint8Array(0);
|
|
24
|
-
|
|
25
|
-
// Super class for the decoding streams.
|
|
26
|
-
class DecodeStream extends BaseStream {
|
|
27
|
-
constructor(maybeMinBufferLength) {
|
|
28
|
-
super();
|
|
29
|
-
this._rawMinBufferLength = maybeMinBufferLength || 0;
|
|
30
|
-
|
|
31
|
-
this.pos = 0;
|
|
32
|
-
this.bufferLength = 0;
|
|
33
|
-
this.eof = false;
|
|
34
|
-
this.buffer = emptyBuffer;
|
|
35
|
-
this.minBufferLength = 512;
|
|
36
|
-
if (maybeMinBufferLength) {
|
|
37
|
-
// Compute the first power of two that is as big as maybeMinBufferLength.
|
|
38
|
-
while (this.minBufferLength < maybeMinBufferLength) {
|
|
39
|
-
this.minBufferLength *= 2;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
get isEmpty() {
|
|
45
|
-
while (!this.eof && this.bufferLength === 0) {
|
|
46
|
-
this.readBlock();
|
|
47
|
-
}
|
|
48
|
-
return this.bufferLength === 0;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
ensureBuffer(requested) {
|
|
52
|
-
const buffer = this.buffer;
|
|
53
|
-
if (requested <= buffer.byteLength) {
|
|
54
|
-
return buffer;
|
|
55
|
-
}
|
|
56
|
-
let size = this.minBufferLength;
|
|
57
|
-
while (size < requested) {
|
|
58
|
-
size *= 2;
|
|
59
|
-
}
|
|
60
|
-
const buffer2 = new Uint8Array(size);
|
|
61
|
-
buffer2.set(buffer);
|
|
62
|
-
return (this.buffer = buffer2);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
getByte() {
|
|
66
|
-
const pos = this.pos;
|
|
67
|
-
while (this.bufferLength <= pos) {
|
|
68
|
-
if (this.eof) {
|
|
69
|
-
return -1;
|
|
70
|
-
}
|
|
71
|
-
this.readBlock();
|
|
72
|
-
}
|
|
73
|
-
return this.buffer[this.pos++];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
getBytes(length, forceClamped = false) {
|
|
77
|
-
const pos = this.pos;
|
|
78
|
-
let end;
|
|
79
|
-
|
|
80
|
-
if (length) {
|
|
81
|
-
this.ensureBuffer(pos + length);
|
|
82
|
-
end = pos + length;
|
|
83
|
-
|
|
84
|
-
while (!this.eof && this.bufferLength < end) {
|
|
85
|
-
this.readBlock();
|
|
86
|
-
}
|
|
87
|
-
const bufEnd = this.bufferLength;
|
|
88
|
-
if (end > bufEnd) {
|
|
89
|
-
end = bufEnd;
|
|
90
|
-
}
|
|
91
|
-
} else {
|
|
92
|
-
while (!this.eof) {
|
|
93
|
-
this.readBlock();
|
|
94
|
-
}
|
|
95
|
-
end = this.bufferLength;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
this.pos = end;
|
|
99
|
-
const subarray = this.buffer.subarray(pos, end);
|
|
100
|
-
// `this.buffer` is either a `Uint8Array` or `Uint8ClampedArray` here.
|
|
101
|
-
return forceClamped && !(subarray instanceof Uint8ClampedArray)
|
|
102
|
-
? new Uint8ClampedArray(subarray)
|
|
103
|
-
: subarray;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
reset() {
|
|
107
|
-
this.pos = 0;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
makeSubStream(start, length, dict = null) {
|
|
111
|
-
if (length === undefined) {
|
|
112
|
-
while (!this.eof) {
|
|
113
|
-
this.readBlock();
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
const end = start + length;
|
|
117
|
-
while (this.bufferLength <= end && !this.eof) {
|
|
118
|
-
this.readBlock();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return new Stream(this.buffer, start, length, dict);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
getBaseStreams() {
|
|
125
|
-
return this.str ? this.str.getBaseStreams() : null;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
class StreamsSequenceStream extends DecodeStream {
|
|
130
|
-
constructor(streams) {
|
|
131
|
-
let maybeLength = 0;
|
|
132
|
-
for (const stream of streams) {
|
|
133
|
-
maybeLength +=
|
|
134
|
-
stream instanceof DecodeStream
|
|
135
|
-
? stream._rawMinBufferLength
|
|
136
|
-
: stream.length;
|
|
137
|
-
}
|
|
138
|
-
super(maybeLength);
|
|
139
|
-
|
|
140
|
-
this.streams = streams;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
readBlock() {
|
|
144
|
-
const streams = this.streams;
|
|
145
|
-
if (streams.length === 0) {
|
|
146
|
-
this.eof = true;
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
const stream = streams.shift();
|
|
150
|
-
const chunk = stream.getBytes();
|
|
151
|
-
const bufferLength = this.bufferLength;
|
|
152
|
-
const newLength = bufferLength + chunk.length;
|
|
153
|
-
const buffer = this.ensureBuffer(newLength);
|
|
154
|
-
buffer.set(chunk, bufferLength);
|
|
155
|
-
this.bufferLength = newLength;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
getBaseStreams() {
|
|
159
|
-
const baseStreamsBuf = [];
|
|
160
|
-
for (const stream of this.streams) {
|
|
161
|
-
const baseStreams = stream.getBaseStreams();
|
|
162
|
-
if (baseStreams) {
|
|
163
|
-
baseStreamsBuf.push(...baseStreams);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return baseStreamsBuf.length > 0 ? baseStreamsBuf : null;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export { DecodeStream, StreamsSequenceStream };
|
|
@@ -1,59 +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 { DecodeStream } from "./decode_stream.js";
|
|
17
|
-
|
|
18
|
-
const chunkSize = 512;
|
|
19
|
-
|
|
20
|
-
class DecryptStream extends DecodeStream {
|
|
21
|
-
constructor(str, maybeLength, decrypt) {
|
|
22
|
-
super(maybeLength);
|
|
23
|
-
|
|
24
|
-
this.str = str;
|
|
25
|
-
this.dict = str.dict;
|
|
26
|
-
this.decrypt = decrypt;
|
|
27
|
-
this.nextChunk = null;
|
|
28
|
-
this.initialized = false;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
readBlock() {
|
|
32
|
-
let chunk;
|
|
33
|
-
if (this.initialized) {
|
|
34
|
-
chunk = this.nextChunk;
|
|
35
|
-
} else {
|
|
36
|
-
chunk = this.str.getBytes(chunkSize);
|
|
37
|
-
this.initialized = true;
|
|
38
|
-
}
|
|
39
|
-
if (!chunk || chunk.length === 0) {
|
|
40
|
-
this.eof = true;
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
this.nextChunk = this.str.getBytes(chunkSize);
|
|
44
|
-
const hasMoreData = this.nextChunk && this.nextChunk.length > 0;
|
|
45
|
-
|
|
46
|
-
const decrypt = this.decrypt;
|
|
47
|
-
chunk = decrypt(chunk, !hasMoreData);
|
|
48
|
-
|
|
49
|
-
let bufferLength = this.bufferLength;
|
|
50
|
-
const n = chunk.length,
|
|
51
|
-
buffer = this.ensureBuffer(bufferLength + n);
|
|
52
|
-
for (let i = 0; i < n; i++) {
|
|
53
|
-
buffer[bufferLength++] = chunk[i];
|
|
54
|
-
}
|
|
55
|
-
this.bufferLength = bufferLength;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export { DecryptStream };
|
|
@@ -1,99 +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 { OPS, warn } from "../shared/util.js";
|
|
17
|
-
import { ColorSpace } from "./colorspace.js";
|
|
18
|
-
import { escapePDFName } from "./core_utils.js";
|
|
19
|
-
import { EvaluatorPreprocessor } from "./evaluator.js";
|
|
20
|
-
import { Name } from "./primitives.js";
|
|
21
|
-
import { StringStream } from "./stream.js";
|
|
22
|
-
|
|
23
|
-
class DefaultAppearanceEvaluator extends EvaluatorPreprocessor {
|
|
24
|
-
constructor(str) {
|
|
25
|
-
super(new StringStream(str));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
parse() {
|
|
29
|
-
const operation = {
|
|
30
|
-
fn: 0,
|
|
31
|
-
args: [],
|
|
32
|
-
};
|
|
33
|
-
const result = {
|
|
34
|
-
fontSize: 0,
|
|
35
|
-
fontName: "",
|
|
36
|
-
fontColor: /* black = */ new Uint8ClampedArray(3),
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
while (true) {
|
|
41
|
-
operation.args.length = 0; // Ensure that `args` it's always reset.
|
|
42
|
-
|
|
43
|
-
if (!this.read(operation)) {
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
if (this.savedStatesDepth !== 0) {
|
|
47
|
-
continue; // Don't get info in save/restore sections.
|
|
48
|
-
}
|
|
49
|
-
const { fn, args } = operation;
|
|
50
|
-
|
|
51
|
-
switch (fn | 0) {
|
|
52
|
-
case OPS.setFont:
|
|
53
|
-
const [fontName, fontSize] = args;
|
|
54
|
-
if (fontName instanceof Name) {
|
|
55
|
-
result.fontName = fontName.name;
|
|
56
|
-
}
|
|
57
|
-
if (typeof fontSize === "number" && fontSize > 0) {
|
|
58
|
-
result.fontSize = fontSize;
|
|
59
|
-
}
|
|
60
|
-
break;
|
|
61
|
-
case OPS.setFillRGBColor:
|
|
62
|
-
ColorSpace.singletons.rgb.getRgbItem(args, 0, result.fontColor, 0);
|
|
63
|
-
break;
|
|
64
|
-
case OPS.setFillGray:
|
|
65
|
-
ColorSpace.singletons.gray.getRgbItem(args, 0, result.fontColor, 0);
|
|
66
|
-
break;
|
|
67
|
-
case OPS.setFillColorSpace:
|
|
68
|
-
ColorSpace.singletons.cmyk.getRgbItem(args, 0, result.fontColor, 0);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
} catch (reason) {
|
|
73
|
-
warn(`parseDefaultAppearance - ignoring errors: "${reason}".`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Parse DA to extract font and color information.
|
|
81
|
-
function parseDefaultAppearance(str) {
|
|
82
|
-
return new DefaultAppearanceEvaluator(str).parse();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Create default appearance string from some information.
|
|
86
|
-
function createDefaultAppearance({ fontSize, fontName, fontColor }) {
|
|
87
|
-
let colorCmd;
|
|
88
|
-
if (fontColor.every(c => c === 0)) {
|
|
89
|
-
colorCmd = "0 g";
|
|
90
|
-
} else {
|
|
91
|
-
colorCmd =
|
|
92
|
-
Array.from(fontColor)
|
|
93
|
-
.map(c => (c / 255).toFixed(2))
|
|
94
|
-
.join(" ") + " rg";
|
|
95
|
-
}
|
|
96
|
-
return `/${escapePDFName(fontName)} ${fontSize} Tf ${colorCmd}`;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export { createDefaultAppearance, parseDefaultAppearance };
|