pdfjs-dist 2.0.943 → 2.4.456
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8286 -14230
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +25500 -26628
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25473 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +57878 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +407 -0
- package/es5/web/pdf_viewer.js +7757 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +2887 -4094
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +855 -778
- package/lib/core/arithmetic_decoder.js +325 -311
- package/lib/core/bidi.js +117 -50
- package/lib/core/ccitt.js +251 -89
- package/lib/core/ccitt_stream.js +26 -16
- package/lib/core/cff_parser.js +525 -197
- package/lib/core/charsets.js +6 -5
- package/lib/core/chunked_stream.js +541 -406
- package/lib/core/cmap.js +368 -253
- package/lib/core/colorspace.js +781 -800
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +609 -422
- package/lib/core/document.js +649 -481
- package/lib/core/encodings.js +33 -24
- package/lib/core/evaluator.js +1471 -736
- package/lib/core/font_renderer.js +289 -149
- package/lib/core/fonts.js +1067 -413
- package/lib/core/function.js +517 -287
- package/lib/core/glyphlist.js +4529 -4527
- package/lib/core/image.js +232 -114
- package/lib/core/image_utils.js +94 -0
- package/lib/core/jbig2.js +711 -342
- package/lib/core/jbig2_stream.js +31 -19
- package/lib/core/jpeg_stream.js +151 -26
- package/lib/core/jpg.js +433 -181
- package/lib/core/jpx.js +551 -143
- package/lib/core/jpx_stream.js +40 -28
- package/lib/core/metrics.js +2931 -2931
- package/lib/core/murmurhash3.js +104 -97
- package/lib/core/obj.js +1561 -1053
- package/lib/core/operator_list.js +192 -64
- package/lib/core/parser.js +1162 -864
- package/lib/core/pattern.js +224 -75
- package/lib/core/pdf_manager.js +154 -285
- package/lib/core/primitives.js +145 -69
- package/lib/core/ps_parser.js +212 -162
- package/lib/core/standard_fonts.js +245 -244
- package/lib/core/stream.js +353 -81
- package/lib/core/type1_parser.js +218 -68
- package/lib/core/unicode.js +1682 -1655
- package/lib/core/worker.js +233 -302
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +808 -862
- package/lib/display/api.js +1778 -1462
- package/lib/display/api_compatibility.js +14 -9
- package/lib/display/canvas.js +463 -140
- package/lib/display/content_disposition.js +86 -58
- package/lib/display/display_utils.js +524 -0
- package/lib/display/fetch_stream.js +202 -274
- package/lib/display/font_loader.js +311 -333
- package/lib/display/metadata.js +98 -88
- package/lib/display/network.js +343 -347
- package/lib/display/network_utils.js +46 -26
- package/lib/display/node_stream.js +326 -404
- package/lib/display/pattern_helper.js +168 -69
- package/lib/display/svg.js +1296 -885
- package/lib/display/text_layer.js +229 -103
- package/lib/display/transport_stream.js +290 -250
- package/lib/display/webgl.js +116 -83
- package/lib/display/worker_options.js +6 -5
- package/lib/display/xml_parser.js +358 -337
- package/lib/examples/node/domstubs.js +95 -39
- package/lib/pdf.js +49 -31
- package/lib/pdf.worker.js +7 -5
- package/lib/shared/compatibility.js +3 -145
- package/lib/shared/is_node.js +8 -7
- package/lib/shared/message_handler.js +367 -314
- package/lib/shared/util.js +421 -415
- package/lib/test/unit/annotation_spec.js +1570 -690
- package/lib/test/unit/api_spec.js +855 -493
- package/lib/test/unit/bidi_spec.js +12 -12
- package/lib/test/unit/cff_parser_spec.js +88 -61
- package/lib/test/unit/clitests_helper.js +9 -12
- package/lib/test/unit/cmap_spec.js +140 -88
- package/lib/test/unit/colorspace_spec.js +204 -152
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +194 -182
- package/lib/test/unit/custom_spec.js +50 -64
- package/lib/test/unit/display_svg_spec.js +53 -38
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +17 -22
- package/lib/test/unit/encodings_spec.js +15 -57
- package/lib/test/unit/evaluator_spec.js +90 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +219 -205
- package/lib/test/unit/jasmine-boot.js +68 -39
- package/lib/test/unit/message_handler_spec.js +187 -160
- package/lib/test/unit/metadata_spec.js +87 -34
- package/lib/test/unit/murmurhash3_spec.js +13 -13
- package/lib/test/unit/network_spec.js +26 -59
- package/lib/test/unit/network_utils_spec.js +187 -121
- package/lib/test/unit/node_stream_spec.js +98 -90
- package/lib/test/unit/parser_spec.js +173 -131
- package/lib/test/unit/pdf_find_controller_spec.js +148 -67
- package/lib/test/unit/pdf_find_utils_spec.js +35 -34
- package/lib/test/unit/pdf_history_spec.js +45 -33
- package/lib/test/unit/primitives_spec.js +161 -126
- package/lib/test/unit/stream_spec.js +22 -15
- package/lib/test/unit/test_utils.js +149 -98
- package/lib/test/unit/testreporter.js +36 -18
- package/lib/test/unit/type1_parser_spec.js +46 -44
- package/lib/test/unit/ui_utils_spec.js +388 -372
- package/lib/test/unit/unicode_spec.js +49 -46
- package/lib/test/unit/util_spec.js +144 -248
- package/lib/web/annotation_layer_builder.js +75 -95
- package/lib/web/app.js +1538 -1147
- package/lib/web/app_options.js +116 -104
- package/lib/web/base_viewer.js +950 -775
- package/lib/web/chromecom.js +217 -225
- package/lib/web/debugger.js +236 -148
- package/lib/web/download_manager.js +50 -50
- package/lib/web/firefox_print_service.js +51 -33
- package/lib/web/firefoxcom.js +225 -352
- package/lib/web/genericcom.js +30 -93
- package/lib/web/genericl10n.js +26 -143
- package/lib/web/grab_to_pan.js +57 -33
- package/lib/web/interfaces.js +105 -232
- package/lib/web/overlay_manager.js +73 -227
- package/lib/web/password_prompt.js +44 -62
- package/lib/web/pdf_attachment_viewer.js +118 -123
- package/lib/web/pdf_cursor_tools.js +89 -93
- package/lib/web/pdf_document_properties.js +242 -281
- package/lib/web/pdf_find_bar.js +157 -163
- package/lib/web/pdf_find_controller.js +598 -454
- package/lib/web/pdf_find_utils.js +32 -16
- package/lib/web/pdf_history.js +481 -355
- package/lib/web/pdf_link_service.js +355 -323
- package/lib/web/pdf_outline_viewer.js +167 -152
- package/lib/web/pdf_page_view.js +511 -457
- package/lib/web/pdf_presentation_mode.js +347 -335
- package/lib/web/pdf_print_service.js +133 -103
- package/lib/web/pdf_rendering_queue.js +98 -100
- package/lib/web/pdf_sidebar.js +323 -299
- package/lib/web/pdf_sidebar_resizer.js +107 -108
- package/lib/web/pdf_single_page_viewer.js +94 -146
- package/lib/web/pdf_thumbnail_view.js +319 -269
- package/lib/web/pdf_thumbnail_viewer.js +219 -199
- package/lib/web/pdf_viewer.component.js +111 -32
- package/lib/web/pdf_viewer.js +61 -101
- package/lib/web/preferences.js +87 -272
- package/lib/web/secondary_toolbar.js +207 -220
- package/lib/web/text_layer_builder.js +322 -322
- package/lib/web/toolbar.js +227 -180
- package/lib/web/ui_utils.js +476 -421
- package/lib/web/view_history.js +59 -208
- package/lib/web/viewer_compatibility.js +9 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +36 -22
- package/web/pdf_viewer.js +4407 -4516
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -441
- package/lib/shared/streams_polyfill.js +0 -39
- package/lib/shared/url_polyfill.js +0 -50
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/web/dom_events.js +0 -140
package/lib/display/svg.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2020 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,59 +19,69 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.SVGGraphics =
|
27
|
+
exports.SVGGraphics = void 0;
|
28
28
|
|
29
|
-
var _util = require(
|
29
|
+
var _util = require("../shared/util.js");
|
30
30
|
|
31
|
-
var
|
31
|
+
var _display_utils = require("./display_utils.js");
|
32
32
|
|
33
|
-
var _is_node = require(
|
33
|
+
var _is_node = require("../shared/is_node.js");
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
38
|
-
|
39
|
-
var SVGGraphics = function SVGGraphics() {
|
40
|
-
throw new Error('Not implemented: SVGGraphics');
|
35
|
+
let SVGGraphics = function () {
|
36
|
+
throw new Error("Not implemented: SVGGraphics");
|
41
37
|
};
|
38
|
+
|
39
|
+
exports.SVGGraphics = SVGGraphics;
|
42
40
|
{
|
43
|
-
|
44
|
-
fontStyle:
|
45
|
-
fontWeight:
|
46
|
-
fillColor:
|
41
|
+
const SVG_DEFAULTS = {
|
42
|
+
fontStyle: "normal",
|
43
|
+
fontWeight: "normal",
|
44
|
+
fillColor: "#000000"
|
47
45
|
};
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
46
|
+
const XML_NS = "http://www.w3.org/XML/1998/namespace";
|
47
|
+
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
48
|
+
const LINE_CAP_STYLES = ["butt", "round", "square"];
|
49
|
+
const LINE_JOIN_STYLES = ["miter", "round", "bevel"];
|
50
|
+
|
51
|
+
const convertImgDataToPng = function () {
|
52
|
+
const PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
53
|
+
const CHUNK_WRAPPER_SIZE = 12;
|
54
|
+
const crcTable = new Int32Array(256);
|
55
|
+
|
56
|
+
for (let i = 0; i < 256; i++) {
|
57
|
+
let c = i;
|
58
|
+
|
59
|
+
for (let h = 0; h < 8; h++) {
|
55
60
|
if (c & 1) {
|
56
|
-
c =
|
61
|
+
c = 0xedb88320 ^ c >> 1 & 0x7fffffff;
|
57
62
|
} else {
|
58
63
|
c = c >> 1 & 0x7fffffff;
|
59
64
|
}
|
60
65
|
}
|
66
|
+
|
61
67
|
crcTable[i] = c;
|
62
68
|
}
|
69
|
+
|
63
70
|
function crc32(data, start, end) {
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
71
|
+
let crc = -1;
|
72
|
+
|
73
|
+
for (let i = start; i < end; i++) {
|
74
|
+
const a = (crc ^ data[i]) & 0xff;
|
75
|
+
const b = crcTable[a];
|
68
76
|
crc = crc >>> 8 ^ b;
|
69
77
|
}
|
78
|
+
|
70
79
|
return crc ^ -1;
|
71
80
|
}
|
81
|
+
|
72
82
|
function writePngChunk(type, body, data, offset) {
|
73
|
-
|
74
|
-
|
83
|
+
let p = offset;
|
84
|
+
const len = body.length;
|
75
85
|
data[p] = len >> 24 & 0xff;
|
76
86
|
data[p + 1] = len >> 16 & 0xff;
|
77
87
|
data[p + 2] = len >> 8 & 0xff;
|
@@ -84,48 +94,61 @@ var SVGGraphics = function SVGGraphics() {
|
|
84
94
|
p += 4;
|
85
95
|
data.set(body, p);
|
86
96
|
p += body.length;
|
87
|
-
|
97
|
+
const crc = crc32(data, offset + 4, p);
|
88
98
|
data[p] = crc >> 24 & 0xff;
|
89
99
|
data[p + 1] = crc >> 16 & 0xff;
|
90
100
|
data[p + 2] = crc >> 8 & 0xff;
|
91
101
|
data[p + 3] = crc & 0xff;
|
92
102
|
}
|
103
|
+
|
93
104
|
function adler32(data, start, end) {
|
94
|
-
|
95
|
-
|
96
|
-
|
105
|
+
let a = 1;
|
106
|
+
let b = 0;
|
107
|
+
|
108
|
+
for (let i = start; i < end; ++i) {
|
97
109
|
a = (a + (data[i] & 0xff)) % 65521;
|
98
110
|
b = (b + a) % 65521;
|
99
111
|
}
|
112
|
+
|
100
113
|
return b << 16 | a;
|
101
114
|
}
|
115
|
+
|
102
116
|
function deflateSync(literals) {
|
103
|
-
if (!
|
117
|
+
if (!_is_node.isNodeJS) {
|
104
118
|
return deflateSyncUncompressed(literals);
|
105
119
|
}
|
120
|
+
|
106
121
|
try {
|
107
|
-
|
122
|
+
let input;
|
123
|
+
|
108
124
|
if (parseInt(process.versions.node) >= 8) {
|
109
125
|
input = literals;
|
110
126
|
} else {
|
111
|
-
input =
|
127
|
+
input = Buffer.from(literals);
|
112
128
|
}
|
113
|
-
|
129
|
+
|
130
|
+
const output = require("zlib").deflateSync(input, {
|
131
|
+
level: 9
|
132
|
+
});
|
133
|
+
|
114
134
|
return output instanceof Uint8Array ? output : new Uint8Array(output);
|
115
135
|
} catch (e) {
|
116
|
-
(0, _util.warn)(
|
136
|
+
(0, _util.warn)("Not compressing PNG because zlib.deflateSync is unavailable: " + e);
|
117
137
|
}
|
138
|
+
|
118
139
|
return deflateSyncUncompressed(literals);
|
119
140
|
}
|
141
|
+
|
120
142
|
function deflateSyncUncompressed(literals) {
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
143
|
+
let len = literals.length;
|
144
|
+
const maxBlockLength = 0xffff;
|
145
|
+
const deflateBlocks = Math.ceil(len / maxBlockLength);
|
146
|
+
const idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
|
147
|
+
let pi = 0;
|
126
148
|
idat[pi++] = 0x78;
|
127
149
|
idat[pi++] = 0x9c;
|
128
|
-
|
150
|
+
let pos = 0;
|
151
|
+
|
129
152
|
while (len > maxBlockLength) {
|
130
153
|
idat[pi++] = 0x00;
|
131
154
|
idat[pi++] = 0xff;
|
@@ -137,6 +160,7 @@ var SVGGraphics = function SVGGraphics() {
|
|
137
160
|
pos += maxBlockLength;
|
138
161
|
len -= maxBlockLength;
|
139
162
|
}
|
163
|
+
|
140
164
|
idat[pi++] = 0x01;
|
141
165
|
idat[pi++] = len & 0xff;
|
142
166
|
idat[pi++] = len >> 8 & 0xff;
|
@@ -144,77 +168,89 @@ var SVGGraphics = function SVGGraphics() {
|
|
144
168
|
idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
|
145
169
|
idat.set(literals.subarray(pos), pi);
|
146
170
|
pi += literals.length - pos;
|
147
|
-
|
171
|
+
const adler = adler32(literals, 0, literals.length);
|
148
172
|
idat[pi++] = adler >> 24 & 0xff;
|
149
173
|
idat[pi++] = adler >> 16 & 0xff;
|
150
174
|
idat[pi++] = adler >> 8 & 0xff;
|
151
175
|
idat[pi++] = adler & 0xff;
|
152
176
|
return idat;
|
153
177
|
}
|
178
|
+
|
154
179
|
function encode(imgData, kind, forceDataSchema, isMask) {
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
180
|
+
const width = imgData.width;
|
181
|
+
const height = imgData.height;
|
182
|
+
let bitDepth, colorType, lineSize;
|
183
|
+
const bytes = imgData.data;
|
184
|
+
|
159
185
|
switch (kind) {
|
160
186
|
case _util.ImageKind.GRAYSCALE_1BPP:
|
161
187
|
colorType = 0;
|
162
188
|
bitDepth = 1;
|
163
189
|
lineSize = width + 7 >> 3;
|
164
190
|
break;
|
191
|
+
|
165
192
|
case _util.ImageKind.RGB_24BPP:
|
166
193
|
colorType = 2;
|
167
194
|
bitDepth = 8;
|
168
195
|
lineSize = width * 3;
|
169
196
|
break;
|
197
|
+
|
170
198
|
case _util.ImageKind.RGBA_32BPP:
|
171
199
|
colorType = 6;
|
172
200
|
bitDepth = 8;
|
173
201
|
lineSize = width * 4;
|
174
202
|
break;
|
203
|
+
|
175
204
|
default:
|
176
|
-
throw new Error(
|
205
|
+
throw new Error("invalid format");
|
177
206
|
}
|
178
|
-
|
179
|
-
|
207
|
+
|
208
|
+
const literals = new Uint8Array((1 + lineSize) * height);
|
209
|
+
let offsetLiterals = 0,
|
180
210
|
offsetBytes = 0;
|
181
|
-
|
182
|
-
for (y = 0; y < height; ++y) {
|
211
|
+
|
212
|
+
for (let y = 0; y < height; ++y) {
|
183
213
|
literals[offsetLiterals++] = 0;
|
184
214
|
literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
|
185
215
|
offsetBytes += lineSize;
|
186
216
|
offsetLiterals += lineSize;
|
187
217
|
}
|
218
|
+
|
188
219
|
if (kind === _util.ImageKind.GRAYSCALE_1BPP && isMask) {
|
189
220
|
offsetLiterals = 0;
|
190
|
-
|
221
|
+
|
222
|
+
for (let y = 0; y < height; y++) {
|
191
223
|
offsetLiterals++;
|
192
|
-
|
193
|
-
|
224
|
+
|
225
|
+
for (let i = 0; i < lineSize; i++) {
|
226
|
+
literals[offsetLiterals++] ^= 0xff;
|
194
227
|
}
|
195
228
|
}
|
196
229
|
}
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
230
|
+
|
231
|
+
const ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]);
|
232
|
+
const idat = deflateSync(literals);
|
233
|
+
const pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
|
234
|
+
const data = new Uint8Array(pngLength);
|
235
|
+
let offset = 0;
|
202
236
|
data.set(PNG_HEADER, offset);
|
203
237
|
offset += PNG_HEADER.length;
|
204
|
-
writePngChunk(
|
238
|
+
writePngChunk("IHDR", ihdr, data, offset);
|
205
239
|
offset += CHUNK_WRAPPER_SIZE + ihdr.length;
|
206
|
-
writePngChunk(
|
240
|
+
writePngChunk("IDATA", idat, data, offset);
|
207
241
|
offset += CHUNK_WRAPPER_SIZE + idat.length;
|
208
|
-
writePngChunk(
|
209
|
-
return (0, _util.createObjectURL)(data,
|
242
|
+
writePngChunk("IEND", new Uint8Array(0), data, offset);
|
243
|
+
return (0, _util.createObjectURL)(data, "image/png", forceDataSchema);
|
210
244
|
}
|
245
|
+
|
211
246
|
return function convertImgDataToPng(imgData, forceDataSchema, isMask) {
|
212
|
-
|
247
|
+
const kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind;
|
213
248
|
return encode(imgData, kind, forceDataSchema, isMask);
|
214
249
|
};
|
215
250
|
}();
|
216
|
-
|
217
|
-
|
251
|
+
|
252
|
+
class SVGExtraState {
|
253
|
+
constructor() {
|
218
254
|
this.fontSizeScale = 1;
|
219
255
|
this.fontWeight = SVG_DEFAULTS.fontWeight;
|
220
256
|
this.fontSize = 0;
|
@@ -222,6 +258,7 @@ var SVGGraphics = function SVGGraphics() {
|
|
222
258
|
this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
|
223
259
|
this.leading = 0;
|
224
260
|
this.textRenderingMode = _util.TextRenderingMode.FILL;
|
261
|
+
this.textMatrixScale = 1;
|
225
262
|
this.x = 0;
|
226
263
|
this.y = 0;
|
227
264
|
this.lineX = 0;
|
@@ -231,90 +268,106 @@ var SVGGraphics = function SVGGraphics() {
|
|
231
268
|
this.textHScale = 1;
|
232
269
|
this.textRise = 0;
|
233
270
|
this.fillColor = SVG_DEFAULTS.fillColor;
|
234
|
-
this.strokeColor =
|
271
|
+
this.strokeColor = "#000000";
|
235
272
|
this.fillAlpha = 1;
|
236
273
|
this.strokeAlpha = 1;
|
237
274
|
this.lineWidth = 1;
|
238
|
-
this.lineJoin =
|
239
|
-
this.lineCap =
|
275
|
+
this.lineJoin = "";
|
276
|
+
this.lineCap = "";
|
240
277
|
this.miterLimit = 0;
|
241
278
|
this.dashArray = [];
|
242
279
|
this.dashPhase = 0;
|
243
280
|
this.dependencies = [];
|
244
281
|
this.activeClipUrl = null;
|
245
282
|
this.clipGroup = null;
|
246
|
-
this.maskId =
|
247
|
-
}
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
283
|
+
this.maskId = "";
|
284
|
+
}
|
285
|
+
|
286
|
+
clone() {
|
287
|
+
return Object.create(this);
|
288
|
+
}
|
289
|
+
|
290
|
+
setCurrentPoint(x, y) {
|
291
|
+
this.x = x;
|
292
|
+
this.y = y;
|
293
|
+
}
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
function opListToTree(opList) {
|
298
|
+
let opTree = [];
|
299
|
+
const tmp = [];
|
300
|
+
|
301
|
+
for (const opListElement of opList) {
|
302
|
+
if (opListElement.fn === "save") {
|
303
|
+
opTree.push({
|
304
|
+
fnId: 92,
|
305
|
+
fn: "group",
|
306
|
+
items: []
|
307
|
+
});
|
308
|
+
tmp.push(opTree);
|
309
|
+
opTree = opTree[opTree.length - 1].items;
|
310
|
+
continue;
|
255
311
|
}
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
var opTree = [];
|
262
|
-
var tmp = [];
|
263
|
-
var opListLen = opList.length;
|
264
|
-
for (var x = 0; x < opListLen; x++) {
|
265
|
-
if (opList[x].fn === 'save') {
|
266
|
-
opTree.push({
|
267
|
-
'fnId': 92,
|
268
|
-
'fn': 'group',
|
269
|
-
'items': []
|
270
|
-
});
|
271
|
-
tmp.push(opTree);
|
272
|
-
opTree = opTree[opTree.length - 1].items;
|
273
|
-
continue;
|
274
|
-
}
|
275
|
-
if (opList[x].fn === 'restore') {
|
276
|
-
opTree = tmp.pop();
|
277
|
-
} else {
|
278
|
-
opTree.push(opList[x]);
|
279
|
-
}
|
312
|
+
|
313
|
+
if (opListElement.fn === "restore") {
|
314
|
+
opTree = tmp.pop();
|
315
|
+
} else {
|
316
|
+
opTree.push(opListElement);
|
280
317
|
}
|
281
|
-
return opTree;
|
282
318
|
}
|
283
|
-
|
284
|
-
|
285
|
-
|
319
|
+
|
320
|
+
return opTree;
|
321
|
+
}
|
322
|
+
|
323
|
+
function pf(value) {
|
324
|
+
if (Number.isInteger(value)) {
|
325
|
+
return value.toString();
|
326
|
+
}
|
327
|
+
|
328
|
+
const s = value.toFixed(10);
|
329
|
+
let i = s.length - 1;
|
330
|
+
|
331
|
+
if (s[i] !== "0") {
|
332
|
+
return s;
|
333
|
+
}
|
334
|
+
|
335
|
+
do {
|
336
|
+
i--;
|
337
|
+
} while (s[i] === "0");
|
338
|
+
|
339
|
+
return s.substring(0, s[i] === "." ? i : i + 1);
|
340
|
+
}
|
341
|
+
|
342
|
+
function pm(m) {
|
343
|
+
if (m[4] === 0 && m[5] === 0) {
|
344
|
+
if (m[1] === 0 && m[2] === 0) {
|
345
|
+
if (m[0] === 1 && m[3] === 1) {
|
346
|
+
return "";
|
347
|
+
}
|
348
|
+
|
349
|
+
return `scale(${pf(m[0])} ${pf(m[3])})`;
|
286
350
|
}
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
return
|
351
|
+
|
352
|
+
if (m[0] === m[3] && m[1] === -m[2]) {
|
353
|
+
const a = Math.acos(m[0]) * 180 / Math.PI;
|
354
|
+
return `rotate(${pf(a)})`;
|
291
355
|
}
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
return s.substring(0, s[i] === '.' ? i : i + 1);
|
296
|
-
}
|
297
|
-
function pm(m) {
|
298
|
-
if (m[4] === 0 && m[5] === 0) {
|
299
|
-
if (m[1] === 0 && m[2] === 0) {
|
300
|
-
if (m[0] === 1 && m[3] === 1) {
|
301
|
-
return '';
|
302
|
-
}
|
303
|
-
return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
|
304
|
-
}
|
305
|
-
if (m[0] === m[3] && m[1] === -m[2]) {
|
306
|
-
var a = Math.acos(m[0]) * 180 / Math.PI;
|
307
|
-
return 'rotate(' + pf(a) + ')';
|
308
|
-
}
|
309
|
-
} else {
|
310
|
-
if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
|
311
|
-
return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
|
312
|
-
}
|
356
|
+
} else {
|
357
|
+
if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
|
358
|
+
return `translate(${pf(m[4])} ${pf(m[5])})`;
|
313
359
|
}
|
314
|
-
return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
|
315
360
|
}
|
316
|
-
|
317
|
-
|
361
|
+
|
362
|
+
return `matrix(${pf(m[0])} ${pf(m[1])} ${pf(m[2])} ${pf(m[3])} ${pf(m[4])} ` + `${pf(m[5])})`;
|
363
|
+
}
|
364
|
+
|
365
|
+
let clipCount = 0;
|
366
|
+
let maskCount = 0;
|
367
|
+
let shadingCount = 0;
|
368
|
+
exports.SVGGraphics = SVGGraphics = class SVGGraphics {
|
369
|
+
constructor(commonObjs, objs, forceDataSchema) {
|
370
|
+
this.svgFactory = new _display_utils.DOMSVGFactory();
|
318
371
|
this.current = new SVGExtraState();
|
319
372
|
this.transformMatrix = _util.IDENTITY_MATRIX;
|
320
373
|
this.transformStack = [];
|
@@ -327,774 +380,1132 @@ var SVGGraphics = function SVGGraphics() {
|
|
327
380
|
this.embeddedFonts = Object.create(null);
|
328
381
|
this.cssStyle = null;
|
329
382
|
this.forceDataSchema = !!forceDataSchema;
|
383
|
+
this._operatorIdMapping = [];
|
384
|
+
|
385
|
+
for (const op in _util.OPS) {
|
386
|
+
this._operatorIdMapping[_util.OPS[op]] = op;
|
387
|
+
}
|
330
388
|
}
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
var fnArrayLen = fnArray.length;
|
360
|
-
var argsArray = operatorList.argsArray;
|
361
|
-
for (var i = 0; i < fnArrayLen; i++) {
|
362
|
-
if (_util.OPS.dependency === fnArray[i]) {
|
363
|
-
var deps = argsArray[i];
|
364
|
-
for (var n = 0, nn = deps.length; n < nn; n++) {
|
365
|
-
var obj = deps[n];
|
366
|
-
var common = obj.substring(0, 2) === 'g_';
|
367
|
-
var promise;
|
368
|
-
if (common) {
|
369
|
-
promise = new Promise(function (resolve) {
|
370
|
-
_this.commonObjs.get(obj, resolve);
|
371
|
-
});
|
372
|
-
} else {
|
373
|
-
promise = new Promise(function (resolve) {
|
374
|
-
_this.objs.get(obj, resolve);
|
375
|
-
});
|
376
|
-
}
|
377
|
-
this.current.dependencies.push(promise);
|
378
|
-
}
|
379
|
-
}
|
380
|
-
}
|
381
|
-
return Promise.all(this.current.dependencies);
|
382
|
-
},
|
383
|
-
transform: function SVGGraphics_transform(a, b, c, d, e, f) {
|
384
|
-
var transformMatrix = [a, b, c, d, e, f];
|
385
|
-
this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
|
386
|
-
this.tgrp = null;
|
387
|
-
},
|
388
|
-
getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
|
389
|
-
var _this2 = this;
|
390
|
-
|
391
|
-
this.viewport = viewport;
|
392
|
-
var svgElement = this._initialize(viewport);
|
393
|
-
return this.loadDependencies(operatorList).then(function () {
|
394
|
-
_this2.transformMatrix = _util.IDENTITY_MATRIX;
|
395
|
-
var opTree = _this2.convertOpList(operatorList);
|
396
|
-
_this2.executeOpTree(opTree);
|
397
|
-
return svgElement;
|
398
|
-
});
|
399
|
-
},
|
400
|
-
convertOpList: function SVGGraphics_convertOpList(operatorList) {
|
401
|
-
var argsArray = operatorList.argsArray;
|
402
|
-
var fnArray = operatorList.fnArray;
|
403
|
-
var fnArrayLen = fnArray.length;
|
404
|
-
var REVOPS = [];
|
405
|
-
var opList = [];
|
406
|
-
for (var op in _util.OPS) {
|
407
|
-
REVOPS[_util.OPS[op]] = op;
|
389
|
+
|
390
|
+
save() {
|
391
|
+
this.transformStack.push(this.transformMatrix);
|
392
|
+
const old = this.current;
|
393
|
+
this.extraStack.push(old);
|
394
|
+
this.current = old.clone();
|
395
|
+
}
|
396
|
+
|
397
|
+
restore() {
|
398
|
+
this.transformMatrix = this.transformStack.pop();
|
399
|
+
this.current = this.extraStack.pop();
|
400
|
+
this.pendingClip = null;
|
401
|
+
this.tgrp = null;
|
402
|
+
}
|
403
|
+
|
404
|
+
group(items) {
|
405
|
+
this.save();
|
406
|
+
this.executeOpTree(items);
|
407
|
+
this.restore();
|
408
|
+
}
|
409
|
+
|
410
|
+
loadDependencies(operatorList) {
|
411
|
+
const fnArray = operatorList.fnArray;
|
412
|
+
const argsArray = operatorList.argsArray;
|
413
|
+
|
414
|
+
for (let i = 0, ii = fnArray.length; i < ii; i++) {
|
415
|
+
if (fnArray[i] !== _util.OPS.dependency) {
|
416
|
+
continue;
|
408
417
|
}
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
'args': argsArray[x]
|
418
|
+
|
419
|
+
for (const obj of argsArray[i]) {
|
420
|
+
const objsPool = obj.startsWith("g_") ? this.commonObjs : this.objs;
|
421
|
+
const promise = new Promise(resolve => {
|
422
|
+
objsPool.get(obj, resolve);
|
415
423
|
});
|
424
|
+
this.current.dependencies.push(promise);
|
416
425
|
}
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
426
|
+
}
|
427
|
+
|
428
|
+
return Promise.all(this.current.dependencies);
|
429
|
+
}
|
430
|
+
|
431
|
+
transform(a, b, c, d, e, f) {
|
432
|
+
const transformMatrix = [a, b, c, d, e, f];
|
433
|
+
this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
|
434
|
+
this.tgrp = null;
|
435
|
+
}
|
436
|
+
|
437
|
+
getSVG(operatorList, viewport) {
|
438
|
+
this.viewport = viewport;
|
439
|
+
|
440
|
+
const svgElement = this._initialize(viewport);
|
441
|
+
|
442
|
+
return this.loadDependencies(operatorList).then(() => {
|
443
|
+
this.transformMatrix = _util.IDENTITY_MATRIX;
|
444
|
+
this.executeOpTree(this.convertOpList(operatorList));
|
445
|
+
return svgElement;
|
446
|
+
});
|
447
|
+
}
|
448
|
+
|
449
|
+
convertOpList(operatorList) {
|
450
|
+
const operatorIdMapping = this._operatorIdMapping;
|
451
|
+
const argsArray = operatorList.argsArray;
|
452
|
+
const fnArray = operatorList.fnArray;
|
453
|
+
const opList = [];
|
454
|
+
|
455
|
+
for (let i = 0, ii = fnArray.length; i < ii; i++) {
|
456
|
+
const fnId = fnArray[i];
|
457
|
+
opList.push({
|
458
|
+
fnId,
|
459
|
+
fn: operatorIdMapping[fnId],
|
460
|
+
args: argsArray[i]
|
461
|
+
});
|
462
|
+
}
|
463
|
+
|
464
|
+
return opListToTree(opList);
|
465
|
+
}
|
466
|
+
|
467
|
+
executeOpTree(opTree) {
|
468
|
+
for (const opTreeElement of opTree) {
|
469
|
+
const fn = opTreeElement.fn;
|
470
|
+
const fnId = opTreeElement.fnId;
|
471
|
+
const args = opTreeElement.args;
|
472
|
+
|
473
|
+
switch (fnId | 0) {
|
474
|
+
case _util.OPS.beginText:
|
475
|
+
this.beginText();
|
476
|
+
break;
|
477
|
+
|
478
|
+
case _util.OPS.dependency:
|
479
|
+
break;
|
480
|
+
|
481
|
+
case _util.OPS.setLeading:
|
482
|
+
this.setLeading(args);
|
483
|
+
break;
|
484
|
+
|
485
|
+
case _util.OPS.setLeadingMoveText:
|
486
|
+
this.setLeadingMoveText(args[0], args[1]);
|
487
|
+
break;
|
488
|
+
|
489
|
+
case _util.OPS.setFont:
|
490
|
+
this.setFont(args);
|
491
|
+
break;
|
492
|
+
|
493
|
+
case _util.OPS.showText:
|
494
|
+
this.showText(args[0]);
|
495
|
+
break;
|
496
|
+
|
497
|
+
case _util.OPS.showSpacedText:
|
498
|
+
this.showText(args[0]);
|
499
|
+
break;
|
500
|
+
|
501
|
+
case _util.OPS.endText:
|
502
|
+
this.endText();
|
503
|
+
break;
|
504
|
+
|
505
|
+
case _util.OPS.moveText:
|
506
|
+
this.moveText(args[0], args[1]);
|
507
|
+
break;
|
508
|
+
|
509
|
+
case _util.OPS.setCharSpacing:
|
510
|
+
this.setCharSpacing(args[0]);
|
511
|
+
break;
|
512
|
+
|
513
|
+
case _util.OPS.setWordSpacing:
|
514
|
+
this.setWordSpacing(args[0]);
|
515
|
+
break;
|
516
|
+
|
517
|
+
case _util.OPS.setHScale:
|
518
|
+
this.setHScale(args[0]);
|
519
|
+
break;
|
520
|
+
|
521
|
+
case _util.OPS.setTextMatrix:
|
522
|
+
this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
|
523
|
+
break;
|
524
|
+
|
525
|
+
case _util.OPS.setTextRise:
|
526
|
+
this.setTextRise(args[0]);
|
527
|
+
break;
|
528
|
+
|
529
|
+
case _util.OPS.setTextRenderingMode:
|
530
|
+
this.setTextRenderingMode(args[0]);
|
531
|
+
break;
|
532
|
+
|
533
|
+
case _util.OPS.setLineWidth:
|
534
|
+
this.setLineWidth(args[0]);
|
535
|
+
break;
|
536
|
+
|
537
|
+
case _util.OPS.setLineJoin:
|
538
|
+
this.setLineJoin(args[0]);
|
539
|
+
break;
|
540
|
+
|
541
|
+
case _util.OPS.setLineCap:
|
542
|
+
this.setLineCap(args[0]);
|
543
|
+
break;
|
544
|
+
|
545
|
+
case _util.OPS.setMiterLimit:
|
546
|
+
this.setMiterLimit(args[0]);
|
547
|
+
break;
|
548
|
+
|
549
|
+
case _util.OPS.setFillRGBColor:
|
550
|
+
this.setFillRGBColor(args[0], args[1], args[2]);
|
551
|
+
break;
|
552
|
+
|
553
|
+
case _util.OPS.setStrokeRGBColor:
|
554
|
+
this.setStrokeRGBColor(args[0], args[1], args[2]);
|
555
|
+
break;
|
556
|
+
|
557
|
+
case _util.OPS.setStrokeColorN:
|
558
|
+
this.setStrokeColorN(args);
|
559
|
+
break;
|
560
|
+
|
561
|
+
case _util.OPS.setFillColorN:
|
562
|
+
this.setFillColorN(args);
|
563
|
+
break;
|
564
|
+
|
565
|
+
case _util.OPS.shadingFill:
|
566
|
+
this.shadingFill(args[0]);
|
567
|
+
break;
|
568
|
+
|
569
|
+
case _util.OPS.setDash:
|
570
|
+
this.setDash(args[0], args[1]);
|
571
|
+
break;
|
572
|
+
|
573
|
+
case _util.OPS.setRenderingIntent:
|
574
|
+
this.setRenderingIntent(args[0]);
|
575
|
+
break;
|
576
|
+
|
577
|
+
case _util.OPS.setFlatness:
|
578
|
+
this.setFlatness(args[0]);
|
579
|
+
break;
|
580
|
+
|
581
|
+
case _util.OPS.setGState:
|
582
|
+
this.setGState(args[0]);
|
583
|
+
break;
|
584
|
+
|
585
|
+
case _util.OPS.fill:
|
586
|
+
this.fill();
|
587
|
+
break;
|
588
|
+
|
589
|
+
case _util.OPS.eoFill:
|
590
|
+
this.eoFill();
|
591
|
+
break;
|
592
|
+
|
593
|
+
case _util.OPS.stroke:
|
594
|
+
this.stroke();
|
595
|
+
break;
|
596
|
+
|
597
|
+
case _util.OPS.fillStroke:
|
598
|
+
this.fillStroke();
|
599
|
+
break;
|
600
|
+
|
601
|
+
case _util.OPS.eoFillStroke:
|
602
|
+
this.eoFillStroke();
|
603
|
+
break;
|
604
|
+
|
605
|
+
case _util.OPS.clip:
|
606
|
+
this.clip("nonzero");
|
607
|
+
break;
|
608
|
+
|
609
|
+
case _util.OPS.eoClip:
|
610
|
+
this.clip("evenodd");
|
611
|
+
break;
|
612
|
+
|
613
|
+
case _util.OPS.paintSolidColorImageMask:
|
614
|
+
this.paintSolidColorImageMask();
|
615
|
+
break;
|
616
|
+
|
617
|
+
case _util.OPS.paintJpegXObject:
|
618
|
+
this.paintJpegXObject(args[0], args[1], args[2]);
|
619
|
+
break;
|
620
|
+
|
621
|
+
case _util.OPS.paintImageXObject:
|
622
|
+
this.paintImageXObject(args[0]);
|
623
|
+
break;
|
624
|
+
|
625
|
+
case _util.OPS.paintInlineImageXObject:
|
626
|
+
this.paintInlineImageXObject(args[0]);
|
627
|
+
break;
|
628
|
+
|
629
|
+
case _util.OPS.paintImageMaskXObject:
|
630
|
+
this.paintImageMaskXObject(args[0]);
|
631
|
+
break;
|
632
|
+
|
633
|
+
case _util.OPS.paintFormXObjectBegin:
|
634
|
+
this.paintFormXObjectBegin(args[0], args[1]);
|
635
|
+
break;
|
636
|
+
|
637
|
+
case _util.OPS.paintFormXObjectEnd:
|
638
|
+
this.paintFormXObjectEnd();
|
639
|
+
break;
|
640
|
+
|
641
|
+
case _util.OPS.closePath:
|
642
|
+
this.closePath();
|
643
|
+
break;
|
644
|
+
|
645
|
+
case _util.OPS.closeStroke:
|
646
|
+
this.closeStroke();
|
647
|
+
break;
|
648
|
+
|
649
|
+
case _util.OPS.closeFillStroke:
|
650
|
+
this.closeFillStroke();
|
651
|
+
break;
|
652
|
+
|
653
|
+
case _util.OPS.closeEOFillStroke:
|
654
|
+
this.closeEOFillStroke();
|
655
|
+
break;
|
656
|
+
|
657
|
+
case _util.OPS.nextLine:
|
658
|
+
this.nextLine();
|
659
|
+
break;
|
660
|
+
|
661
|
+
case _util.OPS.transform:
|
662
|
+
this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
|
663
|
+
break;
|
664
|
+
|
665
|
+
case _util.OPS.constructPath:
|
666
|
+
this.constructPath(args[0], args[1]);
|
667
|
+
break;
|
668
|
+
|
669
|
+
case _util.OPS.endPath:
|
670
|
+
this.endPath();
|
671
|
+
break;
|
672
|
+
|
673
|
+
case 92:
|
674
|
+
this.group(opTreeElement.items);
|
675
|
+
break;
|
676
|
+
|
677
|
+
default:
|
678
|
+
(0, _util.warn)(`Unimplemented operator ${fn}`);
|
679
|
+
break;
|
567
680
|
}
|
568
|
-
}
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
681
|
+
}
|
682
|
+
}
|
683
|
+
|
684
|
+
setWordSpacing(wordSpacing) {
|
685
|
+
this.current.wordSpacing = wordSpacing;
|
686
|
+
}
|
687
|
+
|
688
|
+
setCharSpacing(charSpacing) {
|
689
|
+
this.current.charSpacing = charSpacing;
|
690
|
+
}
|
691
|
+
|
692
|
+
nextLine() {
|
693
|
+
this.moveText(0, this.current.leading);
|
694
|
+
}
|
695
|
+
|
696
|
+
setTextMatrix(a, b, c, d, e, f) {
|
697
|
+
const current = this.current;
|
698
|
+
current.textMatrix = current.lineMatrix = [a, b, c, d, e, f];
|
699
|
+
current.textMatrixScale = Math.sqrt(a * a + b * b);
|
700
|
+
current.x = current.lineX = 0;
|
701
|
+
current.y = current.lineY = 0;
|
702
|
+
current.xcoords = [];
|
703
|
+
current.tspan = this.svgFactory.createElement("svg:tspan");
|
704
|
+
current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
|
705
|
+
current.tspan.setAttributeNS(null, "font-size", `${pf(current.fontSize)}px`);
|
706
|
+
current.tspan.setAttributeNS(null, "y", pf(-current.y));
|
707
|
+
current.txtElement = this.svgFactory.createElement("svg:text");
|
708
|
+
current.txtElement.appendChild(current.tspan);
|
709
|
+
}
|
710
|
+
|
711
|
+
beginText() {
|
712
|
+
const current = this.current;
|
713
|
+
current.x = current.lineX = 0;
|
714
|
+
current.y = current.lineY = 0;
|
715
|
+
current.textMatrix = _util.IDENTITY_MATRIX;
|
716
|
+
current.lineMatrix = _util.IDENTITY_MATRIX;
|
717
|
+
current.textMatrixScale = 1;
|
718
|
+
current.tspan = this.svgFactory.createElement("svg:tspan");
|
719
|
+
current.txtElement = this.svgFactory.createElement("svg:text");
|
720
|
+
current.txtgrp = this.svgFactory.createElement("svg:g");
|
721
|
+
current.xcoords = [];
|
722
|
+
}
|
723
|
+
|
724
|
+
moveText(x, y) {
|
725
|
+
const current = this.current;
|
726
|
+
current.x = current.lineX += x;
|
727
|
+
current.y = current.lineY += y;
|
728
|
+
current.xcoords = [];
|
729
|
+
current.tspan = this.svgFactory.createElement("svg:tspan");
|
730
|
+
current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
|
731
|
+
current.tspan.setAttributeNS(null, "font-size", `${pf(current.fontSize)}px`);
|
732
|
+
current.tspan.setAttributeNS(null, "y", pf(-current.y));
|
733
|
+
}
|
734
|
+
|
735
|
+
showText(glyphs) {
|
736
|
+
const current = this.current;
|
737
|
+
const font = current.font;
|
738
|
+
const fontSize = current.fontSize;
|
739
|
+
|
740
|
+
if (fontSize === 0) {
|
741
|
+
return;
|
742
|
+
}
|
743
|
+
|
744
|
+
const charSpacing = current.charSpacing;
|
745
|
+
const wordSpacing = current.wordSpacing;
|
746
|
+
const fontDirection = current.fontDirection;
|
747
|
+
const textHScale = current.textHScale * fontDirection;
|
748
|
+
const vertical = font.vertical;
|
749
|
+
const widthAdvanceScale = fontSize * current.fontMatrix[0];
|
750
|
+
let x = 0;
|
751
|
+
|
752
|
+
for (const glyph of glyphs) {
|
753
|
+
if (glyph === null) {
|
754
|
+
x += fontDirection * wordSpacing;
|
755
|
+
continue;
|
756
|
+
} else if ((0, _util.isNum)(glyph)) {
|
757
|
+
x += -glyph * fontSize * 0.001;
|
758
|
+
continue;
|
617
759
|
}
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
var x = 0,
|
626
|
-
i;
|
627
|
-
for (i = 0; i < glyphsLength; ++i) {
|
628
|
-
var glyph = glyphs[i];
|
629
|
-
if (glyph === null) {
|
630
|
-
x += fontDirection * wordSpacing;
|
631
|
-
continue;
|
632
|
-
} else if ((0, _util.isNum)(glyph)) {
|
633
|
-
x += -glyph * fontSize * 0.001;
|
634
|
-
continue;
|
635
|
-
}
|
636
|
-
var width = glyph.width;
|
637
|
-
var character = glyph.fontChar;
|
638
|
-
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
|
639
|
-
var charWidth = width * widthAdvanceScale + spacing * fontDirection;
|
640
|
-
if (!glyph.isInFont && !font.missingFile) {
|
641
|
-
x += charWidth;
|
642
|
-
continue;
|
643
|
-
}
|
644
|
-
current.xcoords.push(current.x + x * textHScale);
|
645
|
-
current.tspan.textContent += character;
|
760
|
+
|
761
|
+
const width = glyph.width;
|
762
|
+
const character = glyph.fontChar;
|
763
|
+
const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
|
764
|
+
const charWidth = width * widthAdvanceScale + spacing * fontDirection;
|
765
|
+
|
766
|
+
if (!glyph.isInFont && !font.missingFile) {
|
646
767
|
x += charWidth;
|
768
|
+
continue;
|
647
769
|
}
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
current.
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
if (
|
677
|
-
|
678
|
-
}
|
679
|
-
var textMatrix = current.textMatrix;
|
680
|
-
if (current.textRise !== 0) {
|
681
|
-
textMatrix = textMatrix.slice();
|
682
|
-
textMatrix[5] += current.textRise;
|
770
|
+
|
771
|
+
current.xcoords.push(current.x + x);
|
772
|
+
current.tspan.textContent += character;
|
773
|
+
x += charWidth;
|
774
|
+
}
|
775
|
+
|
776
|
+
if (vertical) {
|
777
|
+
current.y -= x * textHScale;
|
778
|
+
} else {
|
779
|
+
current.x += x * textHScale;
|
780
|
+
}
|
781
|
+
|
782
|
+
current.tspan.setAttributeNS(null, "x", current.xcoords.map(pf).join(" "));
|
783
|
+
current.tspan.setAttributeNS(null, "y", pf(-current.y));
|
784
|
+
current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
|
785
|
+
current.tspan.setAttributeNS(null, "font-size", `${pf(current.fontSize)}px`);
|
786
|
+
|
787
|
+
if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
|
788
|
+
current.tspan.setAttributeNS(null, "font-style", current.fontStyle);
|
789
|
+
}
|
790
|
+
|
791
|
+
if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
|
792
|
+
current.tspan.setAttributeNS(null, "font-weight", current.fontWeight);
|
793
|
+
}
|
794
|
+
|
795
|
+
const fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
|
796
|
+
|
797
|
+
if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
|
798
|
+
if (current.fillColor !== SVG_DEFAULTS.fillColor) {
|
799
|
+
current.tspan.setAttributeNS(null, "fill", current.fillColor);
|
683
800
|
}
|
684
|
-
|
685
|
-
current.
|
686
|
-
|
687
|
-
current.txtgrp.appendChild(current.txtElement);
|
688
|
-
this._ensureTransformGroup().appendChild(current.txtElement);
|
689
|
-
},
|
690
|
-
setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
|
691
|
-
this.setLeading(-y);
|
692
|
-
this.moveText(x, y);
|
693
|
-
},
|
694
|
-
addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
|
695
|
-
if (!this.cssStyle) {
|
696
|
-
this.cssStyle = this.svgFactory.createElement('svg:style');
|
697
|
-
this.cssStyle.setAttributeNS(null, 'type', 'text/css');
|
698
|
-
this.defs.appendChild(this.cssStyle);
|
801
|
+
|
802
|
+
if (current.fillAlpha < 1) {
|
803
|
+
current.tspan.setAttributeNS(null, "fill-opacity", current.fillAlpha);
|
699
804
|
}
|
700
|
-
|
701
|
-
|
702
|
-
}
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
805
|
+
} else if (current.textRenderingMode === _util.TextRenderingMode.ADD_TO_PATH) {
|
806
|
+
current.tspan.setAttributeNS(null, "fill", "transparent");
|
807
|
+
} else {
|
808
|
+
current.tspan.setAttributeNS(null, "fill", "none");
|
809
|
+
}
|
810
|
+
|
811
|
+
if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
|
812
|
+
const lineWidthScale = 1 / (current.textMatrixScale || 1);
|
813
|
+
|
814
|
+
this._setStrokeAttributes(current.tspan, lineWidthScale);
|
815
|
+
}
|
816
|
+
|
817
|
+
let textMatrix = current.textMatrix;
|
818
|
+
|
819
|
+
if (current.textRise !== 0) {
|
820
|
+
textMatrix = textMatrix.slice();
|
821
|
+
textMatrix[5] += current.textRise;
|
822
|
+
}
|
823
|
+
|
824
|
+
current.txtElement.setAttributeNS(null, "transform", `${pm(textMatrix)} scale(${pf(textHScale)}, -1)`);
|
825
|
+
current.txtElement.setAttributeNS(XML_NS, "xml:space", "preserve");
|
826
|
+
current.txtElement.appendChild(current.tspan);
|
827
|
+
current.txtgrp.appendChild(current.txtElement);
|
828
|
+
|
829
|
+
this._ensureTransformGroup().appendChild(current.txtElement);
|
830
|
+
}
|
831
|
+
|
832
|
+
setLeadingMoveText(x, y) {
|
833
|
+
this.setLeading(-y);
|
834
|
+
this.moveText(x, y);
|
835
|
+
}
|
836
|
+
|
837
|
+
addFontStyle(fontObj) {
|
838
|
+
if (!this.cssStyle) {
|
839
|
+
this.cssStyle = this.svgFactory.createElement("svg:style");
|
840
|
+
this.cssStyle.setAttributeNS(null, "type", "text/css");
|
841
|
+
this.defs.appendChild(this.cssStyle);
|
842
|
+
}
|
843
|
+
|
844
|
+
const url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema);
|
845
|
+
this.cssStyle.textContent += `@font-face { font-family: "${fontObj.loadedName}";` + ` src: url(${url}); }\n`;
|
846
|
+
}
|
847
|
+
|
848
|
+
setFont(details) {
|
849
|
+
const current = this.current;
|
850
|
+
const fontObj = this.commonObjs.get(details[0]);
|
851
|
+
let size = details[1];
|
852
|
+
current.font = fontObj;
|
853
|
+
|
854
|
+
if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
|
855
|
+
this.addFontStyle(fontObj);
|
856
|
+
this.embeddedFonts[fontObj.loadedName] = fontObj;
|
857
|
+
}
|
858
|
+
|
859
|
+
current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
|
860
|
+
let bold = "normal";
|
861
|
+
|
862
|
+
if (fontObj.black) {
|
863
|
+
bold = "900";
|
864
|
+
} else if (fontObj.bold) {
|
865
|
+
bold = "bold";
|
866
|
+
}
|
867
|
+
|
868
|
+
const italic = fontObj.italic ? "italic" : "normal";
|
869
|
+
|
870
|
+
if (size < 0) {
|
871
|
+
size = -size;
|
872
|
+
current.fontDirection = -1;
|
873
|
+
} else {
|
874
|
+
current.fontDirection = 1;
|
875
|
+
}
|
876
|
+
|
877
|
+
current.fontSize = size;
|
878
|
+
current.fontFamily = fontObj.loadedName;
|
879
|
+
current.fontWeight = bold;
|
880
|
+
current.fontStyle = italic;
|
881
|
+
current.tspan = this.svgFactory.createElement("svg:tspan");
|
882
|
+
current.tspan.setAttributeNS(null, "y", pf(-current.y));
|
883
|
+
current.xcoords = [];
|
884
|
+
}
|
737
885
|
|
738
|
-
|
886
|
+
endText() {
|
887
|
+
const current = this.current;
|
888
|
+
|
889
|
+
if (current.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG && current.txtElement && current.txtElement.hasChildNodes()) {
|
890
|
+
current.element = current.txtElement;
|
891
|
+
this.clip("nonzero");
|
892
|
+
this.endPath();
|
893
|
+
}
|
894
|
+
}
|
895
|
+
|
896
|
+
setLineWidth(width) {
|
897
|
+
if (width > 0) {
|
739
898
|
this.current.lineWidth = width;
|
740
|
-
}
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
899
|
+
}
|
900
|
+
}
|
901
|
+
|
902
|
+
setLineCap(style) {
|
903
|
+
this.current.lineCap = LINE_CAP_STYLES[style];
|
904
|
+
}
|
905
|
+
|
906
|
+
setLineJoin(style) {
|
907
|
+
this.current.lineJoin = LINE_JOIN_STYLES[style];
|
908
|
+
}
|
909
|
+
|
910
|
+
setMiterLimit(limit) {
|
911
|
+
this.current.miterLimit = limit;
|
912
|
+
}
|
913
|
+
|
914
|
+
setStrokeAlpha(strokeAlpha) {
|
915
|
+
this.current.strokeAlpha = strokeAlpha;
|
916
|
+
}
|
917
|
+
|
918
|
+
setStrokeRGBColor(r, g, b) {
|
919
|
+
this.current.strokeColor = _util.Util.makeCssRgb(r, g, b);
|
920
|
+
}
|
921
|
+
|
922
|
+
setFillAlpha(fillAlpha) {
|
923
|
+
this.current.fillAlpha = fillAlpha;
|
924
|
+
}
|
925
|
+
|
926
|
+
setFillRGBColor(r, g, b) {
|
927
|
+
this.current.fillColor = _util.Util.makeCssRgb(r, g, b);
|
928
|
+
this.current.tspan = this.svgFactory.createElement("svg:tspan");
|
929
|
+
this.current.xcoords = [];
|
930
|
+
}
|
931
|
+
|
932
|
+
setStrokeColorN(args) {
|
933
|
+
this.current.strokeColor = this._makeColorN_Pattern(args);
|
934
|
+
}
|
935
|
+
|
936
|
+
setFillColorN(args) {
|
937
|
+
this.current.fillColor = this._makeColorN_Pattern(args);
|
938
|
+
}
|
939
|
+
|
940
|
+
shadingFill(args) {
|
941
|
+
const width = this.viewport.width;
|
942
|
+
const height = this.viewport.height;
|
943
|
+
|
944
|
+
const inv = _util.Util.inverseTransform(this.transformMatrix);
|
945
|
+
|
946
|
+
const bl = _util.Util.applyTransform([0, 0], inv);
|
947
|
+
|
948
|
+
const br = _util.Util.applyTransform([0, height], inv);
|
949
|
+
|
950
|
+
const ul = _util.Util.applyTransform([width, 0], inv);
|
951
|
+
|
952
|
+
const ur = _util.Util.applyTransform([width, height], inv);
|
953
|
+
|
954
|
+
const x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
|
955
|
+
const y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
|
956
|
+
const x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
|
957
|
+
const y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
|
958
|
+
const rect = this.svgFactory.createElement("svg:rect");
|
959
|
+
rect.setAttributeNS(null, "x", x0);
|
960
|
+
rect.setAttributeNS(null, "y", y0);
|
961
|
+
rect.setAttributeNS(null, "width", x1 - x0);
|
962
|
+
rect.setAttributeNS(null, "height", y1 - y0);
|
963
|
+
rect.setAttributeNS(null, "fill", this._makeShadingPattern(args));
|
964
|
+
|
965
|
+
this._ensureTransformGroup().appendChild(rect);
|
966
|
+
}
|
967
|
+
|
968
|
+
_makeColorN_Pattern(args) {
|
969
|
+
if (args[0] === "TilingPattern") {
|
970
|
+
return this._makeTilingPattern(args);
|
971
|
+
}
|
972
|
+
|
973
|
+
return this._makeShadingPattern(args);
|
974
|
+
}
|
975
|
+
|
976
|
+
_makeTilingPattern(args) {
|
977
|
+
const color = args[1];
|
978
|
+
const operatorList = args[2];
|
979
|
+
const matrix = args[3] || _util.IDENTITY_MATRIX;
|
980
|
+
const [x0, y0, x1, y1] = args[4];
|
981
|
+
const xstep = args[5];
|
982
|
+
const ystep = args[6];
|
983
|
+
const paintType = args[7];
|
984
|
+
const tilingId = `shading${shadingCount++}`;
|
985
|
+
|
986
|
+
const [tx0, ty0] = _util.Util.applyTransform([x0, y0], matrix);
|
987
|
+
|
988
|
+
const [tx1, ty1] = _util.Util.applyTransform([x1, y1], matrix);
|
989
|
+
|
990
|
+
const [xscale, yscale] = _util.Util.singularValueDecompose2dScale(matrix);
|
991
|
+
|
992
|
+
const txstep = xstep * xscale;
|
993
|
+
const tystep = ystep * yscale;
|
994
|
+
const tiling = this.svgFactory.createElement("svg:pattern");
|
995
|
+
tiling.setAttributeNS(null, "id", tilingId);
|
996
|
+
tiling.setAttributeNS(null, "patternUnits", "userSpaceOnUse");
|
997
|
+
tiling.setAttributeNS(null, "width", txstep);
|
998
|
+
tiling.setAttributeNS(null, "height", tystep);
|
999
|
+
tiling.setAttributeNS(null, "x", `${tx0}`);
|
1000
|
+
tiling.setAttributeNS(null, "y", `${ty0}`);
|
1001
|
+
const svg = this.svg;
|
1002
|
+
const transformMatrix = this.transformMatrix;
|
1003
|
+
const fillColor = this.current.fillColor;
|
1004
|
+
const strokeColor = this.current.strokeColor;
|
1005
|
+
const bbox = this.svgFactory.create(tx1 - tx0, ty1 - ty0);
|
1006
|
+
this.svg = bbox;
|
1007
|
+
this.transformMatrix = matrix;
|
1008
|
+
|
1009
|
+
if (paintType === 2) {
|
1010
|
+
const cssColor = _util.Util.makeCssRgb(...color);
|
1011
|
+
|
1012
|
+
this.current.fillColor = cssColor;
|
1013
|
+
this.current.strokeColor = cssColor;
|
1014
|
+
}
|
1015
|
+
|
1016
|
+
this.executeOpTree(this.convertOpList(operatorList));
|
1017
|
+
this.svg = svg;
|
1018
|
+
this.transformMatrix = transformMatrix;
|
1019
|
+
this.current.fillColor = fillColor;
|
1020
|
+
this.current.strokeColor = strokeColor;
|
1021
|
+
tiling.appendChild(bbox.childNodes[0]);
|
1022
|
+
this.defs.appendChild(tiling);
|
1023
|
+
return `url(#${tilingId})`;
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
_makeShadingPattern(args) {
|
1027
|
+
switch (args[0]) {
|
1028
|
+
case "RadialAxial":
|
1029
|
+
const shadingId = `shading${shadingCount++}`;
|
1030
|
+
const colorStops = args[3];
|
1031
|
+
let gradient;
|
1032
|
+
|
1033
|
+
switch (args[1]) {
|
1034
|
+
case "axial":
|
1035
|
+
const point0 = args[4];
|
1036
|
+
const point1 = args[5];
|
1037
|
+
gradient = this.svgFactory.createElement("svg:linearGradient");
|
1038
|
+
gradient.setAttributeNS(null, "id", shadingId);
|
1039
|
+
gradient.setAttributeNS(null, "gradientUnits", "userSpaceOnUse");
|
1040
|
+
gradient.setAttributeNS(null, "x1", point0[0]);
|
1041
|
+
gradient.setAttributeNS(null, "y1", point0[1]);
|
1042
|
+
gradient.setAttributeNS(null, "x2", point1[0]);
|
1043
|
+
gradient.setAttributeNS(null, "y2", point1[1]);
|
815
1044
|
break;
|
816
|
-
|
817
|
-
|
1045
|
+
|
1046
|
+
case "radial":
|
1047
|
+
const focalPoint = args[4];
|
1048
|
+
const circlePoint = args[5];
|
1049
|
+
const focalRadius = args[6];
|
1050
|
+
const circleRadius = args[7];
|
1051
|
+
gradient = this.svgFactory.createElement("svg:radialGradient");
|
1052
|
+
gradient.setAttributeNS(null, "id", shadingId);
|
1053
|
+
gradient.setAttributeNS(null, "gradientUnits", "userSpaceOnUse");
|
1054
|
+
gradient.setAttributeNS(null, "cx", circlePoint[0]);
|
1055
|
+
gradient.setAttributeNS(null, "cy", circlePoint[1]);
|
1056
|
+
gradient.setAttributeNS(null, "r", circleRadius);
|
1057
|
+
gradient.setAttributeNS(null, "fx", focalPoint[0]);
|
1058
|
+
gradient.setAttributeNS(null, "fy", focalPoint[1]);
|
1059
|
+
gradient.setAttributeNS(null, "fr", focalRadius);
|
818
1060
|
break;
|
1061
|
+
|
1062
|
+
default:
|
1063
|
+
throw new Error(`Unknown RadialAxial type: ${args[1]}`);
|
819
1064
|
}
|
1065
|
+
|
1066
|
+
for (const colorStop of colorStops) {
|
1067
|
+
const stop = this.svgFactory.createElement("svg:stop");
|
1068
|
+
stop.setAttributeNS(null, "offset", colorStop[0]);
|
1069
|
+
stop.setAttributeNS(null, "stop-color", colorStop[1]);
|
1070
|
+
gradient.appendChild(stop);
|
1071
|
+
}
|
1072
|
+
|
1073
|
+
this.defs.appendChild(gradient);
|
1074
|
+
return `url(#${shadingId})`;
|
1075
|
+
|
1076
|
+
case "Mesh":
|
1077
|
+
(0, _util.warn)("Unimplemented pattern Mesh");
|
1078
|
+
return null;
|
1079
|
+
|
1080
|
+
case "Dummy":
|
1081
|
+
return "hotpink";
|
1082
|
+
|
1083
|
+
default:
|
1084
|
+
throw new Error(`Unknown IR type: ${args[0]}`);
|
1085
|
+
}
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
setDash(dashArray, dashPhase) {
|
1089
|
+
this.current.dashArray = dashArray;
|
1090
|
+
this.current.dashPhase = dashPhase;
|
1091
|
+
}
|
1092
|
+
|
1093
|
+
constructPath(ops, args) {
|
1094
|
+
const current = this.current;
|
1095
|
+
let x = current.x,
|
1096
|
+
y = current.y;
|
1097
|
+
let d = [];
|
1098
|
+
let j = 0;
|
1099
|
+
|
1100
|
+
for (const op of ops) {
|
1101
|
+
switch (op | 0) {
|
1102
|
+
case _util.OPS.rectangle:
|
1103
|
+
x = args[j++];
|
1104
|
+
y = args[j++];
|
1105
|
+
const width = args[j++];
|
1106
|
+
const height = args[j++];
|
1107
|
+
const xw = x + width;
|
1108
|
+
const yh = y + height;
|
1109
|
+
d.push("M", pf(x), pf(y), "L", pf(xw), pf(y), "L", pf(xw), pf(yh), "L", pf(x), pf(yh), "Z");
|
1110
|
+
break;
|
1111
|
+
|
1112
|
+
case _util.OPS.moveTo:
|
1113
|
+
x = args[j++];
|
1114
|
+
y = args[j++];
|
1115
|
+
d.push("M", pf(x), pf(y));
|
1116
|
+
break;
|
1117
|
+
|
1118
|
+
case _util.OPS.lineTo:
|
1119
|
+
x = args[j++];
|
1120
|
+
y = args[j++];
|
1121
|
+
d.push("L", pf(x), pf(y));
|
1122
|
+
break;
|
1123
|
+
|
1124
|
+
case _util.OPS.curveTo:
|
1125
|
+
x = args[j + 4];
|
1126
|
+
y = args[j + 5];
|
1127
|
+
d.push("C", pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
|
1128
|
+
j += 6;
|
1129
|
+
break;
|
1130
|
+
|
1131
|
+
case _util.OPS.curveTo2:
|
1132
|
+
d.push("C", pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
|
1133
|
+
x = args[j + 2];
|
1134
|
+
y = args[j + 3];
|
1135
|
+
j += 4;
|
1136
|
+
break;
|
1137
|
+
|
1138
|
+
case _util.OPS.curveTo3:
|
1139
|
+
x = args[j + 2];
|
1140
|
+
y = args[j + 3];
|
1141
|
+
d.push("C", pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
|
1142
|
+
j += 4;
|
1143
|
+
break;
|
1144
|
+
|
1145
|
+
case _util.OPS.closePath:
|
1146
|
+
d.push("Z");
|
1147
|
+
break;
|
820
1148
|
}
|
821
|
-
|
822
|
-
|
1149
|
+
}
|
1150
|
+
|
1151
|
+
d = d.join(" ");
|
1152
|
+
|
1153
|
+
if (current.path && ops.length > 0 && ops[0] !== _util.OPS.rectangle && ops[0] !== _util.OPS.moveTo) {
|
1154
|
+
d = current.path.getAttributeNS(null, "d") + d;
|
1155
|
+
} else {
|
1156
|
+
current.path = this.svgFactory.createElement("svg:path");
|
1157
|
+
|
823
1158
|
this._ensureTransformGroup().appendChild(current.path);
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
|
842
|
-
}
|
1159
|
+
}
|
1160
|
+
|
1161
|
+
current.path.setAttributeNS(null, "d", d);
|
1162
|
+
current.path.setAttributeNS(null, "fill", "none");
|
1163
|
+
current.element = current.path;
|
1164
|
+
current.setCurrentPoint(x, y);
|
1165
|
+
}
|
1166
|
+
|
1167
|
+
endPath() {
|
1168
|
+
const current = this.current;
|
1169
|
+
current.path = null;
|
1170
|
+
|
1171
|
+
if (!this.pendingClip) {
|
1172
|
+
return;
|
1173
|
+
}
|
1174
|
+
|
1175
|
+
if (!current.element) {
|
843
1176
|
this.pendingClip = null;
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
}
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
}
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
eoFillStroke: function SVGGraphics_eoFillStroke() {
|
955
|
-
if (this.current.element) {
|
956
|
-
this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
|
1177
|
+
return;
|
1178
|
+
}
|
1179
|
+
|
1180
|
+
const clipId = `clippath${clipCount++}`;
|
1181
|
+
const clipPath = this.svgFactory.createElement("svg:clipPath");
|
1182
|
+
clipPath.setAttributeNS(null, "id", clipId);
|
1183
|
+
clipPath.setAttributeNS(null, "transform", pm(this.transformMatrix));
|
1184
|
+
const clipElement = current.element.cloneNode(true);
|
1185
|
+
|
1186
|
+
if (this.pendingClip === "evenodd") {
|
1187
|
+
clipElement.setAttributeNS(null, "clip-rule", "evenodd");
|
1188
|
+
} else {
|
1189
|
+
clipElement.setAttributeNS(null, "clip-rule", "nonzero");
|
1190
|
+
}
|
1191
|
+
|
1192
|
+
this.pendingClip = null;
|
1193
|
+
clipPath.appendChild(clipElement);
|
1194
|
+
this.defs.appendChild(clipPath);
|
1195
|
+
|
1196
|
+
if (current.activeClipUrl) {
|
1197
|
+
current.clipGroup = null;
|
1198
|
+
this.extraStack.forEach(function (prev) {
|
1199
|
+
prev.clipGroup = null;
|
1200
|
+
});
|
1201
|
+
clipPath.setAttributeNS(null, "clip-path", current.activeClipUrl);
|
1202
|
+
}
|
1203
|
+
|
1204
|
+
current.activeClipUrl = `url(#${clipId})`;
|
1205
|
+
this.tgrp = null;
|
1206
|
+
}
|
1207
|
+
|
1208
|
+
clip(type) {
|
1209
|
+
this.pendingClip = type;
|
1210
|
+
}
|
1211
|
+
|
1212
|
+
closePath() {
|
1213
|
+
const current = this.current;
|
1214
|
+
|
1215
|
+
if (current.path) {
|
1216
|
+
const d = `${current.path.getAttributeNS(null, "d")}Z`;
|
1217
|
+
current.path.setAttributeNS(null, "d", d);
|
1218
|
+
}
|
1219
|
+
}
|
1220
|
+
|
1221
|
+
setLeading(leading) {
|
1222
|
+
this.current.leading = -leading;
|
1223
|
+
}
|
1224
|
+
|
1225
|
+
setTextRise(textRise) {
|
1226
|
+
this.current.textRise = textRise;
|
1227
|
+
}
|
1228
|
+
|
1229
|
+
setTextRenderingMode(textRenderingMode) {
|
1230
|
+
this.current.textRenderingMode = textRenderingMode;
|
1231
|
+
}
|
1232
|
+
|
1233
|
+
setHScale(scale) {
|
1234
|
+
this.current.textHScale = scale / 100;
|
1235
|
+
}
|
1236
|
+
|
1237
|
+
setRenderingIntent(intent) {}
|
1238
|
+
|
1239
|
+
setFlatness(flatness) {}
|
1240
|
+
|
1241
|
+
setGState(states) {
|
1242
|
+
for (const [key, value] of states) {
|
1243
|
+
switch (key) {
|
1244
|
+
case "LW":
|
1245
|
+
this.setLineWidth(value);
|
1246
|
+
break;
|
1247
|
+
|
1248
|
+
case "LC":
|
1249
|
+
this.setLineCap(value);
|
1250
|
+
break;
|
1251
|
+
|
1252
|
+
case "LJ":
|
1253
|
+
this.setLineJoin(value);
|
1254
|
+
break;
|
1255
|
+
|
1256
|
+
case "ML":
|
1257
|
+
this.setMiterLimit(value);
|
1258
|
+
break;
|
1259
|
+
|
1260
|
+
case "D":
|
1261
|
+
this.setDash(value[0], value[1]);
|
1262
|
+
break;
|
1263
|
+
|
1264
|
+
case "RI":
|
1265
|
+
this.setRenderingIntent(value);
|
1266
|
+
break;
|
1267
|
+
|
1268
|
+
case "FL":
|
1269
|
+
this.setFlatness(value);
|
1270
|
+
break;
|
1271
|
+
|
1272
|
+
case "Font":
|
1273
|
+
this.setFont(value);
|
1274
|
+
break;
|
1275
|
+
|
1276
|
+
case "CA":
|
1277
|
+
this.setStrokeAlpha(value);
|
1278
|
+
break;
|
1279
|
+
|
1280
|
+
case "ca":
|
1281
|
+
this.setFillAlpha(value);
|
1282
|
+
break;
|
1283
|
+
|
1284
|
+
default:
|
1285
|
+
(0, _util.warn)(`Unimplemented graphic state operator ${key}`);
|
1286
|
+
break;
|
957
1287
|
}
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
1288
|
+
}
|
1289
|
+
}
|
1290
|
+
|
1291
|
+
fill() {
|
1292
|
+
const current = this.current;
|
1293
|
+
|
1294
|
+
if (current.element) {
|
1295
|
+
current.element.setAttributeNS(null, "fill", current.fillColor);
|
1296
|
+
current.element.setAttributeNS(null, "fill-opacity", current.fillAlpha);
|
1297
|
+
this.endPath();
|
1298
|
+
}
|
1299
|
+
}
|
1300
|
+
|
1301
|
+
stroke() {
|
1302
|
+
const current = this.current;
|
1303
|
+
|
1304
|
+
if (current.element) {
|
1305
|
+
this._setStrokeAttributes(current.element);
|
1306
|
+
|
1307
|
+
current.element.setAttributeNS(null, "fill", "none");
|
1308
|
+
this.endPath();
|
1309
|
+
}
|
1310
|
+
}
|
1311
|
+
|
1312
|
+
_setStrokeAttributes(element, lineWidthScale = 1) {
|
1313
|
+
const current = this.current;
|
1314
|
+
let dashArray = current.dashArray;
|
1315
|
+
|
1316
|
+
if (lineWidthScale !== 1 && dashArray.length > 0) {
|
1317
|
+
dashArray = dashArray.map(function (value) {
|
1318
|
+
return lineWidthScale * value;
|
1319
|
+
});
|
1320
|
+
}
|
1321
|
+
|
1322
|
+
element.setAttributeNS(null, "stroke", current.strokeColor);
|
1323
|
+
element.setAttributeNS(null, "stroke-opacity", current.strokeAlpha);
|
1324
|
+
element.setAttributeNS(null, "stroke-miterlimit", pf(current.miterLimit));
|
1325
|
+
element.setAttributeNS(null, "stroke-linecap", current.lineCap);
|
1326
|
+
element.setAttributeNS(null, "stroke-linejoin", current.lineJoin);
|
1327
|
+
element.setAttributeNS(null, "stroke-width", pf(lineWidthScale * current.lineWidth) + "px");
|
1328
|
+
element.setAttributeNS(null, "stroke-dasharray", dashArray.map(pf).join(" "));
|
1329
|
+
element.setAttributeNS(null, "stroke-dashoffset", pf(lineWidthScale * current.dashPhase) + "px");
|
1330
|
+
}
|
1331
|
+
|
1332
|
+
eoFill() {
|
1333
|
+
if (this.current.element) {
|
1334
|
+
this.current.element.setAttributeNS(null, "fill-rule", "evenodd");
|
1335
|
+
}
|
1336
|
+
|
1337
|
+
this.fill();
|
1338
|
+
}
|
1339
|
+
|
1340
|
+
fillStroke() {
|
1341
|
+
this.stroke();
|
1342
|
+
this.fill();
|
1343
|
+
}
|
1344
|
+
|
1345
|
+
eoFillStroke() {
|
1346
|
+
if (this.current.element) {
|
1347
|
+
this.current.element.setAttributeNS(null, "fill-rule", "evenodd");
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
this.fillStroke();
|
1351
|
+
}
|
1352
|
+
|
1353
|
+
closeStroke() {
|
1354
|
+
this.closePath();
|
1355
|
+
this.stroke();
|
1356
|
+
}
|
1357
|
+
|
1358
|
+
closeFillStroke() {
|
1359
|
+
this.closePath();
|
1360
|
+
this.fillStroke();
|
1361
|
+
}
|
1362
|
+
|
1363
|
+
closeEOFillStroke() {
|
1364
|
+
this.closePath();
|
1365
|
+
this.eoFillStroke();
|
1366
|
+
}
|
1367
|
+
|
1368
|
+
paintSolidColorImageMask() {
|
1369
|
+
const rect = this.svgFactory.createElement("svg:rect");
|
1370
|
+
rect.setAttributeNS(null, "x", "0");
|
1371
|
+
rect.setAttributeNS(null, "y", "0");
|
1372
|
+
rect.setAttributeNS(null, "width", "1px");
|
1373
|
+
rect.setAttributeNS(null, "height", "1px");
|
1374
|
+
rect.setAttributeNS(null, "fill", this.current.fillColor);
|
1375
|
+
|
1376
|
+
this._ensureTransformGroup().appendChild(rect);
|
1377
|
+
}
|
1378
|
+
|
1379
|
+
paintJpegXObject(objId, w, h) {
|
1380
|
+
const imgObj = this.objs.get(objId);
|
1381
|
+
const imgEl = this.svgFactory.createElement("svg:image");
|
1382
|
+
imgEl.setAttributeNS(XLINK_NS, "xlink:href", imgObj.src);
|
1383
|
+
imgEl.setAttributeNS(null, "width", pf(w));
|
1384
|
+
imgEl.setAttributeNS(null, "height", pf(h));
|
1385
|
+
imgEl.setAttributeNS(null, "x", "0");
|
1386
|
+
imgEl.setAttributeNS(null, "y", pf(-h));
|
1387
|
+
imgEl.setAttributeNS(null, "transform", `scale(${pf(1 / w)} ${pf(-1 / h)})`);
|
1388
|
+
|
1389
|
+
this._ensureTransformGroup().appendChild(imgEl);
|
1390
|
+
}
|
1391
|
+
|
1392
|
+
paintImageXObject(objId) {
|
1393
|
+
const imgData = this.objs.get(objId);
|
1394
|
+
|
1395
|
+
if (!imgData) {
|
1396
|
+
(0, _util.warn)(`Dependent image with object ID ${objId} is not ready yet`);
|
1397
|
+
return;
|
1398
|
+
}
|
1399
|
+
|
1400
|
+
this.paintInlineImageXObject(imgData);
|
1401
|
+
}
|
1402
|
+
|
1403
|
+
paintInlineImageXObject(imgData, mask) {
|
1404
|
+
const width = imgData.width;
|
1405
|
+
const height = imgData.height;
|
1406
|
+
const imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask);
|
1407
|
+
const cliprect = this.svgFactory.createElement("svg:rect");
|
1408
|
+
cliprect.setAttributeNS(null, "x", "0");
|
1409
|
+
cliprect.setAttributeNS(null, "y", "0");
|
1410
|
+
cliprect.setAttributeNS(null, "width", pf(width));
|
1411
|
+
cliprect.setAttributeNS(null, "height", pf(height));
|
1412
|
+
this.current.element = cliprect;
|
1413
|
+
this.clip("nonzero");
|
1414
|
+
const imgEl = this.svgFactory.createElement("svg:image");
|
1415
|
+
imgEl.setAttributeNS(XLINK_NS, "xlink:href", imgSrc);
|
1416
|
+
imgEl.setAttributeNS(null, "x", "0");
|
1417
|
+
imgEl.setAttributeNS(null, "y", pf(-height));
|
1418
|
+
imgEl.setAttributeNS(null, "width", pf(width) + "px");
|
1419
|
+
imgEl.setAttributeNS(null, "height", pf(height) + "px");
|
1420
|
+
imgEl.setAttributeNS(null, "transform", `scale(${pf(1 / width)} ${pf(-1 / height)})`);
|
1421
|
+
|
1422
|
+
if (mask) {
|
1423
|
+
mask.appendChild(imgEl);
|
1424
|
+
} else {
|
992
1425
|
this._ensureTransformGroup().appendChild(imgEl);
|
993
|
-
}
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
}
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1426
|
+
}
|
1427
|
+
}
|
1428
|
+
|
1429
|
+
paintImageMaskXObject(imgData) {
|
1430
|
+
const current = this.current;
|
1431
|
+
const width = imgData.width;
|
1432
|
+
const height = imgData.height;
|
1433
|
+
const fillColor = current.fillColor;
|
1434
|
+
current.maskId = `mask${maskCount++}`;
|
1435
|
+
const mask = this.svgFactory.createElement("svg:mask");
|
1436
|
+
mask.setAttributeNS(null, "id", current.maskId);
|
1437
|
+
const rect = this.svgFactory.createElement("svg:rect");
|
1438
|
+
rect.setAttributeNS(null, "x", "0");
|
1439
|
+
rect.setAttributeNS(null, "y", "0");
|
1440
|
+
rect.setAttributeNS(null, "width", pf(width));
|
1441
|
+
rect.setAttributeNS(null, "height", pf(height));
|
1442
|
+
rect.setAttributeNS(null, "fill", fillColor);
|
1443
|
+
rect.setAttributeNS(null, "mask", `url(#${current.maskId})`);
|
1444
|
+
this.defs.appendChild(mask);
|
1445
|
+
|
1446
|
+
this._ensureTransformGroup().appendChild(rect);
|
1447
|
+
|
1448
|
+
this.paintInlineImageXObject(imgData, mask);
|
1449
|
+
}
|
1450
|
+
|
1451
|
+
paintFormXObjectBegin(matrix, bbox) {
|
1452
|
+
if (Array.isArray(matrix) && matrix.length === 6) {
|
1453
|
+
this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
1454
|
+
}
|
1455
|
+
|
1456
|
+
if (bbox) {
|
1457
|
+
const width = bbox[2] - bbox[0];
|
1458
|
+
const height = bbox[3] - bbox[1];
|
1459
|
+
const cliprect = this.svgFactory.createElement("svg:rect");
|
1460
|
+
cliprect.setAttributeNS(null, "x", bbox[0]);
|
1461
|
+
cliprect.setAttributeNS(null, "y", bbox[1]);
|
1462
|
+
cliprect.setAttributeNS(null, "width", pf(width));
|
1463
|
+
cliprect.setAttributeNS(null, "height", pf(height));
|
1011
1464
|
this.current.element = cliprect;
|
1012
|
-
this.clip(
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1465
|
+
this.clip("nonzero");
|
1466
|
+
this.endPath();
|
1467
|
+
}
|
1468
|
+
}
|
1469
|
+
|
1470
|
+
paintFormXObjectEnd() {}
|
1471
|
+
|
1472
|
+
_initialize(viewport) {
|
1473
|
+
const svg = this.svgFactory.create(viewport.width, viewport.height);
|
1474
|
+
const definitions = this.svgFactory.createElement("svg:defs");
|
1475
|
+
svg.appendChild(definitions);
|
1476
|
+
this.defs = definitions;
|
1477
|
+
const rootGroup = this.svgFactory.createElement("svg:g");
|
1478
|
+
rootGroup.setAttributeNS(null, "transform", pm(viewport.transform));
|
1479
|
+
svg.appendChild(rootGroup);
|
1480
|
+
this.svg = rootGroup;
|
1481
|
+
return svg;
|
1482
|
+
}
|
1483
|
+
|
1484
|
+
_ensureClipGroup() {
|
1485
|
+
if (!this.current.clipGroup) {
|
1486
|
+
const clipGroup = this.svgFactory.createElement("svg:g");
|
1487
|
+
clipGroup.setAttributeNS(null, "clip-path", this.current.activeClipUrl);
|
1488
|
+
this.svg.appendChild(clipGroup);
|
1489
|
+
this.current.clipGroup = clipGroup;
|
1490
|
+
}
|
1491
|
+
|
1492
|
+
return this.current.clipGroup;
|
1493
|
+
}
|
1494
|
+
|
1495
|
+
_ensureTransformGroup() {
|
1496
|
+
if (!this.tgrp) {
|
1497
|
+
this.tgrp = this.svgFactory.createElement("svg:g");
|
1498
|
+
this.tgrp.setAttributeNS(null, "transform", pm(this.transformMatrix));
|
1499
|
+
|
1500
|
+
if (this.current.activeClipUrl) {
|
1501
|
+
this._ensureClipGroup().appendChild(this.tgrp);
|
1022
1502
|
} else {
|
1023
|
-
this.
|
1024
|
-
}
|
1025
|
-
},
|
1026
|
-
paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
|
1027
|
-
var current = this.current;
|
1028
|
-
var width = imgData.width;
|
1029
|
-
var height = imgData.height;
|
1030
|
-
var fillColor = current.fillColor;
|
1031
|
-
current.maskId = 'mask' + maskCount++;
|
1032
|
-
var mask = this.svgFactory.createElement('svg:mask');
|
1033
|
-
mask.setAttributeNS(null, 'id', current.maskId);
|
1034
|
-
var rect = this.svgFactory.createElement('svg:rect');
|
1035
|
-
rect.setAttributeNS(null, 'x', '0');
|
1036
|
-
rect.setAttributeNS(null, 'y', '0');
|
1037
|
-
rect.setAttributeNS(null, 'width', pf(width));
|
1038
|
-
rect.setAttributeNS(null, 'height', pf(height));
|
1039
|
-
rect.setAttributeNS(null, 'fill', fillColor);
|
1040
|
-
rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
|
1041
|
-
this.defs.appendChild(mask);
|
1042
|
-
this._ensureTransformGroup().appendChild(rect);
|
1043
|
-
this.paintInlineImageXObject(imgData, mask);
|
1044
|
-
},
|
1045
|
-
paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
|
1046
|
-
if (Array.isArray(matrix) && matrix.length === 6) {
|
1047
|
-
this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
1048
|
-
}
|
1049
|
-
if (Array.isArray(bbox) && bbox.length === 4) {
|
1050
|
-
var width = bbox[2] - bbox[0];
|
1051
|
-
var height = bbox[3] - bbox[1];
|
1052
|
-
var cliprect = this.svgFactory.createElement('svg:rect');
|
1053
|
-
cliprect.setAttributeNS(null, 'x', bbox[0]);
|
1054
|
-
cliprect.setAttributeNS(null, 'y', bbox[1]);
|
1055
|
-
cliprect.setAttributeNS(null, 'width', pf(width));
|
1056
|
-
cliprect.setAttributeNS(null, 'height', pf(height));
|
1057
|
-
this.current.element = cliprect;
|
1058
|
-
this.clip('nonzero');
|
1059
|
-
this.endPath();
|
1060
|
-
}
|
1061
|
-
},
|
1062
|
-
paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {},
|
1063
|
-
_initialize: function _initialize(viewport) {
|
1064
|
-
var svg = this.svgFactory.create(viewport.width, viewport.height);
|
1065
|
-
var definitions = this.svgFactory.createElement('svg:defs');
|
1066
|
-
svg.appendChild(definitions);
|
1067
|
-
this.defs = definitions;
|
1068
|
-
var rootGroup = this.svgFactory.createElement('svg:g');
|
1069
|
-
rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
|
1070
|
-
svg.appendChild(rootGroup);
|
1071
|
-
this.svg = rootGroup;
|
1072
|
-
return svg;
|
1073
|
-
},
|
1074
|
-
|
1075
|
-
_ensureClipGroup: function SVGGraphics_ensureClipGroup() {
|
1076
|
-
if (!this.current.clipGroup) {
|
1077
|
-
var clipGroup = this.svgFactory.createElement('svg:g');
|
1078
|
-
clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
|
1079
|
-
this.svg.appendChild(clipGroup);
|
1080
|
-
this.current.clipGroup = clipGroup;
|
1503
|
+
this.svg.appendChild(this.tgrp);
|
1081
1504
|
}
|
1082
|
-
return this.current.clipGroup;
|
1083
|
-
},
|
1084
|
-
_ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
|
1085
|
-
if (!this.tgrp) {
|
1086
|
-
this.tgrp = this.svgFactory.createElement('svg:g');
|
1087
|
-
this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
|
1088
|
-
if (this.current.activeClipUrl) {
|
1089
|
-
this._ensureClipGroup().appendChild(this.tgrp);
|
1090
|
-
} else {
|
1091
|
-
this.svg.appendChild(this.tgrp);
|
1092
|
-
}
|
1093
|
-
}
|
1094
|
-
return this.tgrp;
|
1095
1505
|
}
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1506
|
+
|
1507
|
+
return this.tgrp;
|
1508
|
+
}
|
1509
|
+
|
1510
|
+
};
|
1511
|
+
}
|