pdfjs-dist 2.3.200 → 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/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +6499 -17971
- 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 +19303 -29896
- 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 +1333 -4839
- 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 +683 -1066
- package/lib/core/arithmetic_decoder.js +81 -97
- package/lib/core/bidi.js +54 -46
- package/lib/core/ccitt.js +88 -81
- package/lib/core/ccitt_stream.js +15 -14
- package/lib/core/cff_parser.js +196 -193
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +441 -569
- package/lib/core/cmap.js +220 -279
- package/lib/core/colorspace.js +699 -863
- package/lib/core/core_utils.js +59 -80
- package/lib/core/crypto.js +379 -437
- package/lib/core/document.js +564 -673
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +983 -889
- package/lib/core/font_renderer.js +128 -171
- package/lib/core/fonts.js +451 -400
- package/lib/core/function.js +289 -285
- package/lib/core/glyphlist.js +4527 -4527
- package/lib/core/image.js +138 -117
- package/lib/core/image_utils.js +46 -63
- package/lib/core/jbig2.js +324 -332
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +133 -24
- package/lib/core/jpg.js +238 -210
- package/lib/core/jpx.js +158 -157
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2928 -2928
- package/lib/core/murmurhash3.js +87 -102
- package/lib/core/obj.js +1111 -1302
- package/lib/core/operator_list.js +55 -42
- package/lib/core/parser.js +956 -987
- package/lib/core/pattern.js +69 -69
- package/lib/core/pdf_manager.js +149 -316
- package/lib/core/primitives.js +45 -77
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +83 -77
- package/lib/core/type1_parser.js +78 -68
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +148 -196
- package/lib/core/worker_stream.js +101 -210
- package/lib/display/annotation_layer.js +733 -1155
- package/lib/display/api.js +1539 -1928
- package/lib/display/api_compatibility.js +10 -8
- package/lib/display/canvas.js +159 -158
- package/lib/display/content_disposition.js +36 -55
- package/lib/display/display_utils.js +298 -551
- package/lib/display/fetch_stream.js +181 -305
- package/lib/display/font_loader.js +273 -416
- package/lib/display/metadata.js +86 -98
- package/lib/display/network.js +376 -511
- package/lib/display/network_utils.js +20 -19
- package/lib/display/node_stream.js +276 -460
- package/lib/display/pattern_helper.js +76 -44
- package/lib/display/svg.js +1137 -1405
- package/lib/display/text_layer.js +75 -82
- package/lib/display/transport_stream.js +236 -374
- package/lib/display/webgl.js +70 -83
- package/lib/display/worker_options.js +3 -3
- package/lib/display/xml_parser.js +303 -392
- package/lib/examples/node/domstubs.js +37 -37
- package/lib/pdf.js +22 -21
- package/lib/pdf.worker.js +5 -5
- package/lib/shared/compatibility.js +2 -251
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +222 -194
- package/lib/shared/util.js +269 -405
- package/lib/test/unit/annotation_spec.js +1089 -1014
- package/lib/test/unit/api_spec.js +617 -544
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +63 -62
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +84 -86
- package/lib/test/unit/colorspace_spec.js +154 -154
- package/lib/test/unit/core_utils_spec.js +125 -105
- package/lib/test/unit/crypto_spec.js +181 -181
- package/lib/test/unit/custom_spec.js +22 -24
- package/lib/test/unit/display_svg_spec.js +35 -36
- package/lib/test/unit/display_utils_spec.js +139 -149
- package/lib/test/unit/document_spec.js +16 -16
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +81 -95
- package/lib/test/unit/fetch_stream_spec.js +30 -30
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +48 -32
- package/lib/test/unit/message_handler_spec.js +172 -162
- package/lib/test/unit/metadata_spec.js +69 -69
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +12 -12
- package/lib/test/unit/network_utils_spec.js +152 -152
- package/lib/test/unit/node_stream_spec.js +74 -90
- package/lib/test/unit/parser_spec.js +107 -113
- package/lib/test/unit/pdf_find_controller_spec.js +55 -86
- package/lib/test/unit/pdf_find_utils_spec.js +32 -32
- package/lib/test/unit/pdf_history_spec.js +32 -32
- package/lib/test/unit/primitives_spec.js +117 -115
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +119 -285
- package/lib/test/unit/testreporter.js +19 -19
- package/lib/test/unit/type1_parser_spec.js +41 -41
- package/lib/test/unit/ui_utils_spec.js +318 -426
- package/lib/test/unit/unicode_spec.js +42 -42
- package/lib/test/unit/util_spec.js +122 -143
- package/lib/web/annotation_layer_builder.js +66 -103
- package/lib/web/app.js +1166 -1196
- package/lib/web/app_options.js +61 -77
- package/lib/web/base_viewer.js +804 -850
- package/lib/web/chromecom.js +164 -249
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +38 -57
- package/lib/web/firefox_print_service.js +35 -30
- package/lib/web/firefoxcom.js +175 -374
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +30 -30
- package/lib/web/interfaces.js +80 -258
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +105 -130
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +227 -376
- package/lib/web/pdf_find_bar.js +137 -171
- package/lib/web/pdf_find_controller.js +492 -549
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +395 -406
- package/lib/web/pdf_link_service.js +302 -349
- package/lib/web/pdf_outline_viewer.js +148 -209
- package/lib/web/pdf_page_view.js +449 -507
- package/lib/web/pdf_presentation_mode.js +304 -357
- package/lib/web/pdf_print_service.js +90 -104
- package/lib/web/pdf_rendering_queue.js +87 -108
- package/lib/web/pdf_sidebar.js +264 -304
- package/lib/web/pdf_sidebar_resizer.js +92 -119
- package/lib/web/pdf_single_page_viewer.js +77 -126
- package/lib/web/pdf_thumbnail_view.js +276 -297
- package/lib/web/pdf_thumbnail_viewer.js +186 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +66 -273
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +284 -317
- package/lib/web/toolbar.js +216 -211
- package/lib/web/ui_utils.js +303 -404
- package/lib/web/view_history.js +49 -222
- package/lib/web/viewer_compatibility.js +7 -5
- package/package.json +2 -9
- package/web/pdf_viewer.css +25 -18
- package/web/pdf_viewer.js +3481 -4764
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/lib/shared/streams_polyfill.js +0 -43
package/lib/core/evaluator.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.
|
@@ -26,58 +26,50 @@ Object.defineProperty(exports, "__esModule", {
|
|
26
26
|
});
|
27
27
|
exports.PartialEvaluator = void 0;
|
28
28
|
|
29
|
-
var
|
29
|
+
var _util = require("../shared/util.js");
|
30
30
|
|
31
|
-
var
|
31
|
+
var _cmap = require("./cmap.js");
|
32
32
|
|
33
|
-
var
|
33
|
+
var _primitives = require("./primitives.js");
|
34
34
|
|
35
|
-
var
|
35
|
+
var _fonts = require("./fonts.js");
|
36
36
|
|
37
|
-
var
|
37
|
+
var _encodings = require("./encodings.js");
|
38
38
|
|
39
|
-
var
|
39
|
+
var _core_utils = require("./core_utils.js");
|
40
40
|
|
41
|
-
var _unicode = require("./unicode");
|
41
|
+
var _unicode = require("./unicode.js");
|
42
42
|
|
43
|
-
var _standard_fonts = require("./standard_fonts");
|
43
|
+
var _standard_fonts = require("./standard_fonts.js");
|
44
44
|
|
45
|
-
var _pattern = require("./pattern");
|
45
|
+
var _pattern = require("./pattern.js");
|
46
46
|
|
47
|
-
var _parser = require("./parser");
|
47
|
+
var _parser = require("./parser.js");
|
48
48
|
|
49
|
-
var _bidi = require("./bidi");
|
49
|
+
var _bidi = require("./bidi.js");
|
50
50
|
|
51
|
-
var _colorspace = require("./colorspace");
|
51
|
+
var _colorspace = require("./colorspace.js");
|
52
52
|
|
53
|
-
var _stream = require("./stream");
|
53
|
+
var _stream = require("./stream.js");
|
54
54
|
|
55
|
-
var _glyphlist = require("./glyphlist");
|
55
|
+
var _glyphlist = require("./glyphlist.js");
|
56
56
|
|
57
|
-
var
|
57
|
+
var _metrics = require("./metrics.js");
|
58
58
|
|
59
|
-
var
|
59
|
+
var _function = require("./function.js");
|
60
60
|
|
61
|
-
var
|
61
|
+
var _jpeg_stream = require("./jpeg_stream.js");
|
62
62
|
|
63
|
-
var
|
63
|
+
var _murmurhash = require("./murmurhash3.js");
|
64
64
|
|
65
|
-
var
|
65
|
+
var _image_utils = require("./image_utils.js");
|
66
66
|
|
67
|
-
var
|
67
|
+
var _operator_list = require("./operator_list.js");
|
68
68
|
|
69
|
-
var
|
70
|
-
|
71
|
-
var _image = require("./image");
|
72
|
-
|
73
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
74
|
-
|
75
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
76
|
-
|
77
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
69
|
+
var _image = require("./image.js");
|
78
70
|
|
79
71
|
var PartialEvaluator = function PartialEvaluatorClosure() {
|
80
|
-
|
72
|
+
const DefaultPartialEvaluatorOptions = {
|
81
73
|
forceDataSchema: false,
|
82
74
|
maxImageSize: -1,
|
83
75
|
disableFontFace: false,
|
@@ -86,18 +78,16 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
86
78
|
isEvalSupported: true
|
87
79
|
};
|
88
80
|
|
89
|
-
function PartialEvaluator(
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
options = _ref$options === void 0 ? null : _ref$options,
|
100
|
-
pdfFunctionFactory = _ref.pdfFunctionFactory;
|
81
|
+
function PartialEvaluator({
|
82
|
+
xref,
|
83
|
+
handler,
|
84
|
+
pageIndex,
|
85
|
+
idFactory,
|
86
|
+
fontCache,
|
87
|
+
builtInCMapCache,
|
88
|
+
options = null,
|
89
|
+
pdfFunctionFactory
|
90
|
+
}) {
|
101
91
|
this.xref = xref;
|
102
92
|
this.handler = handler;
|
103
93
|
this.pageIndex = pageIndex;
|
@@ -108,69 +98,39 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
108
98
|
this.pdfFunctionFactory = pdfFunctionFactory;
|
109
99
|
this.parsingType3Font = false;
|
110
100
|
|
111
|
-
this.fetchBuiltInCMap =
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
/*#__PURE__*/
|
116
|
-
_regenerator["default"].mark(function _callee(name) {
|
117
|
-
var readableStream, reader, data;
|
118
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
119
|
-
while (1) {
|
120
|
-
switch (_context.prev = _context.next) {
|
121
|
-
case 0:
|
122
|
-
if (!_this.builtInCMapCache.has(name)) {
|
123
|
-
_context.next = 2;
|
124
|
-
break;
|
125
|
-
}
|
126
|
-
|
127
|
-
return _context.abrupt("return", _this.builtInCMapCache.get(name));
|
128
|
-
|
129
|
-
case 2:
|
130
|
-
readableStream = _this.handler.sendWithStream('FetchBuiltInCMap', {
|
131
|
-
name: name
|
132
|
-
});
|
133
|
-
reader = readableStream.getReader();
|
134
|
-
_context.next = 6;
|
135
|
-
return new Promise(function (resolve, reject) {
|
136
|
-
function pump() {
|
137
|
-
reader.read().then(function (_ref3) {
|
138
|
-
var value = _ref3.value,
|
139
|
-
done = _ref3.done;
|
140
|
-
|
141
|
-
if (done) {
|
142
|
-
return;
|
143
|
-
}
|
144
|
-
|
145
|
-
resolve(value);
|
146
|
-
pump();
|
147
|
-
}, reject);
|
148
|
-
}
|
149
|
-
|
150
|
-
pump();
|
151
|
-
});
|
101
|
+
this.fetchBuiltInCMap = async name => {
|
102
|
+
if (this.builtInCMapCache.has(name)) {
|
103
|
+
return this.builtInCMapCache.get(name);
|
104
|
+
}
|
152
105
|
|
153
|
-
|
154
|
-
|
106
|
+
const readableStream = this.handler.sendWithStream("FetchBuiltInCMap", {
|
107
|
+
name
|
108
|
+
});
|
109
|
+
const reader = readableStream.getReader();
|
110
|
+
const data = await new Promise(function (resolve, reject) {
|
111
|
+
function pump() {
|
112
|
+
reader.read().then(function ({
|
113
|
+
value,
|
114
|
+
done
|
115
|
+
}) {
|
116
|
+
if (done) {
|
117
|
+
return;
|
118
|
+
}
|
155
119
|
|
156
|
-
|
157
|
-
|
158
|
-
|
120
|
+
resolve(value);
|
121
|
+
pump();
|
122
|
+
}, reject);
|
123
|
+
}
|
159
124
|
|
160
|
-
|
125
|
+
pump();
|
126
|
+
});
|
161
127
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
}
|
166
|
-
}
|
167
|
-
}, _callee);
|
168
|
-
}));
|
128
|
+
if (data.compressionType !== _util.CMapCompressionType.NONE) {
|
129
|
+
this.builtInCMapCache.set(name, data);
|
130
|
+
}
|
169
131
|
|
170
|
-
return
|
171
|
-
|
172
|
-
};
|
173
|
-
}();
|
132
|
+
return data;
|
133
|
+
};
|
174
134
|
}
|
175
135
|
|
176
136
|
var TIME_SLOT_DURATION_MS = 20;
|
@@ -195,78 +155,99 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
195
155
|
}
|
196
156
|
};
|
197
157
|
|
198
|
-
function normalizeBlendMode(value) {
|
158
|
+
function normalizeBlendMode(value, parsingArray = false) {
|
159
|
+
if (Array.isArray(value)) {
|
160
|
+
for (let i = 0, ii = value.length; i < ii; i++) {
|
161
|
+
const maybeBM = normalizeBlendMode(value[i], true);
|
162
|
+
|
163
|
+
if (maybeBM) {
|
164
|
+
return maybeBM;
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
(0, _util.warn)(`Unsupported blend mode Array: ${value}`);
|
169
|
+
return "source-over";
|
170
|
+
}
|
171
|
+
|
199
172
|
if (!(0, _primitives.isName)(value)) {
|
200
|
-
|
173
|
+
if (parsingArray) {
|
174
|
+
return null;
|
175
|
+
}
|
176
|
+
|
177
|
+
return "source-over";
|
201
178
|
}
|
202
179
|
|
203
180
|
switch (value.name) {
|
204
|
-
case
|
205
|
-
case
|
206
|
-
return
|
181
|
+
case "Normal":
|
182
|
+
case "Compatible":
|
183
|
+
return "source-over";
|
207
184
|
|
208
|
-
case
|
209
|
-
return
|
185
|
+
case "Multiply":
|
186
|
+
return "multiply";
|
210
187
|
|
211
|
-
case
|
212
|
-
return
|
188
|
+
case "Screen":
|
189
|
+
return "screen";
|
213
190
|
|
214
|
-
case
|
215
|
-
return
|
191
|
+
case "Overlay":
|
192
|
+
return "overlay";
|
216
193
|
|
217
|
-
case
|
218
|
-
return
|
194
|
+
case "Darken":
|
195
|
+
return "darken";
|
219
196
|
|
220
|
-
case
|
221
|
-
return
|
197
|
+
case "Lighten":
|
198
|
+
return "lighten";
|
222
199
|
|
223
|
-
case
|
224
|
-
return
|
200
|
+
case "ColorDodge":
|
201
|
+
return "color-dodge";
|
225
202
|
|
226
|
-
case
|
227
|
-
return
|
203
|
+
case "ColorBurn":
|
204
|
+
return "color-burn";
|
228
205
|
|
229
|
-
case
|
230
|
-
return
|
206
|
+
case "HardLight":
|
207
|
+
return "hard-light";
|
231
208
|
|
232
|
-
case
|
233
|
-
return
|
209
|
+
case "SoftLight":
|
210
|
+
return "soft-light";
|
234
211
|
|
235
|
-
case
|
236
|
-
return
|
212
|
+
case "Difference":
|
213
|
+
return "difference";
|
237
214
|
|
238
|
-
case
|
239
|
-
return
|
215
|
+
case "Exclusion":
|
216
|
+
return "exclusion";
|
240
217
|
|
241
|
-
case
|
242
|
-
return
|
218
|
+
case "Hue":
|
219
|
+
return "hue";
|
243
220
|
|
244
|
-
case
|
245
|
-
return
|
221
|
+
case "Saturation":
|
222
|
+
return "saturation";
|
246
223
|
|
247
|
-
case
|
248
|
-
return
|
224
|
+
case "Color":
|
225
|
+
return "color";
|
249
226
|
|
250
|
-
case
|
251
|
-
return
|
227
|
+
case "Luminosity":
|
228
|
+
return "luminosity";
|
252
229
|
}
|
253
230
|
|
254
|
-
(
|
255
|
-
|
231
|
+
if (parsingArray) {
|
232
|
+
return null;
|
233
|
+
}
|
234
|
+
|
235
|
+
(0, _util.warn)(`Unsupported blend mode: ${value.name}`);
|
236
|
+
return "source-over";
|
256
237
|
}
|
257
238
|
|
258
239
|
var deferred = Promise.resolve();
|
259
240
|
var TILING_PATTERN = 1,
|
260
241
|
SHADING_PATTERN = 2;
|
261
242
|
PartialEvaluator.prototype = {
|
262
|
-
clone
|
263
|
-
var newOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DefaultPartialEvaluatorOptions;
|
243
|
+
clone(newOptions = DefaultPartialEvaluatorOptions) {
|
264
244
|
var newEvaluator = Object.create(this);
|
265
245
|
newEvaluator.options = newOptions;
|
266
246
|
return newEvaluator;
|
267
247
|
},
|
248
|
+
|
268
249
|
hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
|
269
|
-
if (!(
|
250
|
+
if (!(resources instanceof _primitives.Dict)) {
|
270
251
|
return false;
|
271
252
|
}
|
272
253
|
|
@@ -280,42 +261,110 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
280
261
|
xref = this.xref;
|
281
262
|
|
282
263
|
while (nodes.length) {
|
283
|
-
var key, i, ii;
|
284
264
|
var node = nodes.shift();
|
285
|
-
var graphicStates = node.get(
|
265
|
+
var graphicStates = node.get("ExtGState");
|
286
266
|
|
287
|
-
if (
|
267
|
+
if (graphicStates instanceof _primitives.Dict) {
|
288
268
|
var graphicStatesKeys = graphicStates.getKeys();
|
289
269
|
|
290
|
-
for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
|
291
|
-
key = graphicStatesKeys[i];
|
292
|
-
|
293
|
-
|
270
|
+
for (let i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
|
271
|
+
const key = graphicStatesKeys[i];
|
272
|
+
let graphicState = graphicStates.getRaw(key);
|
273
|
+
|
274
|
+
if (graphicState instanceof _primitives.Ref) {
|
275
|
+
if (processed[graphicState.toString()]) {
|
276
|
+
continue;
|
277
|
+
}
|
278
|
+
|
279
|
+
try {
|
280
|
+
graphicState = xref.fetch(graphicState);
|
281
|
+
} catch (ex) {
|
282
|
+
if (ex instanceof _core_utils.MissingDataException) {
|
283
|
+
throw ex;
|
284
|
+
}
|
285
|
+
|
286
|
+
if (this.options.ignoreErrors) {
|
287
|
+
if (graphicState instanceof _primitives.Ref) {
|
288
|
+
processed[graphicState.toString()] = true;
|
289
|
+
}
|
290
|
+
|
291
|
+
this.handler.send("UnsupportedFeature", {
|
292
|
+
featureId: _util.UNSUPPORTED_FEATURES.unknown
|
293
|
+
});
|
294
|
+
(0, _util.warn)(`hasBlendModes - ignoring ExtGState: "${ex}".`);
|
295
|
+
continue;
|
296
|
+
}
|
297
|
+
|
298
|
+
throw ex;
|
299
|
+
}
|
300
|
+
}
|
301
|
+
|
302
|
+
if (!(graphicState instanceof _primitives.Dict)) {
|
303
|
+
continue;
|
304
|
+
}
|
294
305
|
|
295
|
-
if (
|
296
|
-
|
306
|
+
if (graphicState.objId) {
|
307
|
+
processed[graphicState.objId] = true;
|
308
|
+
}
|
309
|
+
|
310
|
+
const bm = graphicState.get("BM");
|
311
|
+
|
312
|
+
if (bm instanceof _primitives.Name) {
|
313
|
+
if (bm.name !== "Normal") {
|
314
|
+
return true;
|
315
|
+
}
|
316
|
+
|
317
|
+
continue;
|
318
|
+
}
|
319
|
+
|
320
|
+
if (bm !== undefined && Array.isArray(bm)) {
|
321
|
+
for (let j = 0, jj = bm.length; j < jj; j++) {
|
322
|
+
if (bm[j] instanceof _primitives.Name && bm[j].name !== "Normal") {
|
323
|
+
return true;
|
324
|
+
}
|
325
|
+
}
|
297
326
|
}
|
298
327
|
}
|
299
328
|
}
|
300
329
|
|
301
|
-
var xObjects = node.get(
|
330
|
+
var xObjects = node.get("XObject");
|
302
331
|
|
303
|
-
if (!(
|
332
|
+
if (!(xObjects instanceof _primitives.Dict)) {
|
304
333
|
continue;
|
305
334
|
}
|
306
335
|
|
307
336
|
var xObjectsKeys = xObjects.getKeys();
|
308
337
|
|
309
|
-
for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
|
310
|
-
key = xObjectsKeys[i];
|
338
|
+
for (let i = 0, ii = xObjectsKeys.length; i < ii; i++) {
|
339
|
+
const key = xObjectsKeys[i];
|
311
340
|
var xObject = xObjects.getRaw(key);
|
312
341
|
|
313
|
-
if (
|
342
|
+
if (xObject instanceof _primitives.Ref) {
|
314
343
|
if (processed[xObject.toString()]) {
|
315
344
|
continue;
|
316
345
|
}
|
317
346
|
|
318
|
-
|
347
|
+
try {
|
348
|
+
xObject = xref.fetch(xObject);
|
349
|
+
} catch (ex) {
|
350
|
+
if (ex instanceof _core_utils.MissingDataException) {
|
351
|
+
throw ex;
|
352
|
+
}
|
353
|
+
|
354
|
+
if (this.options.ignoreErrors) {
|
355
|
+
if (xObject instanceof _primitives.Ref) {
|
356
|
+
processed[xObject.toString()] = true;
|
357
|
+
}
|
358
|
+
|
359
|
+
this.handler.send("UnsupportedFeature", {
|
360
|
+
featureId: _util.UNSUPPORTED_FEATURES.unknown
|
361
|
+
});
|
362
|
+
(0, _util.warn)(`hasBlendModes - ignoring XObject: "${ex}".`);
|
363
|
+
continue;
|
364
|
+
}
|
365
|
+
|
366
|
+
throw ex;
|
367
|
+
}
|
319
368
|
}
|
320
369
|
|
321
370
|
if (!(0, _primitives.isStream)(xObject)) {
|
@@ -330,9 +379,9 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
330
379
|
processed[xObject.dict.objId] = true;
|
331
380
|
}
|
332
381
|
|
333
|
-
var xResources = xObject.dict.get(
|
382
|
+
var xResources = xObject.dict.get("Resources");
|
334
383
|
|
335
|
-
if (
|
384
|
+
if (xResources instanceof _primitives.Dict && (!xResources.objId || !processed[xResources.objId])) {
|
336
385
|
nodes.push(xResources);
|
337
386
|
|
338
387
|
if (xResources.objId) {
|
@@ -344,10 +393,11 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
344
393
|
|
345
394
|
return false;
|
346
395
|
},
|
347
|
-
|
396
|
+
|
397
|
+
async buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
|
348
398
|
var dict = xobj.dict;
|
349
|
-
var matrix = dict.getArray(
|
350
|
-
var bbox = dict.getArray(
|
399
|
+
var matrix = dict.getArray("Matrix");
|
400
|
+
var bbox = dict.getArray("BBox");
|
351
401
|
|
352
402
|
if (Array.isArray(bbox) && bbox.length === 4) {
|
353
403
|
bbox = _util.Util.normalizeRect(bbox);
|
@@ -355,31 +405,28 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
355
405
|
bbox = null;
|
356
406
|
}
|
357
407
|
|
358
|
-
var group = dict.get(
|
408
|
+
var group = dict.get("Group");
|
359
409
|
|
360
410
|
if (group) {
|
361
411
|
var groupOptions = {
|
362
|
-
matrix
|
363
|
-
bbox
|
364
|
-
smask
|
412
|
+
matrix,
|
413
|
+
bbox,
|
414
|
+
smask,
|
365
415
|
isolated: false,
|
366
416
|
knockout: false
|
367
417
|
};
|
368
|
-
var groupSubtype = group.get(
|
418
|
+
var groupSubtype = group.get("S");
|
369
419
|
var colorSpace = null;
|
370
420
|
|
371
|
-
if ((0, _primitives.isName)(groupSubtype,
|
372
|
-
groupOptions.isolated = group.get(
|
373
|
-
groupOptions.knockout = group.get(
|
421
|
+
if ((0, _primitives.isName)(groupSubtype, "Transparency")) {
|
422
|
+
groupOptions.isolated = group.get("I") || false;
|
423
|
+
groupOptions.knockout = group.get("K") || false;
|
374
424
|
|
375
|
-
if (group.has(
|
376
|
-
colorSpace =
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
} else {
|
381
|
-
(0, _util.warn)('buildFormXObject - invalid/non-existent Group /CS entry: ' + group.getRaw('CS'));
|
382
|
-
}
|
425
|
+
if (group.has("CS")) {
|
426
|
+
colorSpace = await this.parseColorSpace({
|
427
|
+
cs: group.get("CS"),
|
428
|
+
resources
|
429
|
+
});
|
383
430
|
}
|
384
431
|
}
|
385
432
|
|
@@ -394,10 +441,10 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
394
441
|
operatorList.addOp(_util.OPS.paintFormXObjectBegin, [matrix, bbox]);
|
395
442
|
return this.getOperatorList({
|
396
443
|
stream: xobj,
|
397
|
-
task
|
398
|
-
resources: dict.get(
|
399
|
-
operatorList
|
400
|
-
initialState
|
444
|
+
task,
|
445
|
+
resources: dict.get("Resources") || resources,
|
446
|
+
operatorList,
|
447
|
+
initialState
|
401
448
|
}).then(function () {
|
402
449
|
operatorList.addOp(_util.OPS.paintFormXObjectEnd, []);
|
403
450
|
|
@@ -406,223 +453,182 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
406
453
|
}
|
407
454
|
});
|
408
455
|
},
|
409
|
-
buildPaintImageXObject: function () {
|
410
|
-
var _buildPaintImageXObject = _asyncToGenerator(
|
411
|
-
/*#__PURE__*/
|
412
|
-
_regenerator["default"].mark(function _callee2(_ref4) {
|
413
|
-
var _this2 = this;
|
414
|
-
|
415
|
-
var resources, image, _ref4$isInline, isInline, operatorList, cacheKey, imageCache, _ref4$forceDisableNat, forceDisableNativeImageDecoder, dict, w, h, maxImageSize, imageMask, imgData, args, width, height, bitStrideLength, imgArray, decode, softMask, mask, SMALL_IMAGE_DIMENSIONS, imageObj, nativeImageDecoderSupport, objId, nativeImageDecoder, imgPromise;
|
416
|
-
|
417
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
418
|
-
while (1) {
|
419
|
-
switch (_context2.prev = _context2.next) {
|
420
|
-
case 0:
|
421
|
-
resources = _ref4.resources, image = _ref4.image, _ref4$isInline = _ref4.isInline, isInline = _ref4$isInline === void 0 ? false : _ref4$isInline, operatorList = _ref4.operatorList, cacheKey = _ref4.cacheKey, imageCache = _ref4.imageCache, _ref4$forceDisableNat = _ref4.forceDisableNativeImageDecoder, forceDisableNativeImageDecoder = _ref4$forceDisableNat === void 0 ? false : _ref4$forceDisableNat;
|
422
|
-
dict = image.dict;
|
423
|
-
w = dict.get('Width', 'W');
|
424
|
-
h = dict.get('Height', 'H');
|
425
|
-
|
426
|
-
if (!(!(w && (0, _util.isNum)(w)) || !(h && (0, _util.isNum)(h)))) {
|
427
|
-
_context2.next = 7;
|
428
|
-
break;
|
429
|
-
}
|
430
|
-
|
431
|
-
(0, _util.warn)('Image dimensions are missing, or not numbers.');
|
432
|
-
return _context2.abrupt("return", undefined);
|
433
|
-
|
434
|
-
case 7:
|
435
|
-
maxImageSize = this.options.maxImageSize;
|
436
456
|
|
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
|
-
imageObj = new _image.PDFImage({
|
489
|
-
xref: this.xref,
|
490
|
-
res: resources,
|
491
|
-
image: image,
|
492
|
-
isInline: isInline,
|
493
|
-
pdfFunctionFactory: this.pdfFunctionFactory
|
494
|
-
});
|
495
|
-
imgData = imageObj.createImageData(true);
|
496
|
-
operatorList.addOp(_util.OPS.paintInlineImageXObject, [imgData]);
|
497
|
-
return _context2.abrupt("return", undefined);
|
457
|
+
async buildPaintImageXObject({
|
458
|
+
resources,
|
459
|
+
image,
|
460
|
+
isInline = false,
|
461
|
+
operatorList,
|
462
|
+
cacheKey,
|
463
|
+
imageCache,
|
464
|
+
forceDisableNativeImageDecoder = false
|
465
|
+
}) {
|
466
|
+
var dict = image.dict;
|
467
|
+
var w = dict.get("Width", "W");
|
468
|
+
var h = dict.get("Height", "H");
|
469
|
+
|
470
|
+
if (!(w && (0, _util.isNum)(w)) || !(h && (0, _util.isNum)(h))) {
|
471
|
+
(0, _util.warn)("Image dimensions are missing, or not numbers.");
|
472
|
+
return undefined;
|
473
|
+
}
|
474
|
+
|
475
|
+
var maxImageSize = this.options.maxImageSize;
|
476
|
+
|
477
|
+
if (maxImageSize !== -1 && w * h > maxImageSize) {
|
478
|
+
(0, _util.warn)("Image exceeded maximum allowed size and was removed.");
|
479
|
+
return undefined;
|
480
|
+
}
|
481
|
+
|
482
|
+
var imageMask = dict.get("ImageMask", "IM") || false;
|
483
|
+
var imgData, args;
|
484
|
+
|
485
|
+
if (imageMask) {
|
486
|
+
var width = dict.get("Width", "W");
|
487
|
+
var height = dict.get("Height", "H");
|
488
|
+
var bitStrideLength = width + 7 >> 3;
|
489
|
+
var imgArray = image.getBytes(bitStrideLength * height, true);
|
490
|
+
var decode = dict.getArray("Decode", "D");
|
491
|
+
imgData = _image.PDFImage.createMask({
|
492
|
+
imgArray,
|
493
|
+
width,
|
494
|
+
height,
|
495
|
+
imageIsFromDecodeStream: image instanceof _stream.DecodeStream,
|
496
|
+
inverseDecode: !!decode && decode[0] > 0
|
497
|
+
});
|
498
|
+
imgData.cached = !!cacheKey;
|
499
|
+
args = [imgData];
|
500
|
+
operatorList.addOp(_util.OPS.paintImageMaskXObject, args);
|
501
|
+
|
502
|
+
if (cacheKey) {
|
503
|
+
imageCache[cacheKey] = {
|
504
|
+
fn: _util.OPS.paintImageMaskXObject,
|
505
|
+
args
|
506
|
+
};
|
507
|
+
}
|
498
508
|
|
499
|
-
|
500
|
-
|
501
|
-
objId = "img_".concat(this.idFactory.createObjId());
|
509
|
+
return undefined;
|
510
|
+
}
|
502
511
|
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
}
|
512
|
+
var softMask = dict.get("SMask", "SM") || false;
|
513
|
+
var mask = dict.get("Mask") || false;
|
514
|
+
var SMALL_IMAGE_DIMENSIONS = 200;
|
507
515
|
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
516
|
+
if (isInline && !softMask && !mask && !(image instanceof _jpeg_stream.JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
|
517
|
+
const imageObj = new _image.PDFImage({
|
518
|
+
xref: this.xref,
|
519
|
+
res: resources,
|
520
|
+
image,
|
521
|
+
isInline,
|
522
|
+
pdfFunctionFactory: this.pdfFunctionFactory
|
523
|
+
});
|
524
|
+
imgData = imageObj.createImageData(true);
|
525
|
+
operatorList.addOp(_util.OPS.paintInlineImageXObject, [imgData]);
|
526
|
+
return undefined;
|
527
|
+
}
|
512
528
|
|
513
|
-
|
514
|
-
|
515
|
-
args = [objId, w, h];
|
516
|
-
operatorList.addOp(_util.OPS.paintJpegXObject, args);
|
529
|
+
const nativeImageDecoderSupport = forceDisableNativeImageDecoder ? _util.NativeImageDecoding.NONE : this.options.nativeImageDecoderSupport;
|
530
|
+
let objId = `img_${this.idFactory.createObjId()}`;
|
517
531
|
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
};
|
523
|
-
}
|
524
|
-
}, function (reason) {
|
525
|
-
(0, _util.warn)('Native JPEG decoding failed -- trying to recover: ' + (reason && reason.message));
|
526
|
-
return _this2.buildPaintImageXObject({
|
527
|
-
resources: resources,
|
528
|
-
image: image,
|
529
|
-
isInline: isInline,
|
530
|
-
operatorList: operatorList,
|
531
|
-
cacheKey: cacheKey,
|
532
|
-
imageCache: imageCache,
|
533
|
-
forceDisableNativeImageDecoder: true
|
534
|
-
});
|
535
|
-
}));
|
536
|
-
|
537
|
-
case 37:
|
538
|
-
nativeImageDecoder = null;
|
539
|
-
|
540
|
-
if (nativeImageDecoderSupport === _util.NativeImageDecoding.DECODE && (image instanceof _jpeg_stream.JpegStream || mask instanceof _jpeg_stream.JpegStream || softMask instanceof _jpeg_stream.JpegStream)) {
|
541
|
-
nativeImageDecoder = new _image_utils.NativeImageDecoder({
|
542
|
-
xref: this.xref,
|
543
|
-
resources: resources,
|
544
|
-
handler: this.handler,
|
545
|
-
forceDataSchema: this.options.forceDataSchema,
|
546
|
-
pdfFunctionFactory: this.pdfFunctionFactory
|
547
|
-
});
|
548
|
-
}
|
532
|
+
if (this.parsingType3Font) {
|
533
|
+
(0, _util.assert)(nativeImageDecoderSupport === _util.NativeImageDecoding.NONE, "Type3 image resources should be completely decoded in the worker.");
|
534
|
+
objId = `${this.idFactory.getDocId()}_type3res_${objId}`;
|
535
|
+
}
|
549
536
|
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
res: resources,
|
556
|
-
image: image,
|
557
|
-
isInline: isInline,
|
558
|
-
nativeDecoder: nativeImageDecoder,
|
559
|
-
pdfFunctionFactory: this.pdfFunctionFactory
|
560
|
-
}).then(function (imageObj) {
|
561
|
-
var imgData = imageObj.createImageData(false);
|
562
|
-
|
563
|
-
if (_this2.parsingType3Font) {
|
564
|
-
return _this2.handler.sendWithPromise('commonobj', [objId, 'FontType3Res', imgData], [imgData.data.buffer]);
|
565
|
-
}
|
537
|
+
if (nativeImageDecoderSupport !== _util.NativeImageDecoding.NONE && !softMask && !mask && image instanceof _jpeg_stream.JpegStream && _image_utils.NativeImageDecoder.isSupported(image, this.xref, resources, this.pdfFunctionFactory) && image.maybeValidDimensions) {
|
538
|
+
return this.handler.sendWithPromise("obj", [objId, this.pageIndex, "JpegStream", image.getIR(this.options.forceDataSchema)]).then(function () {
|
539
|
+
operatorList.addDependency(objId);
|
540
|
+
args = [objId, w, h];
|
541
|
+
operatorList.addOp(_util.OPS.paintJpegXObject, args);
|
566
542
|
|
567
|
-
|
543
|
+
if (cacheKey) {
|
544
|
+
imageCache[cacheKey] = {
|
545
|
+
fn: _util.OPS.paintJpegXObject,
|
546
|
+
args
|
547
|
+
};
|
548
|
+
}
|
549
|
+
}, reason => {
|
550
|
+
(0, _util.warn)("Native JPEG decoding failed -- trying to recover: " + (reason && reason.message));
|
551
|
+
return this.buildPaintImageXObject({
|
552
|
+
resources,
|
553
|
+
image,
|
554
|
+
isInline,
|
555
|
+
operatorList,
|
556
|
+
cacheKey,
|
557
|
+
imageCache,
|
558
|
+
forceDisableNativeImageDecoder: true
|
559
|
+
});
|
560
|
+
});
|
561
|
+
}
|
568
562
|
|
569
|
-
|
570
|
-
})["catch"](function (reason) {
|
571
|
-
(0, _util.warn)('Unable to decode image: ' + reason);
|
563
|
+
var nativeImageDecoder = null;
|
572
564
|
|
573
|
-
|
574
|
-
|
575
|
-
|
565
|
+
if (nativeImageDecoderSupport === _util.NativeImageDecoding.DECODE && (image instanceof _jpeg_stream.JpegStream || mask instanceof _jpeg_stream.JpegStream || softMask instanceof _jpeg_stream.JpegStream)) {
|
566
|
+
nativeImageDecoder = new _image_utils.NativeImageDecoder({
|
567
|
+
xref: this.xref,
|
568
|
+
resources,
|
569
|
+
handler: this.handler,
|
570
|
+
forceDataSchema: this.options.forceDataSchema,
|
571
|
+
pdfFunctionFactory: this.pdfFunctionFactory
|
572
|
+
});
|
573
|
+
}
|
576
574
|
|
577
|
-
|
575
|
+
operatorList.addDependency(objId);
|
576
|
+
args = [objId, w, h];
|
578
577
|
|
579
|
-
|
580
|
-
|
578
|
+
const imgPromise = _image.PDFImage.buildImage({
|
579
|
+
handler: this.handler,
|
580
|
+
xref: this.xref,
|
581
|
+
res: resources,
|
582
|
+
image,
|
583
|
+
isInline,
|
584
|
+
nativeDecoder: nativeImageDecoder,
|
585
|
+
pdfFunctionFactory: this.pdfFunctionFactory
|
586
|
+
}).then(imageObj => {
|
587
|
+
var imgData = imageObj.createImageData(false);
|
581
588
|
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
}
|
589
|
+
if (this.parsingType3Font) {
|
590
|
+
return this.handler.sendWithPromise("commonobj", [objId, "FontType3Res", imgData], [imgData.data.buffer]);
|
591
|
+
}
|
586
592
|
|
587
|
-
|
588
|
-
|
593
|
+
this.handler.send("obj", [objId, this.pageIndex, "Image", imgData], [imgData.data.buffer]);
|
594
|
+
return undefined;
|
595
|
+
}).catch(reason => {
|
596
|
+
(0, _util.warn)("Unable to decode image: " + reason);
|
589
597
|
|
590
|
-
|
591
|
-
|
598
|
+
if (this.parsingType3Font) {
|
599
|
+
return this.handler.sendWithPromise("commonobj", [objId, "FontType3Res", null]);
|
600
|
+
}
|
592
601
|
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
args: args
|
597
|
-
};
|
598
|
-
}
|
602
|
+
this.handler.send("obj", [objId, this.pageIndex, "Image", null]);
|
603
|
+
return undefined;
|
604
|
+
});
|
599
605
|
|
600
|
-
|
606
|
+
if (this.parsingType3Font) {
|
607
|
+
await imgPromise;
|
608
|
+
}
|
601
609
|
|
602
|
-
|
603
|
-
case "end":
|
604
|
-
return _context2.stop();
|
605
|
-
}
|
606
|
-
}
|
607
|
-
}, _callee2, this);
|
608
|
-
}));
|
610
|
+
operatorList.addOp(_util.OPS.paintImageXObject, args);
|
609
611
|
|
610
|
-
|
611
|
-
|
612
|
+
if (cacheKey) {
|
613
|
+
imageCache[cacheKey] = {
|
614
|
+
fn: _util.OPS.paintImageXObject,
|
615
|
+
args
|
616
|
+
};
|
612
617
|
}
|
613
618
|
|
614
|
-
return
|
615
|
-
}
|
619
|
+
return undefined;
|
620
|
+
},
|
621
|
+
|
616
622
|
handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
|
617
|
-
var smaskContent = smask.get(
|
623
|
+
var smaskContent = smask.get("G");
|
618
624
|
var smaskOptions = {
|
619
|
-
subtype: smask.get(
|
620
|
-
backdrop: smask.get(
|
625
|
+
subtype: smask.get("S").name,
|
626
|
+
backdrop: smask.get("BC")
|
621
627
|
};
|
622
|
-
var transferObj = smask.get(
|
628
|
+
var transferObj = smask.get("TR");
|
623
629
|
|
624
630
|
if ((0, _function.isPDFFunction)(transferObj)) {
|
625
|
-
|
631
|
+
const transferFn = this.pdfFunctionFactory.create(transferObj);
|
626
632
|
var transferMap = new Uint8Array(256);
|
627
633
|
var tmp = new Float32Array(1);
|
628
634
|
|
@@ -637,17 +643,16 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
637
643
|
|
638
644
|
return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
|
639
645
|
},
|
640
|
-
handleTilingType: function handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
|
641
|
-
var _this3 = this;
|
642
646
|
|
643
|
-
|
644
|
-
|
647
|
+
handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
|
648
|
+
const tilingOpList = new _operator_list.OperatorList();
|
649
|
+
const resourcesArray = [patternDict.get("Resources"), resources];
|
645
650
|
|
646
|
-
|
651
|
+
const patternResources = _primitives.Dict.merge(this.xref, resourcesArray);
|
647
652
|
|
648
653
|
return this.getOperatorList({
|
649
654
|
stream: pattern,
|
650
|
-
task
|
655
|
+
task,
|
651
656
|
resources: patternResources,
|
652
657
|
operatorList: tilingOpList
|
653
658
|
}).then(function () {
|
@@ -658,26 +663,24 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
658
663
|
}).then(function (tilingPatternIR) {
|
659
664
|
operatorList.addDependencies(tilingOpList.dependencies);
|
660
665
|
operatorList.addOp(fn, tilingPatternIR);
|
661
|
-
},
|
666
|
+
}, reason => {
|
662
667
|
if (reason instanceof _util.AbortException) {
|
663
668
|
return;
|
664
669
|
}
|
665
670
|
|
666
|
-
if (
|
667
|
-
|
671
|
+
if (this.options.ignoreErrors) {
|
672
|
+
this.handler.send("UnsupportedFeature", {
|
668
673
|
featureId: _util.UNSUPPORTED_FEATURES.unknown
|
669
674
|
});
|
670
|
-
|
671
|
-
(0, _util.warn)("handleTilingType - ignoring pattern: \"".concat(reason, "\"."));
|
675
|
+
(0, _util.warn)(`handleTilingType - ignoring pattern: "${reason}".`);
|
672
676
|
return;
|
673
677
|
}
|
674
678
|
|
675
679
|
throw reason;
|
676
680
|
});
|
677
681
|
},
|
678
|
-
handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
|
679
|
-
var _this4 = this;
|
680
682
|
|
683
|
+
handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
|
681
684
|
var fontName;
|
682
685
|
|
683
686
|
if (fontArgs) {
|
@@ -685,122 +688,135 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
685
688
|
fontName = fontArgs[0].name;
|
686
689
|
}
|
687
690
|
|
688
|
-
return this.loadFont(fontName, fontRef, resources).then(
|
691
|
+
return this.loadFont(fontName, fontRef, resources).then(translated => {
|
689
692
|
if (!translated.font.isType3Font) {
|
690
693
|
return translated;
|
691
694
|
}
|
692
695
|
|
693
|
-
return translated.loadType3Data(
|
696
|
+
return translated.loadType3Data(this, resources, operatorList, task).then(function () {
|
694
697
|
return translated;
|
695
|
-
})
|
696
|
-
|
698
|
+
}).catch(reason => {
|
699
|
+
this.handler.send("UnsupportedFeature", {
|
697
700
|
featureId: _util.UNSUPPORTED_FEATURES.font
|
698
701
|
});
|
699
|
-
|
700
|
-
return new TranslatedFont('g_font_error', new _fonts.ErrorFont('Type3 font load error: ' + reason), translated.font);
|
702
|
+
return new TranslatedFont("g_font_error", new _fonts.ErrorFont("Type3 font load error: " + reason), translated.font);
|
701
703
|
});
|
702
|
-
}).then(
|
704
|
+
}).then(translated => {
|
703
705
|
state.font = translated.font;
|
704
|
-
translated.send(
|
706
|
+
translated.send(this.handler);
|
705
707
|
return translated.loadedName;
|
706
708
|
});
|
707
709
|
},
|
708
|
-
|
709
|
-
|
710
|
-
|
710
|
+
|
711
|
+
handleText(chars, state) {
|
712
|
+
const font = state.font;
|
713
|
+
const glyphs = font.charsToGlyphs(chars);
|
711
714
|
|
712
715
|
if (font.data) {
|
713
|
-
|
716
|
+
const isAddToPathSet = !!(state.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
|
714
717
|
|
715
|
-
if (isAddToPathSet || state.fillColorSpace.name ===
|
718
|
+
if (isAddToPathSet || state.fillColorSpace.name === "Pattern" || font.disableFontFace || this.options.disableFontFace) {
|
716
719
|
PartialEvaluator.buildFontPaths(font, glyphs, this.handler);
|
717
720
|
}
|
718
721
|
}
|
719
722
|
|
720
723
|
return glyphs;
|
721
724
|
},
|
722
|
-
setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, stateManager) {
|
723
|
-
var _this5 = this;
|
724
725
|
|
726
|
+
ensureStateFont(state) {
|
727
|
+
if (state.font) {
|
728
|
+
return;
|
729
|
+
}
|
730
|
+
|
731
|
+
const reason = new _util.FormatError("Missing setFont (Tf) operator before text rendering operator.");
|
732
|
+
|
733
|
+
if (this.options.ignoreErrors) {
|
734
|
+
this.handler.send("UnsupportedFeature", {
|
735
|
+
featureId: _util.UNSUPPORTED_FEATURES.font
|
736
|
+
});
|
737
|
+
(0, _util.warn)(`ensureStateFont: "${reason}".`);
|
738
|
+
return;
|
739
|
+
}
|
740
|
+
|
741
|
+
throw reason;
|
742
|
+
},
|
743
|
+
|
744
|
+
setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, stateManager) {
|
725
745
|
var gStateObj = [];
|
726
746
|
var gStateKeys = gState.getKeys();
|
727
747
|
var promise = Promise.resolve();
|
728
748
|
|
729
|
-
var
|
730
|
-
|
731
|
-
|
749
|
+
for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
|
750
|
+
const key = gStateKeys[i];
|
751
|
+
const value = gState.get(key);
|
732
752
|
|
733
753
|
switch (key) {
|
734
|
-
case
|
754
|
+
case "Type":
|
735
755
|
break;
|
736
756
|
|
737
|
-
case
|
738
|
-
case
|
739
|
-
case
|
740
|
-
case
|
741
|
-
case
|
742
|
-
case
|
743
|
-
case
|
744
|
-
case
|
745
|
-
case
|
757
|
+
case "LW":
|
758
|
+
case "LC":
|
759
|
+
case "LJ":
|
760
|
+
case "ML":
|
761
|
+
case "D":
|
762
|
+
case "RI":
|
763
|
+
case "FL":
|
764
|
+
case "CA":
|
765
|
+
case "ca":
|
746
766
|
gStateObj.push([key, value]);
|
747
767
|
break;
|
748
768
|
|
749
|
-
case
|
750
|
-
promise = promise.then(
|
751
|
-
return
|
769
|
+
case "Font":
|
770
|
+
promise = promise.then(() => {
|
771
|
+
return this.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
|
752
772
|
operatorList.addDependency(loadedName);
|
753
773
|
gStateObj.push([key, [loadedName, value[1]]]);
|
754
774
|
});
|
755
775
|
});
|
756
776
|
break;
|
757
777
|
|
758
|
-
case
|
778
|
+
case "BM":
|
759
779
|
gStateObj.push([key, normalizeBlendMode(value)]);
|
760
780
|
break;
|
761
781
|
|
762
|
-
case
|
763
|
-
if ((0, _primitives.isName)(value,
|
782
|
+
case "SMask":
|
783
|
+
if ((0, _primitives.isName)(value, "None")) {
|
764
784
|
gStateObj.push([key, false]);
|
765
785
|
break;
|
766
786
|
}
|
767
787
|
|
768
788
|
if ((0, _primitives.isDict)(value)) {
|
769
|
-
promise = promise.then(
|
770
|
-
return
|
789
|
+
promise = promise.then(() => {
|
790
|
+
return this.handleSMask(value, resources, operatorList, task, stateManager);
|
771
791
|
});
|
772
792
|
gStateObj.push([key, true]);
|
773
793
|
} else {
|
774
|
-
(0, _util.warn)(
|
794
|
+
(0, _util.warn)("Unsupported SMask type");
|
775
795
|
}
|
776
796
|
|
777
797
|
break;
|
778
798
|
|
779
|
-
case
|
780
|
-
case
|
781
|
-
case
|
782
|
-
case
|
783
|
-
case
|
784
|
-
case
|
785
|
-
case
|
786
|
-
case
|
787
|
-
case
|
788
|
-
case
|
789
|
-
case
|
790
|
-
case
|
791
|
-
case
|
792
|
-
case
|
793
|
-
(0, _util.info)(
|
799
|
+
case "OP":
|
800
|
+
case "op":
|
801
|
+
case "OPM":
|
802
|
+
case "BG":
|
803
|
+
case "BG2":
|
804
|
+
case "UCR":
|
805
|
+
case "UCR2":
|
806
|
+
case "TR":
|
807
|
+
case "TR2":
|
808
|
+
case "HT":
|
809
|
+
case "SM":
|
810
|
+
case "SA":
|
811
|
+
case "AIS":
|
812
|
+
case "TK":
|
813
|
+
(0, _util.info)("graphic state operator " + key);
|
794
814
|
break;
|
795
815
|
|
796
816
|
default:
|
797
|
-
(0, _util.info)(
|
817
|
+
(0, _util.info)("Unknown graphic state operator " + key);
|
798
818
|
break;
|
799
819
|
}
|
800
|
-
};
|
801
|
-
|
802
|
-
for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
|
803
|
-
_loop();
|
804
820
|
}
|
805
821
|
|
806
822
|
return promise.then(function () {
|
@@ -810,10 +826,8 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
810
826
|
});
|
811
827
|
},
|
812
828
|
loadFont: function PartialEvaluator_loadFont(fontName, font, resources) {
|
813
|
-
var _this6 = this;
|
814
|
-
|
815
829
|
function errorFont() {
|
816
|
-
return Promise.resolve(new TranslatedFont(
|
830
|
+
return Promise.resolve(new TranslatedFont("g_font_error", new _fonts.ErrorFont("Font " + fontName + " is not available"), font));
|
817
831
|
}
|
818
832
|
|
819
833
|
var fontRef,
|
@@ -821,24 +835,31 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
821
835
|
|
822
836
|
if (font) {
|
823
837
|
if (!(0, _primitives.isRef)(font)) {
|
824
|
-
throw new
|
838
|
+
throw new _util.FormatError('The "font" object should be a reference.');
|
825
839
|
}
|
826
840
|
|
827
841
|
fontRef = font;
|
828
842
|
} else {
|
829
|
-
var fontRes = resources.get(
|
843
|
+
var fontRes = resources.get("Font");
|
830
844
|
|
831
845
|
if (fontRes) {
|
832
846
|
fontRef = fontRes.getRaw(fontName);
|
833
|
-
} else {
|
834
|
-
(0, _util.warn)('fontRes not available');
|
835
|
-
return errorFont();
|
836
847
|
}
|
837
848
|
}
|
838
849
|
|
839
850
|
if (!fontRef) {
|
840
|
-
|
841
|
-
|
851
|
+
const partialMsg = `Font "${fontName || font && font.toString()}" is not available`;
|
852
|
+
|
853
|
+
if (!this.options.ignoreErrors && !this.parsingType3Font) {
|
854
|
+
(0, _util.warn)(`${partialMsg}.`);
|
855
|
+
return errorFont();
|
856
|
+
}
|
857
|
+
|
858
|
+
this.handler.send("UnsupportedFeature", {
|
859
|
+
featureId: _util.UNSUPPORTED_FEATURES.font
|
860
|
+
});
|
861
|
+
(0, _util.warn)(`${partialMsg} -- attempting to fallback to a default font.`);
|
862
|
+
fontRef = PartialEvaluator.getFallbackFontDict();
|
842
863
|
}
|
843
864
|
|
844
865
|
if (this.fontCache.has(fontRef)) {
|
@@ -857,8 +878,10 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
857
878
|
|
858
879
|
var fontCapability = (0, _util.createPromiseCapability)();
|
859
880
|
var preEvaluatedFont = this.preEvaluateFont(font);
|
860
|
-
|
861
|
-
|
881
|
+
const {
|
882
|
+
descriptor,
|
883
|
+
hash
|
884
|
+
} = preEvaluatedFont;
|
862
885
|
var fontRefIsRef = (0, _primitives.isRef)(fontRef),
|
863
886
|
fontID;
|
864
887
|
|
@@ -900,11 +923,11 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
900
923
|
fontID = this.idFactory.createObjId();
|
901
924
|
}
|
902
925
|
|
903
|
-
this.fontCache.put(
|
926
|
+
this.fontCache.put(`id_${fontID}`, fontCapability.promise);
|
904
927
|
}
|
905
928
|
|
906
929
|
(0, _util.assert)(fontID, 'The "fontID" must be defined.');
|
907
|
-
font.loadedName =
|
930
|
+
font.loadedName = `${this.idFactory.getDocId()}_f${fontID}`;
|
908
931
|
font.translated = fontCapability.promise;
|
909
932
|
var translatedPromise;
|
910
933
|
|
@@ -921,14 +944,14 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
921
944
|
}
|
922
945
|
|
923
946
|
fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
|
924
|
-
})
|
925
|
-
|
947
|
+
}).catch(reason => {
|
948
|
+
this.handler.send("UnsupportedFeature", {
|
926
949
|
featureId: _util.UNSUPPORTED_FEATURES.font
|
927
950
|
});
|
928
951
|
|
929
952
|
try {
|
930
|
-
var fontFile3 = descriptor && descriptor.get(
|
931
|
-
var subtype = fontFile3 && fontFile3.get(
|
953
|
+
var fontFile3 = descriptor && descriptor.get("FontFile3");
|
954
|
+
var subtype = fontFile3 && fontFile3.get("Subtype");
|
932
955
|
var fontType = (0, _fonts.getFontType)(preEvaluatedFont.type, subtype && subtype.name);
|
933
956
|
var xrefFontStats = xref.stats.fontTypes;
|
934
957
|
xrefFontStats[fontType] = true;
|
@@ -938,8 +961,8 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
938
961
|
});
|
939
962
|
return fontCapability.promise;
|
940
963
|
},
|
941
|
-
|
942
|
-
|
964
|
+
|
965
|
+
buildPath(operatorList, fn, args, parsingText = false) {
|
943
966
|
var lastIndex = operatorList.length - 1;
|
944
967
|
|
945
968
|
if (!args) {
|
@@ -948,7 +971,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
948
971
|
|
949
972
|
if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== _util.OPS.constructPath) {
|
950
973
|
if (parsingText) {
|
951
|
-
(0, _util.warn)(
|
974
|
+
(0, _util.warn)(`Encountered path operator "${fn}" inside of a text object.`);
|
952
975
|
operatorList.addOp(_util.OPS.save, null);
|
953
976
|
}
|
954
977
|
|
@@ -963,74 +986,62 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
963
986
|
Array.prototype.push.apply(opArgs[1], args);
|
964
987
|
}
|
965
988
|
},
|
966
|
-
handleColorN: function () {
|
967
|
-
var _handleColorN = _asyncToGenerator(
|
968
|
-
/*#__PURE__*/
|
969
|
-
_regenerator["default"].mark(function _callee3(operatorList, fn, args, cs, patterns, resources, task) {
|
970
|
-
var patternName, pattern, dict, typeNum, color, shading, matrix;
|
971
|
-
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
972
|
-
while (1) {
|
973
|
-
switch (_context3.prev = _context3.next) {
|
974
|
-
case 0:
|
975
|
-
patternName = args[args.length - 1];
|
976
|
-
|
977
|
-
if (!((0, _primitives.isName)(patternName) && (pattern = patterns.get(patternName.name)))) {
|
978
|
-
_context3.next = 16;
|
979
|
-
break;
|
980
|
-
}
|
981
989
|
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
990
|
+
parseColorSpace({
|
991
|
+
cs,
|
992
|
+
resources
|
993
|
+
}) {
|
994
|
+
return new Promise(resolve => {
|
995
|
+
resolve(_colorspace.ColorSpace.parse(cs, this.xref, resources, this.pdfFunctionFactory));
|
996
|
+
}).catch(reason => {
|
997
|
+
if (reason instanceof _util.AbortException) {
|
998
|
+
return null;
|
999
|
+
}
|
992
1000
|
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
1001
|
+
if (this.options.ignoreErrors) {
|
1002
|
+
this.handler.send("UnsupportedFeature", {
|
1003
|
+
featureId: _util.UNSUPPORTED_FEATURES.unknown
|
1004
|
+
});
|
1005
|
+
(0, _util.warn)(`parseColorSpace - ignoring ColorSpace: "${reason}".`);
|
1006
|
+
return null;
|
1007
|
+
}
|
998
1008
|
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
operatorList.addOp(fn, pattern.getIR());
|
1003
|
-
return _context3.abrupt("return", undefined);
|
1009
|
+
throw reason;
|
1010
|
+
});
|
1011
|
+
},
|
1004
1012
|
|
1005
|
-
|
1006
|
-
|
1013
|
+
async handleColorN(operatorList, fn, args, cs, patterns, resources, task) {
|
1014
|
+
var patternName = args[args.length - 1];
|
1015
|
+
var pattern;
|
1007
1016
|
|
1008
|
-
|
1009
|
-
|
1017
|
+
if ((0, _primitives.isName)(patternName) && (pattern = patterns.get(patternName.name))) {
|
1018
|
+
var dict = (0, _primitives.isStream)(pattern) ? pattern.dict : pattern;
|
1019
|
+
var typeNum = dict.get("PatternType");
|
1010
1020
|
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1021
|
+
if (typeNum === TILING_PATTERN) {
|
1022
|
+
var color = cs.base ? cs.base.getRgb(args, 0) : null;
|
1023
|
+
return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
|
1024
|
+
} else if (typeNum === SHADING_PATTERN) {
|
1025
|
+
var shading = dict.get("Shading");
|
1026
|
+
var matrix = dict.getArray("Matrix");
|
1027
|
+
pattern = _pattern.Pattern.parseShading(shading, matrix, this.xref, resources, this.handler, this.pdfFunctionFactory);
|
1028
|
+
operatorList.addOp(fn, pattern.getIR());
|
1029
|
+
return undefined;
|
1030
|
+
}
|
1018
1031
|
|
1019
|
-
|
1020
|
-
return _handleColorN.apply(this, arguments);
|
1032
|
+
throw new _util.FormatError(`Unknown PatternType: ${typeNum}`);
|
1021
1033
|
}
|
1022
1034
|
|
1023
|
-
|
1024
|
-
}
|
1025
|
-
getOperatorList: function getOperatorList(_ref5) {
|
1026
|
-
var _this7 = this;
|
1035
|
+
throw new _util.FormatError(`Unknown PatternName: ${patternName}`);
|
1036
|
+
},
|
1027
1037
|
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1038
|
+
getOperatorList({
|
1039
|
+
stream,
|
1040
|
+
task,
|
1041
|
+
resources,
|
1042
|
+
operatorList,
|
1043
|
+
initialState = null
|
1044
|
+
}) {
|
1034
1045
|
resources = resources || _primitives.Dict.empty;
|
1035
1046
|
initialState = initialState || new EvalState();
|
1036
1047
|
|
@@ -1040,12 +1051,12 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1040
1051
|
|
1041
1052
|
var self = this;
|
1042
1053
|
var xref = this.xref;
|
1043
|
-
|
1054
|
+
let parsingText = false;
|
1044
1055
|
var imageCache = Object.create(null);
|
1045
1056
|
|
1046
|
-
var xobjs = resources.get(
|
1057
|
+
var xobjs = resources.get("XObject") || _primitives.Dict.empty;
|
1047
1058
|
|
1048
|
-
var patterns = resources.get(
|
1059
|
+
var patterns = resources.get("Pattern") || _primitives.Dict.empty;
|
1049
1060
|
|
1050
1061
|
var stateManager = new StateManager(initialState);
|
1051
1062
|
var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
|
@@ -1058,7 +1069,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1058
1069
|
}
|
1059
1070
|
|
1060
1071
|
return new Promise(function promiseBody(resolve, reject) {
|
1061
|
-
|
1072
|
+
const next = function (promise) {
|
1062
1073
|
Promise.all([promise, operatorList.ready]).then(function () {
|
1063
1074
|
try {
|
1064
1075
|
promiseBody(resolve, reject);
|
@@ -1098,10 +1109,10 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1098
1109
|
|
1099
1110
|
next(new Promise(function (resolveXObject, rejectXObject) {
|
1100
1111
|
if (!name) {
|
1101
|
-
throw new _util.FormatError(
|
1112
|
+
throw new _util.FormatError("XObject must be referred to by name.");
|
1102
1113
|
}
|
1103
1114
|
|
1104
|
-
|
1115
|
+
const xobj = xobjs.get(name);
|
1105
1116
|
|
1106
1117
|
if (!xobj) {
|
1107
1118
|
operatorList.addOp(fn, args);
|
@@ -1110,48 +1121,48 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1110
1121
|
}
|
1111
1122
|
|
1112
1123
|
if (!(0, _primitives.isStream)(xobj)) {
|
1113
|
-
throw new _util.FormatError(
|
1124
|
+
throw new _util.FormatError("XObject should be a stream");
|
1114
1125
|
}
|
1115
1126
|
|
1116
|
-
|
1127
|
+
const type = xobj.dict.get("Subtype");
|
1117
1128
|
|
1118
1129
|
if (!(0, _primitives.isName)(type)) {
|
1119
|
-
throw new _util.FormatError(
|
1130
|
+
throw new _util.FormatError("XObject should have a Name subtype");
|
1120
1131
|
}
|
1121
1132
|
|
1122
|
-
if (type.name ===
|
1133
|
+
if (type.name === "Form") {
|
1123
1134
|
stateManager.save();
|
1124
1135
|
self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
|
1125
1136
|
stateManager.restore();
|
1126
1137
|
resolveXObject();
|
1127
1138
|
}, rejectXObject);
|
1128
1139
|
return;
|
1129
|
-
} else if (type.name ===
|
1140
|
+
} else if (type.name === "Image") {
|
1130
1141
|
self.buildPaintImageXObject({
|
1131
|
-
resources
|
1142
|
+
resources,
|
1132
1143
|
image: xobj,
|
1133
|
-
operatorList
|
1144
|
+
operatorList,
|
1134
1145
|
cacheKey: name,
|
1135
|
-
imageCache
|
1146
|
+
imageCache
|
1136
1147
|
}).then(resolveXObject, rejectXObject);
|
1137
1148
|
return;
|
1138
|
-
} else if (type.name ===
|
1139
|
-
(0, _util.info)(
|
1149
|
+
} else if (type.name === "PS") {
|
1150
|
+
(0, _util.info)("Ignored XObject subtype PS");
|
1140
1151
|
} else {
|
1141
|
-
throw new _util.FormatError(
|
1152
|
+
throw new _util.FormatError(`Unhandled XObject subtype ${type.name}`);
|
1142
1153
|
}
|
1143
1154
|
|
1144
1155
|
resolveXObject();
|
1145
|
-
})
|
1156
|
+
}).catch(function (reason) {
|
1146
1157
|
if (reason instanceof _util.AbortException) {
|
1147
1158
|
return;
|
1148
1159
|
}
|
1149
1160
|
|
1150
1161
|
if (self.options.ignoreErrors) {
|
1151
|
-
self.handler.send(
|
1162
|
+
self.handler.send("UnsupportedFeature", {
|
1152
1163
|
featureId: _util.UNSUPPORTED_FEATURES.unknown
|
1153
1164
|
});
|
1154
|
-
(0, _util.warn)(
|
1165
|
+
(0, _util.warn)(`getOperatorList - ignoring XObject: "${reason}".`);
|
1155
1166
|
return;
|
1156
1167
|
}
|
1157
1168
|
|
@@ -1189,20 +1200,30 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1189
1200
|
}
|
1190
1201
|
|
1191
1202
|
next(self.buildPaintImageXObject({
|
1192
|
-
resources
|
1203
|
+
resources,
|
1193
1204
|
image: args[0],
|
1194
1205
|
isInline: true,
|
1195
|
-
operatorList
|
1196
|
-
cacheKey
|
1197
|
-
imageCache
|
1206
|
+
operatorList,
|
1207
|
+
cacheKey,
|
1208
|
+
imageCache
|
1198
1209
|
}));
|
1199
1210
|
return;
|
1200
1211
|
|
1201
1212
|
case _util.OPS.showText:
|
1213
|
+
if (!stateManager.state.font) {
|
1214
|
+
self.ensureStateFont(stateManager.state);
|
1215
|
+
continue;
|
1216
|
+
}
|
1217
|
+
|
1202
1218
|
args[0] = self.handleText(args[0], stateManager.state);
|
1203
1219
|
break;
|
1204
1220
|
|
1205
1221
|
case _util.OPS.showSpacedText:
|
1222
|
+
if (!stateManager.state.font) {
|
1223
|
+
self.ensureStateFont(stateManager.state);
|
1224
|
+
continue;
|
1225
|
+
}
|
1226
|
+
|
1206
1227
|
var arr = args[0];
|
1207
1228
|
var combinedGlyphs = [];
|
1208
1229
|
var arrLength = arr.length;
|
@@ -1223,12 +1244,22 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1223
1244
|
break;
|
1224
1245
|
|
1225
1246
|
case _util.OPS.nextLineShowText:
|
1247
|
+
if (!stateManager.state.font) {
|
1248
|
+
self.ensureStateFont(stateManager.state);
|
1249
|
+
continue;
|
1250
|
+
}
|
1251
|
+
|
1226
1252
|
operatorList.addOp(_util.OPS.nextLine);
|
1227
1253
|
args[0] = self.handleText(args[0], stateManager.state);
|
1228
1254
|
fn = _util.OPS.showText;
|
1229
1255
|
break;
|
1230
1256
|
|
1231
1257
|
case _util.OPS.nextLineSetSpacingShowText:
|
1258
|
+
if (!stateManager.state.font) {
|
1259
|
+
self.ensureStateFont(stateManager.state);
|
1260
|
+
continue;
|
1261
|
+
}
|
1262
|
+
|
1232
1263
|
operatorList.addOp(_util.OPS.nextLine);
|
1233
1264
|
operatorList.addOp(_util.OPS.setWordSpacing, [args.shift()]);
|
1234
1265
|
operatorList.addOp(_util.OPS.setCharSpacing, [args.shift()]);
|
@@ -1241,12 +1272,26 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1241
1272
|
break;
|
1242
1273
|
|
1243
1274
|
case _util.OPS.setFillColorSpace:
|
1244
|
-
|
1245
|
-
|
1275
|
+
next(self.parseColorSpace({
|
1276
|
+
cs: args[0],
|
1277
|
+
resources
|
1278
|
+
}).then(function (colorSpace) {
|
1279
|
+
if (colorSpace) {
|
1280
|
+
stateManager.state.fillColorSpace = colorSpace;
|
1281
|
+
}
|
1282
|
+
}));
|
1283
|
+
return;
|
1246
1284
|
|
1247
1285
|
case _util.OPS.setStrokeColorSpace:
|
1248
|
-
|
1249
|
-
|
1286
|
+
next(self.parseColorSpace({
|
1287
|
+
cs: args[0],
|
1288
|
+
resources
|
1289
|
+
}).then(function (colorSpace) {
|
1290
|
+
if (colorSpace) {
|
1291
|
+
stateManager.state.strokeColorSpace = colorSpace;
|
1292
|
+
}
|
1293
|
+
}));
|
1294
|
+
return;
|
1250
1295
|
|
1251
1296
|
case _util.OPS.setFillColor:
|
1252
1297
|
cs = stateManager.state.fillColorSpace;
|
@@ -1297,7 +1342,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1297
1342
|
case _util.OPS.setFillColorN:
|
1298
1343
|
cs = stateManager.state.fillColorSpace;
|
1299
1344
|
|
1300
|
-
if (cs.name ===
|
1345
|
+
if (cs.name === "Pattern") {
|
1301
1346
|
next(self.handleColorN(operatorList, _util.OPS.setFillColorN, args, cs, patterns, resources, task));
|
1302
1347
|
return;
|
1303
1348
|
}
|
@@ -1309,7 +1354,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1309
1354
|
case _util.OPS.setStrokeColorN:
|
1310
1355
|
cs = stateManager.state.strokeColorSpace;
|
1311
1356
|
|
1312
|
-
if (cs.name ===
|
1357
|
+
if (cs.name === "Pattern") {
|
1313
1358
|
next(self.handleColorN(operatorList, _util.OPS.setStrokeColorN, args, cs, patterns, resources, task));
|
1314
1359
|
return;
|
1315
1360
|
}
|
@@ -1319,16 +1364,16 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1319
1364
|
break;
|
1320
1365
|
|
1321
1366
|
case _util.OPS.shadingFill:
|
1322
|
-
var shadingRes = resources.get(
|
1367
|
+
var shadingRes = resources.get("Shading");
|
1323
1368
|
|
1324
1369
|
if (!shadingRes) {
|
1325
|
-
throw new _util.FormatError(
|
1370
|
+
throw new _util.FormatError("No shading resource found");
|
1326
1371
|
}
|
1327
1372
|
|
1328
1373
|
var shading = shadingRes.get(args[0].name);
|
1329
1374
|
|
1330
1375
|
if (!shading) {
|
1331
|
-
throw new _util.FormatError(
|
1376
|
+
throw new _util.FormatError("No shading object found");
|
1332
1377
|
}
|
1333
1378
|
|
1334
1379
|
var shadingFill = _pattern.Pattern.parseShading(shading, null, xref, resources, self.handler, self.pdfFunctionFactory);
|
@@ -1340,7 +1385,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1340
1385
|
|
1341
1386
|
case _util.OPS.setGState:
|
1342
1387
|
var dictName = args[0];
|
1343
|
-
var extGState = resources.get(
|
1388
|
+
var extGState = resources.get("ExtGState");
|
1344
1389
|
|
1345
1390
|
if (!(0, _primitives.isDict)(extGState) || !extGState.has(dictName.name)) {
|
1346
1391
|
break;
|
@@ -1378,7 +1423,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1378
1423
|
}
|
1379
1424
|
|
1380
1425
|
if (i < ii) {
|
1381
|
-
(0, _util.warn)(
|
1426
|
+
(0, _util.warn)("getOperatorList - ignoring operator: " + fn);
|
1382
1427
|
continue;
|
1383
1428
|
}
|
1384
1429
|
}
|
@@ -1395,17 +1440,16 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1395
1440
|
|
1396
1441
|
closePendingRestoreOPS();
|
1397
1442
|
resolve();
|
1398
|
-
})
|
1443
|
+
}).catch(reason => {
|
1399
1444
|
if (reason instanceof _util.AbortException) {
|
1400
1445
|
return;
|
1401
1446
|
}
|
1402
1447
|
|
1403
|
-
if (
|
1404
|
-
|
1448
|
+
if (this.options.ignoreErrors) {
|
1449
|
+
this.handler.send("UnsupportedFeature", {
|
1405
1450
|
featureId: _util.UNSUPPORTED_FEATURES.unknown
|
1406
1451
|
});
|
1407
|
-
|
1408
|
-
(0, _util.warn)("getOperatorList - ignoring errors during \"".concat(task.name, "\" ") + "task: \"".concat(reason, "\"."));
|
1452
|
+
(0, _util.warn)(`getOperatorList - ignoring errors during "${task.name}" ` + `task: "${reason}".`);
|
1409
1453
|
closePendingRestoreOPS();
|
1410
1454
|
return;
|
1411
1455
|
}
|
@@ -1413,21 +1457,17 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1413
1457
|
throw reason;
|
1414
1458
|
});
|
1415
1459
|
},
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
combineTextItems = _ref6$combineTextItem === void 0 ? false : _ref6$combineTextItem,
|
1428
|
-
sink = _ref6.sink,
|
1429
|
-
_ref6$seenStyles = _ref6.seenStyles,
|
1430
|
-
seenStyles = _ref6$seenStyles === void 0 ? Object.create(null) : _ref6$seenStyles;
|
1460
|
+
|
1461
|
+
getTextContent({
|
1462
|
+
stream,
|
1463
|
+
task,
|
1464
|
+
resources,
|
1465
|
+
stateManager = null,
|
1466
|
+
normalizeWhitespace = false,
|
1467
|
+
combineTextItems = false,
|
1468
|
+
sink,
|
1469
|
+
seenStyles = Object.create(null)
|
1470
|
+
}) {
|
1431
1471
|
resources = resources || _primitives.Dict.empty;
|
1432
1472
|
stateManager = stateManager || new StateManager(new TextState());
|
1433
1473
|
var WhitespaceRegexp = /\s/g;
|
@@ -1483,7 +1523,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1483
1523
|
var tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise];
|
1484
1524
|
|
1485
1525
|
if (font.isType3Font && textState.fontSize <= 1 && !(0, _util.isArrayEqual)(textState.fontMatrix, _util.FONT_IDENTITY_MATRIX)) {
|
1486
|
-
|
1526
|
+
const glyphHeight = font.bbox[3] - font.bbox[1];
|
1487
1527
|
|
1488
1528
|
if (glyphHeight > 0) {
|
1489
1529
|
tsm[3] *= glyphHeight * textState.fontMatrix[3];
|
@@ -1538,15 +1578,15 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1538
1578
|
ii = str.length,
|
1539
1579
|
code;
|
1540
1580
|
|
1541
|
-
while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <=
|
1581
|
+
while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7f) {
|
1542
1582
|
i++;
|
1543
1583
|
}
|
1544
1584
|
|
1545
|
-
return i < ii ? str.replace(WhitespaceRegexp,
|
1585
|
+
return i < ii ? str.replace(WhitespaceRegexp, " ") : str;
|
1546
1586
|
}
|
1547
1587
|
|
1548
1588
|
function runBidiTransform(textChunk) {
|
1549
|
-
var str = textChunk.str.join(
|
1589
|
+
var str = textChunk.str.join("");
|
1550
1590
|
var bidiResult = (0, _bidi.bidi)(str, -1, textChunk.vertical);
|
1551
1591
|
return {
|
1552
1592
|
str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
|
@@ -1635,14 +1675,14 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1635
1675
|
}
|
1636
1676
|
|
1637
1677
|
if (width < textContentItem.fakeMultiSpaceMin) {
|
1638
|
-
strBuf.push(
|
1678
|
+
strBuf.push(" ");
|
1639
1679
|
return;
|
1640
1680
|
}
|
1641
1681
|
|
1642
1682
|
var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
|
1643
1683
|
|
1644
1684
|
while (fakeSpaces-- > 0) {
|
1645
|
-
strBuf.push(
|
1685
|
+
strBuf.push(" ");
|
1646
1686
|
}
|
1647
1687
|
}
|
1648
1688
|
|
@@ -1663,7 +1703,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1663
1703
|
}
|
1664
1704
|
|
1665
1705
|
function enqueueChunk() {
|
1666
|
-
|
1706
|
+
const length = textContent.items.length;
|
1667
1707
|
|
1668
1708
|
if (length > 0) {
|
1669
1709
|
sink.enqueue(textContent, length);
|
@@ -1674,7 +1714,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1674
1714
|
|
1675
1715
|
var timeSlotManager = new TimeSlotManager();
|
1676
1716
|
return new Promise(function promiseBody(resolve, reject) {
|
1677
|
-
|
1717
|
+
const next = function (promise) {
|
1678
1718
|
enqueueChunk();
|
1679
1719
|
Promise.all([promise, sink.ready]).then(function () {
|
1680
1720
|
try {
|
@@ -1796,11 +1836,16 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1796
1836
|
break;
|
1797
1837
|
|
1798
1838
|
case _util.OPS.showSpacedText:
|
1839
|
+
if (!stateManager.state.font) {
|
1840
|
+
self.ensureStateFont(stateManager.state);
|
1841
|
+
continue;
|
1842
|
+
}
|
1843
|
+
|
1799
1844
|
var items = args[0];
|
1800
1845
|
var offset;
|
1801
1846
|
|
1802
1847
|
for (var j = 0, jj = items.length; j < jj; j++) {
|
1803
|
-
if (typeof items[j] ===
|
1848
|
+
if (typeof items[j] === "string") {
|
1804
1849
|
buildTextContentItem(items[j]);
|
1805
1850
|
} else if ((0, _util.isNum)(items[j])) {
|
1806
1851
|
ensureTextContentItem();
|
@@ -1837,16 +1882,31 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1837
1882
|
break;
|
1838
1883
|
|
1839
1884
|
case _util.OPS.showText:
|
1885
|
+
if (!stateManager.state.font) {
|
1886
|
+
self.ensureStateFont(stateManager.state);
|
1887
|
+
continue;
|
1888
|
+
}
|
1889
|
+
|
1840
1890
|
buildTextContentItem(args[0]);
|
1841
1891
|
break;
|
1842
1892
|
|
1843
1893
|
case _util.OPS.nextLineShowText:
|
1894
|
+
if (!stateManager.state.font) {
|
1895
|
+
self.ensureStateFont(stateManager.state);
|
1896
|
+
continue;
|
1897
|
+
}
|
1898
|
+
|
1844
1899
|
flushTextContentItem();
|
1845
1900
|
textState.carriageReturn();
|
1846
1901
|
buildTextContentItem(args[0]);
|
1847
1902
|
break;
|
1848
1903
|
|
1849
1904
|
case _util.OPS.nextLineSetSpacingShowText:
|
1905
|
+
if (!stateManager.state.font) {
|
1906
|
+
self.ensureStateFont(stateManager.state);
|
1907
|
+
continue;
|
1908
|
+
}
|
1909
|
+
|
1850
1910
|
flushTextContentItem();
|
1851
1911
|
textState.wordSpacing = args[0];
|
1852
1912
|
textState.charSpacing = args[1];
|
@@ -1858,7 +1918,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1858
1918
|
flushTextContentItem();
|
1859
1919
|
|
1860
1920
|
if (!xobjs) {
|
1861
|
-
xobjs = resources.get(
|
1921
|
+
xobjs = resources.get("XObject") || _primitives.Dict.empty;
|
1862
1922
|
}
|
1863
1923
|
|
1864
1924
|
var name = args[0].name;
|
@@ -1869,10 +1929,10 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1869
1929
|
|
1870
1930
|
next(new Promise(function (resolveXObject, rejectXObject) {
|
1871
1931
|
if (!name) {
|
1872
|
-
throw new _util.FormatError(
|
1932
|
+
throw new _util.FormatError("XObject must be referred to by name.");
|
1873
1933
|
}
|
1874
1934
|
|
1875
|
-
|
1935
|
+
const xobj = xobjs.get(name);
|
1876
1936
|
|
1877
1937
|
if (!xobj) {
|
1878
1938
|
resolveXObject();
|
@@ -1880,33 +1940,34 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1880
1940
|
}
|
1881
1941
|
|
1882
1942
|
if (!(0, _primitives.isStream)(xobj)) {
|
1883
|
-
throw new _util.FormatError(
|
1943
|
+
throw new _util.FormatError("XObject should be a stream");
|
1884
1944
|
}
|
1885
1945
|
|
1886
|
-
|
1946
|
+
const type = xobj.dict.get("Subtype");
|
1887
1947
|
|
1888
1948
|
if (!(0, _primitives.isName)(type)) {
|
1889
|
-
throw new _util.FormatError(
|
1949
|
+
throw new _util.FormatError("XObject should have a Name subtype");
|
1890
1950
|
}
|
1891
1951
|
|
1892
|
-
if (type.name !==
|
1952
|
+
if (type.name !== "Form") {
|
1893
1953
|
skipEmptyXObjs[name] = true;
|
1894
1954
|
resolveXObject();
|
1895
1955
|
return;
|
1896
1956
|
}
|
1897
1957
|
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1958
|
+
const currentState = stateManager.state.clone();
|
1959
|
+
const xObjStateManager = new StateManager(currentState);
|
1960
|
+
const matrix = xobj.dict.getArray("Matrix");
|
1901
1961
|
|
1902
1962
|
if (Array.isArray(matrix) && matrix.length === 6) {
|
1903
1963
|
xObjStateManager.transform(matrix);
|
1904
1964
|
}
|
1905
1965
|
|
1906
1966
|
enqueueChunk();
|
1907
|
-
|
1967
|
+
const sinkWrapper = {
|
1908
1968
|
enqueueInvoked: false,
|
1909
|
-
|
1969
|
+
|
1970
|
+
enqueue(chunk, size) {
|
1910
1971
|
this.enqueueInvoked = true;
|
1911
1972
|
sink.enqueue(chunk, size);
|
1912
1973
|
},
|
@@ -1922,13 +1983,13 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1922
1983
|
};
|
1923
1984
|
self.getTextContent({
|
1924
1985
|
stream: xobj,
|
1925
|
-
task
|
1926
|
-
resources: xobj.dict.get(
|
1986
|
+
task,
|
1987
|
+
resources: xobj.dict.get("Resources") || resources,
|
1927
1988
|
stateManager: xObjStateManager,
|
1928
|
-
normalizeWhitespace
|
1929
|
-
combineTextItems
|
1989
|
+
normalizeWhitespace,
|
1990
|
+
combineTextItems,
|
1930
1991
|
sink: sinkWrapper,
|
1931
|
-
seenStyles
|
1992
|
+
seenStyles
|
1932
1993
|
}).then(function () {
|
1933
1994
|
if (!sinkWrapper.enqueueInvoked) {
|
1934
1995
|
skipEmptyXObjs[name] = true;
|
@@ -1936,13 +1997,13 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1936
1997
|
|
1937
1998
|
resolveXObject();
|
1938
1999
|
}, rejectXObject);
|
1939
|
-
})
|
2000
|
+
}).catch(function (reason) {
|
1940
2001
|
if (reason instanceof _util.AbortException) {
|
1941
2002
|
return;
|
1942
2003
|
}
|
1943
2004
|
|
1944
2005
|
if (self.options.ignoreErrors) {
|
1945
|
-
(0, _util.warn)(
|
2006
|
+
(0, _util.warn)(`getTextContent - ignoring XObject: "${reason}".`);
|
1946
2007
|
return;
|
1947
2008
|
}
|
1948
2009
|
|
@@ -1953,7 +2014,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1953
2014
|
case _util.OPS.setGState:
|
1954
2015
|
flushTextContentItem();
|
1955
2016
|
var dictName = args[0];
|
1956
|
-
var extGState = resources.get(
|
2017
|
+
var extGState = resources.get("ExtGState");
|
1957
2018
|
|
1958
2019
|
if (!(0, _primitives.isDict)(extGState) || !(0, _primitives.isName)(dictName)) {
|
1959
2020
|
break;
|
@@ -1965,7 +2026,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1965
2026
|
break;
|
1966
2027
|
}
|
1967
2028
|
|
1968
|
-
var gStateFont = gState.get(
|
2029
|
+
var gStateFont = gState.get("Font");
|
1969
2030
|
|
1970
2031
|
if (gStateFont) {
|
1971
2032
|
textState.fontName = null;
|
@@ -1991,13 +2052,13 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1991
2052
|
flushTextContentItem();
|
1992
2053
|
enqueueChunk();
|
1993
2054
|
resolve();
|
1994
|
-
})
|
2055
|
+
}).catch(reason => {
|
1995
2056
|
if (reason instanceof _util.AbortException) {
|
1996
2057
|
return;
|
1997
2058
|
}
|
1998
2059
|
|
1999
|
-
if (
|
2000
|
-
(0, _util.warn)(
|
2060
|
+
if (this.options.ignoreErrors) {
|
2061
|
+
(0, _util.warn)(`getTextContent - ignoring errors during "${task.name}" ` + `task: "${reason}".`);
|
2001
2062
|
flushTextContentItem();
|
2002
2063
|
enqueueChunk();
|
2003
2064
|
return;
|
@@ -2006,26 +2067,25 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2006
2067
|
throw reason;
|
2007
2068
|
});
|
2008
2069
|
},
|
2009
|
-
extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) {
|
2010
|
-
var _this9 = this;
|
2011
2070
|
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2071
|
+
extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) {
|
2072
|
+
const xref = this.xref;
|
2073
|
+
let cidToGidBytes;
|
2074
|
+
var toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
|
2015
2075
|
var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
|
2016
2076
|
|
2017
2077
|
if (properties.composite) {
|
2018
|
-
var cidSystemInfo = dict.get(
|
2078
|
+
var cidSystemInfo = dict.get("CIDSystemInfo");
|
2019
2079
|
|
2020
2080
|
if ((0, _primitives.isDict)(cidSystemInfo)) {
|
2021
2081
|
properties.cidSystemInfo = {
|
2022
|
-
registry: (0, _util.stringToPDFString)(cidSystemInfo.get(
|
2023
|
-
ordering: (0, _util.stringToPDFString)(cidSystemInfo.get(
|
2024
|
-
supplement: cidSystemInfo.get(
|
2082
|
+
registry: (0, _util.stringToPDFString)(cidSystemInfo.get("Registry")),
|
2083
|
+
ordering: (0, _util.stringToPDFString)(cidSystemInfo.get("Ordering")),
|
2084
|
+
supplement: cidSystemInfo.get("Supplement")
|
2025
2085
|
};
|
2026
2086
|
}
|
2027
2087
|
|
2028
|
-
var cidToGidMap = dict.get(
|
2088
|
+
var cidToGidMap = dict.get("CIDToGIDMap");
|
2029
2089
|
|
2030
2090
|
if ((0, _primitives.isStream)(cidToGidMap)) {
|
2031
2091
|
cidToGidBytes = cidToGidMap.getBytes();
|
@@ -2036,15 +2096,15 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2036
2096
|
var baseEncodingName = null;
|
2037
2097
|
var encoding;
|
2038
2098
|
|
2039
|
-
if (dict.has(
|
2040
|
-
encoding = dict.get(
|
2099
|
+
if (dict.has("Encoding")) {
|
2100
|
+
encoding = dict.get("Encoding");
|
2041
2101
|
|
2042
2102
|
if ((0, _primitives.isDict)(encoding)) {
|
2043
|
-
baseEncodingName = encoding.get(
|
2103
|
+
baseEncodingName = encoding.get("BaseEncoding");
|
2044
2104
|
baseEncodingName = (0, _primitives.isName)(baseEncodingName) ? baseEncodingName.name : null;
|
2045
2105
|
|
2046
|
-
if (encoding.has(
|
2047
|
-
var diffEncoding = encoding.get(
|
2106
|
+
if (encoding.has("Differences")) {
|
2107
|
+
var diffEncoding = encoding.get("Differences");
|
2048
2108
|
var index = 0;
|
2049
2109
|
|
2050
2110
|
for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
|
@@ -2055,17 +2115,17 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2055
2115
|
} else if ((0, _primitives.isName)(data)) {
|
2056
2116
|
differences[index++] = data.name;
|
2057
2117
|
} else {
|
2058
|
-
throw new _util.FormatError(
|
2118
|
+
throw new _util.FormatError(`Invalid entry in 'Differences' array: ${data}`);
|
2059
2119
|
}
|
2060
2120
|
}
|
2061
2121
|
}
|
2062
2122
|
} else if ((0, _primitives.isName)(encoding)) {
|
2063
2123
|
baseEncodingName = encoding.name;
|
2064
2124
|
} else {
|
2065
|
-
throw new _util.FormatError(
|
2125
|
+
throw new _util.FormatError("Encoding is not a Name nor a Dict");
|
2066
2126
|
}
|
2067
2127
|
|
2068
|
-
if (baseEncodingName !==
|
2128
|
+
if (baseEncodingName !== "MacRomanEncoding" && baseEncodingName !== "MacExpertEncoding" && baseEncodingName !== "WinAnsiEncoding") {
|
2069
2129
|
baseEncodingName = null;
|
2070
2130
|
}
|
2071
2131
|
}
|
@@ -2077,7 +2137,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2077
2137
|
var isNonsymbolicFont = !!(properties.flags & _fonts.FontFlags.Nonsymbolic);
|
2078
2138
|
encoding = _encodings.StandardEncoding;
|
2079
2139
|
|
2080
|
-
if (properties.type ===
|
2140
|
+
if (properties.type === "TrueType" && !isNonsymbolicFont) {
|
2081
2141
|
encoding = _encodings.WinAnsiEncoding;
|
2082
2142
|
}
|
2083
2143
|
|
@@ -2087,7 +2147,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2087
2147
|
if (!properties.file) {
|
2088
2148
|
if (/Symbol/i.test(properties.name)) {
|
2089
2149
|
encoding = _encodings.SymbolSetEncoding;
|
2090
|
-
} else if (/Dingbats/i.test(properties.name)) {
|
2150
|
+
} else if (/Dingbats|Wingdings/i.test(properties.name)) {
|
2091
2151
|
encoding = _encodings.ZapfDingbatsEncoding;
|
2092
2152
|
}
|
2093
2153
|
}
|
@@ -2100,73 +2160,83 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2100
2160
|
properties.baseEncodingName = baseEncodingName;
|
2101
2161
|
properties.hasEncoding = !!baseEncodingName || differences.length > 0;
|
2102
2162
|
properties.dict = dict;
|
2103
|
-
return toUnicodePromise.then(
|
2163
|
+
return toUnicodePromise.then(toUnicode => {
|
2104
2164
|
properties.toUnicode = toUnicode;
|
2105
|
-
return
|
2106
|
-
}).then(
|
2165
|
+
return this.buildToUnicode(properties);
|
2166
|
+
}).then(toUnicode => {
|
2107
2167
|
properties.toUnicode = toUnicode;
|
2108
2168
|
|
2109
2169
|
if (cidToGidBytes) {
|
2110
|
-
properties.cidToGidMap =
|
2170
|
+
properties.cidToGidMap = this.readCidToGidMap(cidToGidBytes, toUnicode);
|
2111
2171
|
}
|
2112
2172
|
|
2113
2173
|
return properties;
|
2114
2174
|
});
|
2115
2175
|
},
|
2116
|
-
_buildSimpleFontToUnicode: function _buildSimpleFontToUnicode(properties) {
|
2117
|
-
(0, _util.assert)(!properties.composite, 'Must be a simple font.');
|
2118
|
-
var toUnicode = [],
|
2119
|
-
charcode,
|
2120
|
-
glyphName;
|
2121
|
-
var encoding = properties.defaultEncoding.slice();
|
2122
|
-
var baseEncodingName = properties.baseEncodingName;
|
2123
|
-
var differences = properties.differences;
|
2124
2176
|
|
2125
|
-
|
2126
|
-
|
2177
|
+
_buildSimpleFontToUnicode(properties, forceGlyphs = false) {
|
2178
|
+
(0, _util.assert)(!properties.composite, "Must be a simple font.");
|
2179
|
+
const toUnicode = [];
|
2180
|
+
const encoding = properties.defaultEncoding.slice();
|
2181
|
+
const baseEncodingName = properties.baseEncodingName;
|
2182
|
+
const differences = properties.differences;
|
2183
|
+
|
2184
|
+
for (const charcode in differences) {
|
2185
|
+
const glyphName = differences[charcode];
|
2127
2186
|
|
2128
|
-
if (glyphName ===
|
2187
|
+
if (glyphName === ".notdef") {
|
2129
2188
|
continue;
|
2130
2189
|
}
|
2131
2190
|
|
2132
2191
|
encoding[charcode] = glyphName;
|
2133
2192
|
}
|
2134
2193
|
|
2135
|
-
|
2194
|
+
const glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
|
2136
2195
|
|
2137
|
-
for (charcode in encoding) {
|
2138
|
-
glyphName = encoding[charcode];
|
2196
|
+
for (const charcode in encoding) {
|
2197
|
+
let glyphName = encoding[charcode];
|
2139
2198
|
|
2140
|
-
if (glyphName ===
|
2199
|
+
if (glyphName === "") {
|
2141
2200
|
continue;
|
2142
2201
|
} else if (glyphsUnicodeMap[glyphName] === undefined) {
|
2143
|
-
|
2202
|
+
let code = 0;
|
2144
2203
|
|
2145
2204
|
switch (glyphName[0]) {
|
2146
|
-
case
|
2205
|
+
case "G":
|
2147
2206
|
if (glyphName.length === 3) {
|
2148
2207
|
code = parseInt(glyphName.substring(1), 16);
|
2149
2208
|
}
|
2150
2209
|
|
2151
2210
|
break;
|
2152
2211
|
|
2153
|
-
case
|
2212
|
+
case "g":
|
2154
2213
|
if (glyphName.length === 5) {
|
2155
2214
|
code = parseInt(glyphName.substring(1), 16);
|
2156
2215
|
}
|
2157
2216
|
|
2158
2217
|
break;
|
2159
2218
|
|
2160
|
-
case
|
2161
|
-
case
|
2162
|
-
if (glyphName.length >= 3) {
|
2163
|
-
|
2219
|
+
case "C":
|
2220
|
+
case "c":
|
2221
|
+
if (glyphName.length >= 3 && glyphName.length <= 4) {
|
2222
|
+
const codeStr = glyphName.substring(1);
|
2223
|
+
|
2224
|
+
if (forceGlyphs) {
|
2225
|
+
code = parseInt(codeStr, 16);
|
2226
|
+
break;
|
2227
|
+
}
|
2228
|
+
|
2229
|
+
code = +codeStr;
|
2230
|
+
|
2231
|
+
if (Number.isNaN(code) && Number.isInteger(parseInt(codeStr, 16))) {
|
2232
|
+
return this._buildSimpleFontToUnicode(properties, true);
|
2233
|
+
}
|
2164
2234
|
}
|
2165
2235
|
|
2166
2236
|
break;
|
2167
2237
|
|
2168
2238
|
default:
|
2169
|
-
|
2239
|
+
const unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
|
2170
2240
|
|
2171
2241
|
if (unicode !== -1) {
|
2172
2242
|
code = unicode;
|
@@ -2174,9 +2244,9 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2174
2244
|
|
2175
2245
|
}
|
2176
2246
|
|
2177
|
-
if (code) {
|
2247
|
+
if (code > 0 && Number.isInteger(code)) {
|
2178
2248
|
if (baseEncodingName && code === +charcode) {
|
2179
|
-
|
2249
|
+
const baseEncoding = (0, _encodings.getEncoding)(baseEncodingName);
|
2180
2250
|
|
2181
2251
|
if (baseEncoding && (glyphName = baseEncoding[charcode])) {
|
2182
2252
|
toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
|
@@ -2195,7 +2265,8 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2195
2265
|
|
2196
2266
|
return new _fonts.ToUnicodeMap(toUnicode);
|
2197
2267
|
},
|
2198
|
-
|
2268
|
+
|
2269
|
+
buildToUnicode(properties) {
|
2199
2270
|
properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
|
2200
2271
|
|
2201
2272
|
if (properties.hasIncludedToUnicodeMap) {
|
@@ -2210,25 +2281,25 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2210
2281
|
return Promise.resolve(this._buildSimpleFontToUnicode(properties));
|
2211
2282
|
}
|
2212
2283
|
|
2213
|
-
if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof _cmap.IdentityCMap) || properties.cidSystemInfo.registry ===
|
2214
|
-
|
2215
|
-
|
2284
|
+
if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof _cmap.IdentityCMap) || properties.cidSystemInfo.registry === "Adobe" && (properties.cidSystemInfo.ordering === "GB1" || properties.cidSystemInfo.ordering === "CNS1" || properties.cidSystemInfo.ordering === "Japan1" || properties.cidSystemInfo.ordering === "Korea1"))) {
|
2285
|
+
const registry = properties.cidSystemInfo.registry;
|
2286
|
+
const ordering = properties.cidSystemInfo.ordering;
|
2216
2287
|
|
2217
|
-
|
2288
|
+
const ucs2CMapName = _primitives.Name.get(registry + "-" + ordering + "-UCS2");
|
2218
2289
|
|
2219
2290
|
return _cmap.CMapFactory.create({
|
2220
2291
|
encoding: ucs2CMapName,
|
2221
2292
|
fetchBuiltInCMap: this.fetchBuiltInCMap,
|
2222
2293
|
useCMap: null
|
2223
2294
|
}).then(function (ucs2CMap) {
|
2224
|
-
|
2225
|
-
|
2295
|
+
const cMap = properties.cMap;
|
2296
|
+
const toUnicode = [];
|
2226
2297
|
cMap.forEach(function (charcode, cid) {
|
2227
2298
|
if (cid > 0xffff) {
|
2228
|
-
throw new _util.FormatError(
|
2299
|
+
throw new _util.FormatError("Max size of CID is 65,535");
|
2229
2300
|
}
|
2230
2301
|
|
2231
|
-
|
2302
|
+
const ucs2 = ucs2CMap.lookup(cid);
|
2232
2303
|
|
2233
2304
|
if (ucs2) {
|
2234
2305
|
toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
|
@@ -2240,6 +2311,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2240
2311
|
|
2241
2312
|
return Promise.resolve(new _fonts.IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
|
2242
2313
|
},
|
2314
|
+
|
2243
2315
|
readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
|
2244
2316
|
var cmapObj = toUnicode;
|
2245
2317
|
|
@@ -2250,7 +2322,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2250
2322
|
useCMap: null
|
2251
2323
|
}).then(function (cmap) {
|
2252
2324
|
if (cmap instanceof _cmap.IdentityCMap) {
|
2253
|
-
return new _fonts.IdentityToUnicodeMap(0,
|
2325
|
+
return new _fonts.IdentityToUnicodeMap(0, 0xffff);
|
2254
2326
|
}
|
2255
2327
|
|
2256
2328
|
return new _fonts.ToUnicodeMap(cmap.getMap());
|
@@ -2262,7 +2334,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2262
2334
|
useCMap: null
|
2263
2335
|
}).then(function (cmap) {
|
2264
2336
|
if (cmap instanceof _cmap.IdentityCMap) {
|
2265
|
-
return new _fonts.IdentityToUnicodeMap(0,
|
2337
|
+
return new _fonts.IdentityToUnicodeMap(0, 0xffff);
|
2266
2338
|
}
|
2267
2339
|
|
2268
2340
|
var map = new Array(cmap.length);
|
@@ -2272,7 +2344,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2272
2344
|
for (var k = 0; k < token.length; k += 2) {
|
2273
2345
|
var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
|
2274
2346
|
|
2275
|
-
if ((w1 &
|
2347
|
+
if ((w1 & 0xf800) !== 0xd800) {
|
2276
2348
|
str.push(w1);
|
2277
2349
|
continue;
|
2278
2350
|
}
|
@@ -2285,17 +2357,32 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2285
2357
|
map[charCode] = String.fromCodePoint.apply(String, str);
|
2286
2358
|
});
|
2287
2359
|
return new _fonts.ToUnicodeMap(map);
|
2360
|
+
}, reason => {
|
2361
|
+
if (reason instanceof _util.AbortException) {
|
2362
|
+
return null;
|
2363
|
+
}
|
2364
|
+
|
2365
|
+
if (this.options.ignoreErrors) {
|
2366
|
+
this.handler.send("UnsupportedFeature", {
|
2367
|
+
featureId: _util.UNSUPPORTED_FEATURES.font
|
2368
|
+
});
|
2369
|
+
(0, _util.warn)(`readToUnicode - ignoring ToUnicode data: "${reason}".`);
|
2370
|
+
return null;
|
2371
|
+
}
|
2372
|
+
|
2373
|
+
throw reason;
|
2288
2374
|
});
|
2289
2375
|
}
|
2290
2376
|
|
2291
2377
|
return Promise.resolve(null);
|
2292
2378
|
},
|
2293
|
-
|
2379
|
+
|
2380
|
+
readCidToGidMap(glyphsData, toUnicode) {
|
2294
2381
|
var result = [];
|
2295
2382
|
|
2296
2383
|
for (var j = 0, jj = glyphsData.length; j < jj; j++) {
|
2297
2384
|
var glyphID = glyphsData[j++] << 8 | glyphsData[j];
|
2298
|
-
|
2385
|
+
const code = j >> 1;
|
2299
2386
|
|
2300
2387
|
if (glyphID === 0 && !toUnicode.has(code)) {
|
2301
2388
|
continue;
|
@@ -2306,6 +2393,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2306
2393
|
|
2307
2394
|
return result;
|
2308
2395
|
},
|
2396
|
+
|
2309
2397
|
extractWidths: function PartialEvaluator_extractWidths(dict, descriptor, properties) {
|
2310
2398
|
var xref = this.xref;
|
2311
2399
|
var glyphsWidths = [];
|
@@ -2315,8 +2403,8 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2315
2403
|
var i, ii, j, jj, start, code, widths;
|
2316
2404
|
|
2317
2405
|
if (properties.composite) {
|
2318
|
-
defaultWidth = dict.has(
|
2319
|
-
widths = dict.get(
|
2406
|
+
defaultWidth = dict.has("DW") ? dict.get("DW") : 1000;
|
2407
|
+
widths = dict.get("W");
|
2320
2408
|
|
2321
2409
|
if (widths) {
|
2322
2410
|
for (i = 0, ii = widths.length; i < ii; i++) {
|
@@ -2338,9 +2426,9 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2338
2426
|
}
|
2339
2427
|
|
2340
2428
|
if (properties.vertical) {
|
2341
|
-
var vmetrics = dict.getArray(
|
2429
|
+
var vmetrics = dict.getArray("DW2") || [880, -1000];
|
2342
2430
|
defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
|
2343
|
-
vmetrics = dict.get(
|
2431
|
+
vmetrics = dict.get("W2");
|
2344
2432
|
|
2345
2433
|
if (vmetrics) {
|
2346
2434
|
for (i = 0, ii = vmetrics.length; i < ii; i++) {
|
@@ -2363,7 +2451,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2363
2451
|
}
|
2364
2452
|
} else {
|
2365
2453
|
var firstChar = properties.firstChar;
|
2366
|
-
widths = dict.get(
|
2454
|
+
widths = dict.get("Widths");
|
2367
2455
|
|
2368
2456
|
if (widths) {
|
2369
2457
|
j = firstChar;
|
@@ -2372,9 +2460,9 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2372
2460
|
glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
|
2373
2461
|
}
|
2374
2462
|
|
2375
|
-
defaultWidth = parseFloat(descriptor.get(
|
2463
|
+
defaultWidth = parseFloat(descriptor.get("MissingWidth")) || 0;
|
2376
2464
|
} else {
|
2377
|
-
var baseFontName = dict.get(
|
2465
|
+
var baseFontName = dict.get("BaseFont");
|
2378
2466
|
|
2379
2467
|
if ((0, _primitives.isName)(baseFontName)) {
|
2380
2468
|
var metrics = this.getBaseFontMetrics(baseFontName.name);
|
@@ -2415,7 +2503,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2415
2503
|
properties.vmetrics = glyphsVMetrics;
|
2416
2504
|
},
|
2417
2505
|
isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
|
2418
|
-
var fontNameWoStyle = baseFontName.split(
|
2506
|
+
var fontNameWoStyle = baseFontName.split("-")[0];
|
2419
2507
|
return fontNameWoStyle in (0, _standard_fonts.getSerifFonts)() || fontNameWoStyle.search(/serif/gi) !== -1;
|
2420
2508
|
},
|
2421
2509
|
getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
|
@@ -2428,9 +2516,9 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2428
2516
|
|
2429
2517
|
if (!(lookupName in Metrics)) {
|
2430
2518
|
if (this.isSerifFont(name)) {
|
2431
|
-
lookupName =
|
2519
|
+
lookupName = "Times-Roman";
|
2432
2520
|
} else {
|
2433
|
-
lookupName =
|
2521
|
+
lookupName = "Helvetica";
|
2434
2522
|
}
|
2435
2523
|
}
|
2436
2524
|
|
@@ -2444,9 +2532,9 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2444
2532
|
}
|
2445
2533
|
|
2446
2534
|
return {
|
2447
|
-
defaultWidth
|
2448
|
-
monospace
|
2449
|
-
widths
|
2535
|
+
defaultWidth,
|
2536
|
+
monospace,
|
2537
|
+
widths
|
2450
2538
|
};
|
2451
2539
|
},
|
2452
2540
|
buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
|
@@ -2470,37 +2558,37 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2470
2558
|
},
|
2471
2559
|
preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict) {
|
2472
2560
|
var baseDict = dict;
|
2473
|
-
var type = dict.get(
|
2561
|
+
var type = dict.get("Subtype");
|
2474
2562
|
|
2475
2563
|
if (!(0, _primitives.isName)(type)) {
|
2476
|
-
throw new _util.FormatError(
|
2564
|
+
throw new _util.FormatError("invalid font Subtype");
|
2477
2565
|
}
|
2478
2566
|
|
2479
2567
|
var composite = false;
|
2480
2568
|
var uint8array;
|
2481
2569
|
|
2482
|
-
if (type.name ===
|
2483
|
-
var df = dict.get(
|
2570
|
+
if (type.name === "Type0") {
|
2571
|
+
var df = dict.get("DescendantFonts");
|
2484
2572
|
|
2485
2573
|
if (!df) {
|
2486
|
-
throw new _util.FormatError(
|
2574
|
+
throw new _util.FormatError("Descendant fonts are not specified");
|
2487
2575
|
}
|
2488
2576
|
|
2489
2577
|
dict = Array.isArray(df) ? this.xref.fetchIfRef(df[0]) : df;
|
2490
|
-
type = dict.get(
|
2578
|
+
type = dict.get("Subtype");
|
2491
2579
|
|
2492
2580
|
if (!(0, _primitives.isName)(type)) {
|
2493
|
-
throw new _util.FormatError(
|
2581
|
+
throw new _util.FormatError("invalid font Subtype");
|
2494
2582
|
}
|
2495
2583
|
|
2496
2584
|
composite = true;
|
2497
2585
|
}
|
2498
2586
|
|
2499
|
-
var descriptor = dict.get(
|
2587
|
+
var descriptor = dict.get("FontDescriptor");
|
2500
2588
|
|
2501
2589
|
if (descriptor) {
|
2502
2590
|
var hash = new _murmurhash.MurmurHash3_64();
|
2503
|
-
var encoding = baseDict.getRaw(
|
2591
|
+
var encoding = baseDict.getRaw("Encoding");
|
2504
2592
|
|
2505
2593
|
if ((0, _primitives.isName)(encoding)) {
|
2506
2594
|
hash.update(encoding.name);
|
@@ -2535,10 +2623,10 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2535
2623
|
}
|
2536
2624
|
}
|
2537
2625
|
|
2538
|
-
|
2539
|
-
|
2540
|
-
hash.update(
|
2541
|
-
var toUnicode = dict.get(
|
2626
|
+
const firstChar = dict.get("FirstChar") || 0;
|
2627
|
+
const lastChar = dict.get("LastChar") || (composite ? 0xffff : 0xff);
|
2628
|
+
hash.update(`${firstChar}-${lastChar}`);
|
2629
|
+
var toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
|
2542
2630
|
|
2543
2631
|
if ((0, _primitives.isStream)(toUnicode)) {
|
2544
2632
|
var stream = toUnicode.str || toUnicode;
|
@@ -2548,7 +2636,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2548
2636
|
hash.update(toUnicode.name);
|
2549
2637
|
}
|
2550
2638
|
|
2551
|
-
var widths = dict.get(
|
2639
|
+
var widths = dict.get("Widths") || baseDict.get("Widths");
|
2552
2640
|
|
2553
2641
|
if (widths) {
|
2554
2642
|
uint8array = new Uint8Array(new Uint32Array(widths).buffer);
|
@@ -2557,61 +2645,72 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2557
2645
|
}
|
2558
2646
|
|
2559
2647
|
return {
|
2560
|
-
descriptor
|
2561
|
-
dict
|
2562
|
-
baseDict
|
2563
|
-
composite
|
2648
|
+
descriptor,
|
2649
|
+
dict,
|
2650
|
+
baseDict,
|
2651
|
+
composite,
|
2564
2652
|
type: type.name,
|
2565
|
-
hash: hash ? hash.hexdigest() :
|
2653
|
+
hash: hash ? hash.hexdigest() : ""
|
2566
2654
|
};
|
2567
2655
|
},
|
2568
2656
|
translateFont: function PartialEvaluator_translateFont(preEvaluatedFont) {
|
2569
|
-
var _this10 = this;
|
2570
|
-
|
2571
2657
|
var baseDict = preEvaluatedFont.baseDict;
|
2572
2658
|
var dict = preEvaluatedFont.dict;
|
2573
2659
|
var composite = preEvaluatedFont.composite;
|
2574
2660
|
var descriptor = preEvaluatedFont.descriptor;
|
2575
2661
|
var type = preEvaluatedFont.type;
|
2576
|
-
var maxCharIndex = composite ?
|
2662
|
+
var maxCharIndex = composite ? 0xffff : 0xff;
|
2577
2663
|
var properties;
|
2664
|
+
const firstChar = dict.get("FirstChar") || 0;
|
2665
|
+
const lastChar = dict.get("LastChar") || maxCharIndex;
|
2578
2666
|
|
2579
2667
|
if (!descriptor) {
|
2580
|
-
if (type ===
|
2668
|
+
if (type === "Type3") {
|
2581
2669
|
descriptor = new _primitives.Dict(null);
|
2582
|
-
descriptor.set(
|
2583
|
-
descriptor.set(
|
2670
|
+
descriptor.set("FontName", _primitives.Name.get(type));
|
2671
|
+
descriptor.set("FontBBox", dict.getArray("FontBBox") || [0, 0, 0, 0]);
|
2584
2672
|
} else {
|
2585
|
-
var baseFontName = dict.get(
|
2673
|
+
var baseFontName = dict.get("BaseFont");
|
2586
2674
|
|
2587
2675
|
if (!(0, _primitives.isName)(baseFontName)) {
|
2588
|
-
throw new _util.FormatError(
|
2676
|
+
throw new _util.FormatError("Base font is not specified");
|
2589
2677
|
}
|
2590
2678
|
|
2591
|
-
baseFontName = baseFontName.name.replace(/[,_]/g,
|
2679
|
+
baseFontName = baseFontName.name.replace(/[,_]/g, "-");
|
2592
2680
|
var metrics = this.getBaseFontMetrics(baseFontName);
|
2593
|
-
var fontNameWoStyle = baseFontName.split(
|
2681
|
+
var fontNameWoStyle = baseFontName.split("-")[0];
|
2594
2682
|
var flags = (this.isSerifFont(fontNameWoStyle) ? _fonts.FontFlags.Serif : 0) | (metrics.monospace ? _fonts.FontFlags.FixedPitch : 0) | ((0, _standard_fonts.getSymbolsFonts)()[fontNameWoStyle] ? _fonts.FontFlags.Symbolic : _fonts.FontFlags.Nonsymbolic);
|
2595
2683
|
properties = {
|
2596
|
-
type
|
2684
|
+
type,
|
2597
2685
|
name: baseFontName,
|
2598
2686
|
widths: metrics.widths,
|
2599
2687
|
defaultWidth: metrics.defaultWidth,
|
2600
|
-
flags
|
2601
|
-
firstChar
|
2602
|
-
lastChar
|
2688
|
+
flags,
|
2689
|
+
firstChar,
|
2690
|
+
lastChar
|
2603
2691
|
};
|
2604
|
-
|
2605
|
-
|
2692
|
+
const widths = dict.get("Widths");
|
2693
|
+
return this.extractDataStructures(dict, dict, properties).then(properties => {
|
2694
|
+
if (widths) {
|
2695
|
+
const glyphWidths = [];
|
2696
|
+
let j = firstChar;
|
2697
|
+
|
2698
|
+
for (let i = 0, ii = widths.length; i < ii; i++) {
|
2699
|
+
glyphWidths[j++] = this.xref.fetchIfRef(widths[i]);
|
2700
|
+
}
|
2701
|
+
|
2702
|
+
properties.widths = glyphWidths;
|
2703
|
+
} else {
|
2704
|
+
properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
|
2705
|
+
}
|
2706
|
+
|
2606
2707
|
return new _fonts.Font(baseFontName, null, properties);
|
2607
2708
|
});
|
2608
2709
|
}
|
2609
2710
|
}
|
2610
2711
|
|
2611
|
-
var
|
2612
|
-
var
|
2613
|
-
var fontName = descriptor.get('FontName');
|
2614
|
-
var baseFont = dict.get('BaseFont');
|
2712
|
+
var fontName = descriptor.get("FontName");
|
2713
|
+
var baseFont = dict.get("BaseFont");
|
2615
2714
|
|
2616
2715
|
if ((0, _util.isString)(fontName)) {
|
2617
2716
|
fontName = _primitives.Name.get(fontName);
|
@@ -2621,12 +2720,12 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2621
2720
|
baseFont = _primitives.Name.get(baseFont);
|
2622
2721
|
}
|
2623
2722
|
|
2624
|
-
if (type !==
|
2723
|
+
if (type !== "Type3") {
|
2625
2724
|
var fontNameStr = fontName && fontName.name;
|
2626
2725
|
var baseFontStr = baseFont && baseFont.name;
|
2627
2726
|
|
2628
2727
|
if (fontNameStr !== baseFontStr) {
|
2629
|
-
(0, _util.info)(
|
2728
|
+
(0, _util.info)(`The FontDescriptor\'s FontName is "${fontNameStr}" but ` + `should be the same as the Font\'s BaseFont "${baseFontStr}".`);
|
2630
2729
|
|
2631
2730
|
if (fontNameStr && baseFontStr && baseFontStr.startsWith(fontNameStr)) {
|
2632
2731
|
fontName = baseFont;
|
@@ -2637,53 +2736,53 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2637
2736
|
fontName = fontName || baseFont;
|
2638
2737
|
|
2639
2738
|
if (!(0, _primitives.isName)(fontName)) {
|
2640
|
-
throw new _util.FormatError(
|
2739
|
+
throw new _util.FormatError("invalid font name");
|
2641
2740
|
}
|
2642
2741
|
|
2643
|
-
var fontFile = descriptor.get(
|
2742
|
+
var fontFile = descriptor.get("FontFile", "FontFile2", "FontFile3");
|
2644
2743
|
|
2645
2744
|
if (fontFile) {
|
2646
2745
|
if (fontFile.dict) {
|
2647
|
-
var subtype = fontFile.dict.get(
|
2746
|
+
var subtype = fontFile.dict.get("Subtype");
|
2648
2747
|
|
2649
2748
|
if (subtype) {
|
2650
2749
|
subtype = subtype.name;
|
2651
2750
|
}
|
2652
2751
|
|
2653
|
-
var length1 = fontFile.dict.get(
|
2654
|
-
var length2 = fontFile.dict.get(
|
2655
|
-
var length3 = fontFile.dict.get(
|
2752
|
+
var length1 = fontFile.dict.get("Length1");
|
2753
|
+
var length2 = fontFile.dict.get("Length2");
|
2754
|
+
var length3 = fontFile.dict.get("Length3");
|
2656
2755
|
}
|
2657
2756
|
}
|
2658
2757
|
|
2659
2758
|
properties = {
|
2660
|
-
type
|
2759
|
+
type,
|
2661
2760
|
name: fontName.name,
|
2662
|
-
subtype
|
2761
|
+
subtype,
|
2663
2762
|
file: fontFile,
|
2664
|
-
length1
|
2665
|
-
length2
|
2666
|
-
length3
|
2763
|
+
length1,
|
2764
|
+
length2,
|
2765
|
+
length3,
|
2667
2766
|
loadedName: baseDict.loadedName,
|
2668
|
-
composite
|
2767
|
+
composite,
|
2669
2768
|
wideChars: composite,
|
2670
2769
|
fixedPitch: false,
|
2671
|
-
fontMatrix: dict.getArray(
|
2770
|
+
fontMatrix: dict.getArray("FontMatrix") || _util.FONT_IDENTITY_MATRIX,
|
2672
2771
|
firstChar: firstChar || 0,
|
2673
2772
|
lastChar: lastChar || maxCharIndex,
|
2674
|
-
bbox: descriptor.getArray(
|
2675
|
-
ascent: descriptor.get(
|
2676
|
-
descent: descriptor.get(
|
2677
|
-
xHeight: descriptor.get(
|
2678
|
-
capHeight: descriptor.get(
|
2679
|
-
flags: descriptor.get(
|
2680
|
-
italicAngle: descriptor.get(
|
2773
|
+
bbox: descriptor.getArray("FontBBox"),
|
2774
|
+
ascent: descriptor.get("Ascent"),
|
2775
|
+
descent: descriptor.get("Descent"),
|
2776
|
+
xHeight: descriptor.get("XHeight"),
|
2777
|
+
capHeight: descriptor.get("CapHeight"),
|
2778
|
+
flags: descriptor.get("Flags"),
|
2779
|
+
italicAngle: descriptor.get("ItalicAngle"),
|
2681
2780
|
isType3Font: false
|
2682
2781
|
};
|
2683
2782
|
var cMapPromise;
|
2684
2783
|
|
2685
2784
|
if (composite) {
|
2686
|
-
var cidEncoding = baseDict.get(
|
2785
|
+
var cidEncoding = baseDict.get("Encoding");
|
2687
2786
|
|
2688
2787
|
if ((0, _primitives.isName)(cidEncoding)) {
|
2689
2788
|
properties.cidEncoding = cidEncoding.name;
|
@@ -2701,12 +2800,12 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2701
2800
|
cMapPromise = Promise.resolve(undefined);
|
2702
2801
|
}
|
2703
2802
|
|
2704
|
-
return cMapPromise.then(
|
2705
|
-
return
|
2706
|
-
}).then(
|
2707
|
-
|
2803
|
+
return cMapPromise.then(() => {
|
2804
|
+
return this.extractDataStructures(dict, baseDict, properties);
|
2805
|
+
}).then(properties => {
|
2806
|
+
this.extractWidths(dict, descriptor, properties);
|
2708
2807
|
|
2709
|
-
if (type ===
|
2808
|
+
if (type === "Type3") {
|
2710
2809
|
properties.isType3Font = true;
|
2711
2810
|
}
|
2712
2811
|
|
@@ -2721,39 +2820,32 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2721
2820
|
return;
|
2722
2821
|
}
|
2723
2822
|
|
2724
|
-
handler.send(
|
2823
|
+
handler.send("commonobj", [`${font.loadedName}_path_${fontChar}`, "FontPath", font.renderer.getPathJs(fontChar)]);
|
2725
2824
|
}
|
2726
2825
|
|
2727
|
-
|
2728
|
-
|
2729
|
-
|
2826
|
+
for (const glyph of glyphs) {
|
2827
|
+
buildPath(glyph.fontChar);
|
2828
|
+
const accent = glyph.accent;
|
2730
2829
|
|
2731
|
-
|
2732
|
-
|
2733
|
-
var glyph = _step.value;
|
2734
|
-
buildPath(glyph.fontChar);
|
2735
|
-
var accent = glyph.accent;
|
2736
|
-
|
2737
|
-
if (accent && accent.fontChar) {
|
2738
|
-
buildPath(accent.fontChar);
|
2739
|
-
}
|
2740
|
-
}
|
2741
|
-
} catch (err) {
|
2742
|
-
_didIteratorError = true;
|
2743
|
-
_iteratorError = err;
|
2744
|
-
} finally {
|
2745
|
-
try {
|
2746
|
-
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
|
2747
|
-
_iterator["return"]();
|
2748
|
-
}
|
2749
|
-
} finally {
|
2750
|
-
if (_didIteratorError) {
|
2751
|
-
throw _iteratorError;
|
2752
|
-
}
|
2830
|
+
if (accent && accent.fontChar) {
|
2831
|
+
buildPath(accent.fontChar);
|
2753
2832
|
}
|
2754
2833
|
}
|
2755
2834
|
};
|
2756
2835
|
|
2836
|
+
PartialEvaluator.getFallbackFontDict = function () {
|
2837
|
+
if (this._fallbackFontDict) {
|
2838
|
+
return this._fallbackFontDict;
|
2839
|
+
}
|
2840
|
+
|
2841
|
+
const dict = new _primitives.Dict();
|
2842
|
+
dict.set("BaseFont", _primitives.Name.get("PDFJS-FallbackFont"));
|
2843
|
+
dict.set("Type", _primitives.Name.get("FallbackType"));
|
2844
|
+
dict.set("Subtype", _primitives.Name.get("FallbackType"));
|
2845
|
+
dict.set("Encoding", _primitives.Name.get("WinAnsiEncoding"));
|
2846
|
+
return this._fallbackFontDict = dict;
|
2847
|
+
};
|
2848
|
+
|
2757
2849
|
return PartialEvaluator;
|
2758
2850
|
}();
|
2759
2851
|
|
@@ -2769,26 +2861,28 @@ var TranslatedFont = function TranslatedFontClosure() {
|
|
2769
2861
|
}
|
2770
2862
|
|
2771
2863
|
TranslatedFont.prototype = {
|
2772
|
-
send
|
2864
|
+
send(handler) {
|
2773
2865
|
if (this.sent) {
|
2774
2866
|
return;
|
2775
2867
|
}
|
2776
2868
|
|
2777
2869
|
this.sent = true;
|
2778
|
-
handler.send(
|
2870
|
+
handler.send("commonobj", [this.loadedName, "Font", this.font.exportData()]);
|
2779
2871
|
},
|
2780
|
-
|
2872
|
+
|
2873
|
+
fallback(handler) {
|
2781
2874
|
if (!this.font.data) {
|
2782
2875
|
return;
|
2783
2876
|
}
|
2784
2877
|
|
2785
2878
|
this.font.disableFontFace = true;
|
2786
|
-
|
2879
|
+
const glyphs = this.font.glyphCacheValues;
|
2787
2880
|
PartialEvaluator.buildFontPaths(this.font, glyphs, handler);
|
2788
2881
|
},
|
2789
|
-
|
2882
|
+
|
2883
|
+
loadType3Data(evaluator, resources, parentOperatorList, task) {
|
2790
2884
|
if (!this.font.isType3Font) {
|
2791
|
-
throw new Error(
|
2885
|
+
throw new Error("Must be a Type3 font.");
|
2792
2886
|
}
|
2793
2887
|
|
2794
2888
|
if (this.type3Loaded) {
|
@@ -2802,34 +2896,30 @@ var TranslatedFont = function TranslatedFontClosure() {
|
|
2802
2896
|
type3Evaluator.parsingType3Font = true;
|
2803
2897
|
var translatedFont = this.font;
|
2804
2898
|
var loadCharProcsPromise = Promise.resolve();
|
2805
|
-
var charProcs = this.dict.get(
|
2806
|
-
var fontResources = this.dict.get(
|
2899
|
+
var charProcs = this.dict.get("CharProcs");
|
2900
|
+
var fontResources = this.dict.get("Resources") || resources;
|
2807
2901
|
var charProcKeys = charProcs.getKeys();
|
2808
2902
|
var charProcOperatorList = Object.create(null);
|
2809
2903
|
|
2810
|
-
var
|
2811
|
-
|
2904
|
+
for (var i = 0, n = charProcKeys.length; i < n; ++i) {
|
2905
|
+
const key = charProcKeys[i];
|
2812
2906
|
loadCharProcsPromise = loadCharProcsPromise.then(function () {
|
2813
2907
|
var glyphStream = charProcs.get(key);
|
2814
2908
|
var operatorList = new _operator_list.OperatorList();
|
2815
2909
|
return type3Evaluator.getOperatorList({
|
2816
2910
|
stream: glyphStream,
|
2817
|
-
task
|
2911
|
+
task,
|
2818
2912
|
resources: fontResources,
|
2819
|
-
operatorList
|
2913
|
+
operatorList
|
2820
2914
|
}).then(function () {
|
2821
2915
|
charProcOperatorList[key] = operatorList.getIR();
|
2822
2916
|
parentOperatorList.addDependencies(operatorList.dependencies);
|
2823
|
-
})
|
2824
|
-
(0, _util.warn)(
|
2917
|
+
}).catch(function (reason) {
|
2918
|
+
(0, _util.warn)(`Type3 font resource "${key}" is not available.`);
|
2825
2919
|
var operatorList = new _operator_list.OperatorList();
|
2826
2920
|
charProcOperatorList[key] = operatorList.getIR();
|
2827
2921
|
});
|
2828
2922
|
});
|
2829
|
-
};
|
2830
|
-
|
2831
|
-
for (var i = 0, n = charProcKeys.length; i < n; ++i) {
|
2832
|
-
_loop2();
|
2833
2923
|
}
|
2834
2924
|
|
2835
2925
|
this.type3Loaded = loadCharProcsPromise.then(function () {
|
@@ -2837,6 +2927,7 @@ var TranslatedFont = function TranslatedFontClosure() {
|
|
2837
2927
|
});
|
2838
2928
|
return this.type3Loaded;
|
2839
2929
|
}
|
2930
|
+
|
2840
2931
|
};
|
2841
2932
|
return TranslatedFont;
|
2842
2933
|
}();
|
@@ -2848,21 +2939,24 @@ var StateManager = function StateManagerClosure() {
|
|
2848
2939
|
}
|
2849
2940
|
|
2850
2941
|
StateManager.prototype = {
|
2851
|
-
save
|
2942
|
+
save() {
|
2852
2943
|
var old = this.state;
|
2853
2944
|
this.stateStack.push(this.state);
|
2854
2945
|
this.state = old.clone();
|
2855
2946
|
},
|
2856
|
-
|
2947
|
+
|
2948
|
+
restore() {
|
2857
2949
|
var prev = this.stateStack.pop();
|
2858
2950
|
|
2859
2951
|
if (prev) {
|
2860
2952
|
this.state = prev;
|
2861
2953
|
}
|
2862
2954
|
},
|
2863
|
-
|
2955
|
+
|
2956
|
+
transform(args) {
|
2864
2957
|
this.state.ctm = _util.Util.transform(this.state.ctm, args);
|
2865
2958
|
}
|
2959
|
+
|
2866
2960
|
};
|
2867
2961
|
return StateManager;
|
2868
2962
|
}();
|
@@ -2988,232 +3082,232 @@ var EvalState = function EvalStateClosure() {
|
|
2988
3082
|
|
2989
3083
|
var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
|
2990
3084
|
var getOPMap = (0, _core_utils.getLookupTableFactory)(function (t) {
|
2991
|
-
t[
|
3085
|
+
t["w"] = {
|
2992
3086
|
id: _util.OPS.setLineWidth,
|
2993
3087
|
numArgs: 1,
|
2994
3088
|
variableArgs: false
|
2995
3089
|
};
|
2996
|
-
t[
|
3090
|
+
t["J"] = {
|
2997
3091
|
id: _util.OPS.setLineCap,
|
2998
3092
|
numArgs: 1,
|
2999
3093
|
variableArgs: false
|
3000
3094
|
};
|
3001
|
-
t[
|
3095
|
+
t["j"] = {
|
3002
3096
|
id: _util.OPS.setLineJoin,
|
3003
3097
|
numArgs: 1,
|
3004
3098
|
variableArgs: false
|
3005
3099
|
};
|
3006
|
-
t[
|
3100
|
+
t["M"] = {
|
3007
3101
|
id: _util.OPS.setMiterLimit,
|
3008
3102
|
numArgs: 1,
|
3009
3103
|
variableArgs: false
|
3010
3104
|
};
|
3011
|
-
t[
|
3105
|
+
t["d"] = {
|
3012
3106
|
id: _util.OPS.setDash,
|
3013
3107
|
numArgs: 2,
|
3014
3108
|
variableArgs: false
|
3015
3109
|
};
|
3016
|
-
t[
|
3110
|
+
t["ri"] = {
|
3017
3111
|
id: _util.OPS.setRenderingIntent,
|
3018
3112
|
numArgs: 1,
|
3019
3113
|
variableArgs: false
|
3020
3114
|
};
|
3021
|
-
t[
|
3115
|
+
t["i"] = {
|
3022
3116
|
id: _util.OPS.setFlatness,
|
3023
3117
|
numArgs: 1,
|
3024
3118
|
variableArgs: false
|
3025
3119
|
};
|
3026
|
-
t[
|
3120
|
+
t["gs"] = {
|
3027
3121
|
id: _util.OPS.setGState,
|
3028
3122
|
numArgs: 1,
|
3029
3123
|
variableArgs: false
|
3030
3124
|
};
|
3031
|
-
t[
|
3125
|
+
t["q"] = {
|
3032
3126
|
id: _util.OPS.save,
|
3033
3127
|
numArgs: 0,
|
3034
3128
|
variableArgs: false
|
3035
3129
|
};
|
3036
|
-
t[
|
3130
|
+
t["Q"] = {
|
3037
3131
|
id: _util.OPS.restore,
|
3038
3132
|
numArgs: 0,
|
3039
3133
|
variableArgs: false
|
3040
3134
|
};
|
3041
|
-
t[
|
3135
|
+
t["cm"] = {
|
3042
3136
|
id: _util.OPS.transform,
|
3043
3137
|
numArgs: 6,
|
3044
3138
|
variableArgs: false
|
3045
3139
|
};
|
3046
|
-
t[
|
3140
|
+
t["m"] = {
|
3047
3141
|
id: _util.OPS.moveTo,
|
3048
3142
|
numArgs: 2,
|
3049
3143
|
variableArgs: false
|
3050
3144
|
};
|
3051
|
-
t[
|
3145
|
+
t["l"] = {
|
3052
3146
|
id: _util.OPS.lineTo,
|
3053
3147
|
numArgs: 2,
|
3054
3148
|
variableArgs: false
|
3055
3149
|
};
|
3056
|
-
t[
|
3150
|
+
t["c"] = {
|
3057
3151
|
id: _util.OPS.curveTo,
|
3058
3152
|
numArgs: 6,
|
3059
3153
|
variableArgs: false
|
3060
3154
|
};
|
3061
|
-
t[
|
3155
|
+
t["v"] = {
|
3062
3156
|
id: _util.OPS.curveTo2,
|
3063
3157
|
numArgs: 4,
|
3064
3158
|
variableArgs: false
|
3065
3159
|
};
|
3066
|
-
t[
|
3160
|
+
t["y"] = {
|
3067
3161
|
id: _util.OPS.curveTo3,
|
3068
3162
|
numArgs: 4,
|
3069
3163
|
variableArgs: false
|
3070
3164
|
};
|
3071
|
-
t[
|
3165
|
+
t["h"] = {
|
3072
3166
|
id: _util.OPS.closePath,
|
3073
3167
|
numArgs: 0,
|
3074
3168
|
variableArgs: false
|
3075
3169
|
};
|
3076
|
-
t[
|
3170
|
+
t["re"] = {
|
3077
3171
|
id: _util.OPS.rectangle,
|
3078
3172
|
numArgs: 4,
|
3079
3173
|
variableArgs: false
|
3080
3174
|
};
|
3081
|
-
t[
|
3175
|
+
t["S"] = {
|
3082
3176
|
id: _util.OPS.stroke,
|
3083
3177
|
numArgs: 0,
|
3084
3178
|
variableArgs: false
|
3085
3179
|
};
|
3086
|
-
t[
|
3180
|
+
t["s"] = {
|
3087
3181
|
id: _util.OPS.closeStroke,
|
3088
3182
|
numArgs: 0,
|
3089
3183
|
variableArgs: false
|
3090
3184
|
};
|
3091
|
-
t[
|
3185
|
+
t["f"] = {
|
3092
3186
|
id: _util.OPS.fill,
|
3093
3187
|
numArgs: 0,
|
3094
3188
|
variableArgs: false
|
3095
3189
|
};
|
3096
|
-
t[
|
3190
|
+
t["F"] = {
|
3097
3191
|
id: _util.OPS.fill,
|
3098
3192
|
numArgs: 0,
|
3099
3193
|
variableArgs: false
|
3100
3194
|
};
|
3101
|
-
t[
|
3195
|
+
t["f*"] = {
|
3102
3196
|
id: _util.OPS.eoFill,
|
3103
3197
|
numArgs: 0,
|
3104
3198
|
variableArgs: false
|
3105
3199
|
};
|
3106
|
-
t[
|
3200
|
+
t["B"] = {
|
3107
3201
|
id: _util.OPS.fillStroke,
|
3108
3202
|
numArgs: 0,
|
3109
3203
|
variableArgs: false
|
3110
3204
|
};
|
3111
|
-
t[
|
3205
|
+
t["B*"] = {
|
3112
3206
|
id: _util.OPS.eoFillStroke,
|
3113
3207
|
numArgs: 0,
|
3114
3208
|
variableArgs: false
|
3115
3209
|
};
|
3116
|
-
t[
|
3210
|
+
t["b"] = {
|
3117
3211
|
id: _util.OPS.closeFillStroke,
|
3118
3212
|
numArgs: 0,
|
3119
3213
|
variableArgs: false
|
3120
3214
|
};
|
3121
|
-
t[
|
3215
|
+
t["b*"] = {
|
3122
3216
|
id: _util.OPS.closeEOFillStroke,
|
3123
3217
|
numArgs: 0,
|
3124
3218
|
variableArgs: false
|
3125
3219
|
};
|
3126
|
-
t[
|
3220
|
+
t["n"] = {
|
3127
3221
|
id: _util.OPS.endPath,
|
3128
3222
|
numArgs: 0,
|
3129
3223
|
variableArgs: false
|
3130
3224
|
};
|
3131
|
-
t[
|
3225
|
+
t["W"] = {
|
3132
3226
|
id: _util.OPS.clip,
|
3133
3227
|
numArgs: 0,
|
3134
3228
|
variableArgs: false
|
3135
3229
|
};
|
3136
|
-
t[
|
3230
|
+
t["W*"] = {
|
3137
3231
|
id: _util.OPS.eoClip,
|
3138
3232
|
numArgs: 0,
|
3139
3233
|
variableArgs: false
|
3140
3234
|
};
|
3141
|
-
t[
|
3235
|
+
t["BT"] = {
|
3142
3236
|
id: _util.OPS.beginText,
|
3143
3237
|
numArgs: 0,
|
3144
3238
|
variableArgs: false
|
3145
3239
|
};
|
3146
|
-
t[
|
3240
|
+
t["ET"] = {
|
3147
3241
|
id: _util.OPS.endText,
|
3148
3242
|
numArgs: 0,
|
3149
3243
|
variableArgs: false
|
3150
3244
|
};
|
3151
|
-
t[
|
3245
|
+
t["Tc"] = {
|
3152
3246
|
id: _util.OPS.setCharSpacing,
|
3153
3247
|
numArgs: 1,
|
3154
3248
|
variableArgs: false
|
3155
3249
|
};
|
3156
|
-
t[
|
3250
|
+
t["Tw"] = {
|
3157
3251
|
id: _util.OPS.setWordSpacing,
|
3158
3252
|
numArgs: 1,
|
3159
3253
|
variableArgs: false
|
3160
3254
|
};
|
3161
|
-
t[
|
3255
|
+
t["Tz"] = {
|
3162
3256
|
id: _util.OPS.setHScale,
|
3163
3257
|
numArgs: 1,
|
3164
3258
|
variableArgs: false
|
3165
3259
|
};
|
3166
|
-
t[
|
3260
|
+
t["TL"] = {
|
3167
3261
|
id: _util.OPS.setLeading,
|
3168
3262
|
numArgs: 1,
|
3169
3263
|
variableArgs: false
|
3170
3264
|
};
|
3171
|
-
t[
|
3265
|
+
t["Tf"] = {
|
3172
3266
|
id: _util.OPS.setFont,
|
3173
3267
|
numArgs: 2,
|
3174
3268
|
variableArgs: false
|
3175
3269
|
};
|
3176
|
-
t[
|
3270
|
+
t["Tr"] = {
|
3177
3271
|
id: _util.OPS.setTextRenderingMode,
|
3178
3272
|
numArgs: 1,
|
3179
3273
|
variableArgs: false
|
3180
3274
|
};
|
3181
|
-
t[
|
3275
|
+
t["Ts"] = {
|
3182
3276
|
id: _util.OPS.setTextRise,
|
3183
3277
|
numArgs: 1,
|
3184
3278
|
variableArgs: false
|
3185
3279
|
};
|
3186
|
-
t[
|
3280
|
+
t["Td"] = {
|
3187
3281
|
id: _util.OPS.moveText,
|
3188
3282
|
numArgs: 2,
|
3189
3283
|
variableArgs: false
|
3190
3284
|
};
|
3191
|
-
t[
|
3285
|
+
t["TD"] = {
|
3192
3286
|
id: _util.OPS.setLeadingMoveText,
|
3193
3287
|
numArgs: 2,
|
3194
3288
|
variableArgs: false
|
3195
3289
|
};
|
3196
|
-
t[
|
3290
|
+
t["Tm"] = {
|
3197
3291
|
id: _util.OPS.setTextMatrix,
|
3198
3292
|
numArgs: 6,
|
3199
3293
|
variableArgs: false
|
3200
3294
|
};
|
3201
|
-
t[
|
3295
|
+
t["T*"] = {
|
3202
3296
|
id: _util.OPS.nextLine,
|
3203
3297
|
numArgs: 0,
|
3204
3298
|
variableArgs: false
|
3205
3299
|
};
|
3206
|
-
t[
|
3300
|
+
t["Tj"] = {
|
3207
3301
|
id: _util.OPS.showText,
|
3208
3302
|
numArgs: 1,
|
3209
3303
|
variableArgs: false
|
3210
3304
|
};
|
3211
|
-
t[
|
3305
|
+
t["TJ"] = {
|
3212
3306
|
id: _util.OPS.showSpacedText,
|
3213
3307
|
numArgs: 1,
|
3214
3308
|
variableArgs: false
|
3215
3309
|
};
|
3216
|
-
t['
|
3310
|
+
t["'"] = {
|
3217
3311
|
id: _util.OPS.nextLineShowText,
|
3218
3312
|
numArgs: 1,
|
3219
3313
|
variableArgs: false
|
@@ -3223,154 +3317,154 @@ var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
|
|
3223
3317
|
numArgs: 3,
|
3224
3318
|
variableArgs: false
|
3225
3319
|
};
|
3226
|
-
t[
|
3320
|
+
t["d0"] = {
|
3227
3321
|
id: _util.OPS.setCharWidth,
|
3228
3322
|
numArgs: 2,
|
3229
3323
|
variableArgs: false
|
3230
3324
|
};
|
3231
|
-
t[
|
3325
|
+
t["d1"] = {
|
3232
3326
|
id: _util.OPS.setCharWidthAndBounds,
|
3233
3327
|
numArgs: 6,
|
3234
3328
|
variableArgs: false
|
3235
3329
|
};
|
3236
|
-
t[
|
3330
|
+
t["CS"] = {
|
3237
3331
|
id: _util.OPS.setStrokeColorSpace,
|
3238
3332
|
numArgs: 1,
|
3239
3333
|
variableArgs: false
|
3240
3334
|
};
|
3241
|
-
t[
|
3335
|
+
t["cs"] = {
|
3242
3336
|
id: _util.OPS.setFillColorSpace,
|
3243
3337
|
numArgs: 1,
|
3244
3338
|
variableArgs: false
|
3245
3339
|
};
|
3246
|
-
t[
|
3340
|
+
t["SC"] = {
|
3247
3341
|
id: _util.OPS.setStrokeColor,
|
3248
3342
|
numArgs: 4,
|
3249
3343
|
variableArgs: true
|
3250
3344
|
};
|
3251
|
-
t[
|
3345
|
+
t["SCN"] = {
|
3252
3346
|
id: _util.OPS.setStrokeColorN,
|
3253
3347
|
numArgs: 33,
|
3254
3348
|
variableArgs: true
|
3255
3349
|
};
|
3256
|
-
t[
|
3350
|
+
t["sc"] = {
|
3257
3351
|
id: _util.OPS.setFillColor,
|
3258
3352
|
numArgs: 4,
|
3259
3353
|
variableArgs: true
|
3260
3354
|
};
|
3261
|
-
t[
|
3355
|
+
t["scn"] = {
|
3262
3356
|
id: _util.OPS.setFillColorN,
|
3263
3357
|
numArgs: 33,
|
3264
3358
|
variableArgs: true
|
3265
3359
|
};
|
3266
|
-
t[
|
3360
|
+
t["G"] = {
|
3267
3361
|
id: _util.OPS.setStrokeGray,
|
3268
3362
|
numArgs: 1,
|
3269
3363
|
variableArgs: false
|
3270
3364
|
};
|
3271
|
-
t[
|
3365
|
+
t["g"] = {
|
3272
3366
|
id: _util.OPS.setFillGray,
|
3273
3367
|
numArgs: 1,
|
3274
3368
|
variableArgs: false
|
3275
3369
|
};
|
3276
|
-
t[
|
3370
|
+
t["RG"] = {
|
3277
3371
|
id: _util.OPS.setStrokeRGBColor,
|
3278
3372
|
numArgs: 3,
|
3279
3373
|
variableArgs: false
|
3280
3374
|
};
|
3281
|
-
t[
|
3375
|
+
t["rg"] = {
|
3282
3376
|
id: _util.OPS.setFillRGBColor,
|
3283
3377
|
numArgs: 3,
|
3284
3378
|
variableArgs: false
|
3285
3379
|
};
|
3286
|
-
t[
|
3380
|
+
t["K"] = {
|
3287
3381
|
id: _util.OPS.setStrokeCMYKColor,
|
3288
3382
|
numArgs: 4,
|
3289
3383
|
variableArgs: false
|
3290
3384
|
};
|
3291
|
-
t[
|
3385
|
+
t["k"] = {
|
3292
3386
|
id: _util.OPS.setFillCMYKColor,
|
3293
3387
|
numArgs: 4,
|
3294
3388
|
variableArgs: false
|
3295
3389
|
};
|
3296
|
-
t[
|
3390
|
+
t["sh"] = {
|
3297
3391
|
id: _util.OPS.shadingFill,
|
3298
3392
|
numArgs: 1,
|
3299
3393
|
variableArgs: false
|
3300
3394
|
};
|
3301
|
-
t[
|
3395
|
+
t["BI"] = {
|
3302
3396
|
id: _util.OPS.beginInlineImage,
|
3303
3397
|
numArgs: 0,
|
3304
3398
|
variableArgs: false
|
3305
3399
|
};
|
3306
|
-
t[
|
3400
|
+
t["ID"] = {
|
3307
3401
|
id: _util.OPS.beginImageData,
|
3308
3402
|
numArgs: 0,
|
3309
3403
|
variableArgs: false
|
3310
3404
|
};
|
3311
|
-
t[
|
3405
|
+
t["EI"] = {
|
3312
3406
|
id: _util.OPS.endInlineImage,
|
3313
3407
|
numArgs: 1,
|
3314
3408
|
variableArgs: false
|
3315
3409
|
};
|
3316
|
-
t[
|
3410
|
+
t["Do"] = {
|
3317
3411
|
id: _util.OPS.paintXObject,
|
3318
3412
|
numArgs: 1,
|
3319
3413
|
variableArgs: false
|
3320
3414
|
};
|
3321
|
-
t[
|
3415
|
+
t["MP"] = {
|
3322
3416
|
id: _util.OPS.markPoint,
|
3323
3417
|
numArgs: 1,
|
3324
3418
|
variableArgs: false
|
3325
3419
|
};
|
3326
|
-
t[
|
3420
|
+
t["DP"] = {
|
3327
3421
|
id: _util.OPS.markPointProps,
|
3328
3422
|
numArgs: 2,
|
3329
3423
|
variableArgs: false
|
3330
3424
|
};
|
3331
|
-
t[
|
3425
|
+
t["BMC"] = {
|
3332
3426
|
id: _util.OPS.beginMarkedContent,
|
3333
3427
|
numArgs: 1,
|
3334
3428
|
variableArgs: false
|
3335
3429
|
};
|
3336
|
-
t[
|
3430
|
+
t["BDC"] = {
|
3337
3431
|
id: _util.OPS.beginMarkedContentProps,
|
3338
3432
|
numArgs: 2,
|
3339
3433
|
variableArgs: false
|
3340
3434
|
};
|
3341
|
-
t[
|
3435
|
+
t["EMC"] = {
|
3342
3436
|
id: _util.OPS.endMarkedContent,
|
3343
3437
|
numArgs: 0,
|
3344
3438
|
variableArgs: false
|
3345
3439
|
};
|
3346
|
-
t[
|
3440
|
+
t["BX"] = {
|
3347
3441
|
id: _util.OPS.beginCompat,
|
3348
3442
|
numArgs: 0,
|
3349
3443
|
variableArgs: false
|
3350
3444
|
};
|
3351
|
-
t[
|
3445
|
+
t["EX"] = {
|
3352
3446
|
id: _util.OPS.endCompat,
|
3353
3447
|
numArgs: 0,
|
3354
3448
|
variableArgs: false
|
3355
3449
|
};
|
3356
|
-
t[
|
3357
|
-
t[
|
3358
|
-
t[
|
3359
|
-
t[
|
3360
|
-
t[
|
3361
|
-
t[
|
3362
|
-
t[
|
3363
|
-
t[
|
3364
|
-
t[
|
3365
|
-
t[
|
3450
|
+
t["BM"] = null;
|
3451
|
+
t["BD"] = null;
|
3452
|
+
t["true"] = null;
|
3453
|
+
t["fa"] = null;
|
3454
|
+
t["fal"] = null;
|
3455
|
+
t["fals"] = null;
|
3456
|
+
t["false"] = null;
|
3457
|
+
t["nu"] = null;
|
3458
|
+
t["nul"] = null;
|
3459
|
+
t["null"] = null;
|
3366
3460
|
});
|
3367
|
-
|
3461
|
+
const MAX_INVALID_PATH_OPS = 20;
|
3368
3462
|
|
3369
3463
|
function EvaluatorPreprocessor(stream, xref, stateManager) {
|
3370
3464
|
this.opMap = getOPMap();
|
3371
3465
|
this.parser = new _parser.Parser({
|
3372
3466
|
lexer: new _parser.Lexer(stream, this.opMap),
|
3373
|
-
xref
|
3467
|
+
xref
|
3374
3468
|
});
|
3375
3469
|
this.stateManager = stateManager;
|
3376
3470
|
this.nonProcessedArgs = [];
|
@@ -3393,7 +3487,7 @@ var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
|
|
3393
3487
|
var opSpec = this.opMap[cmd];
|
3394
3488
|
|
3395
3489
|
if (!opSpec) {
|
3396
|
-
(0, _util.warn)(
|
3490
|
+
(0, _util.warn)(`Unknown command "${cmd}".`);
|
3397
3491
|
continue;
|
3398
3492
|
}
|
3399
3493
|
|
@@ -3421,13 +3515,13 @@ var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
|
|
3421
3515
|
}
|
3422
3516
|
|
3423
3517
|
if (argsLength < numArgs) {
|
3424
|
-
|
3518
|
+
const partialMsg = `command ${cmd}: expected ${numArgs} args, ` + `but received ${argsLength} args.`;
|
3425
3519
|
|
3426
3520
|
if (fn >= _util.OPS.moveTo && fn <= _util.OPS.endPath && ++this._numInvalidPathOPS > MAX_INVALID_PATH_OPS) {
|
3427
|
-
throw new _util.FormatError(
|
3521
|
+
throw new _util.FormatError(`Invalid ${partialMsg}`);
|
3428
3522
|
}
|
3429
3523
|
|
3430
|
-
(0, _util.warn)(
|
3524
|
+
(0, _util.warn)(`Skipping ${partialMsg}`);
|
3431
3525
|
|
3432
3526
|
if (args !== null) {
|
3433
3527
|
args.length = 0;
|
@@ -3436,7 +3530,7 @@ var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
|
|
3436
3530
|
continue;
|
3437
3531
|
}
|
3438
3532
|
} else if (argsLength > numArgs) {
|
3439
|
-
(0, _util.info)(
|
3533
|
+
(0, _util.info)(`Command ${cmd}: expected [0, ${numArgs}] args, ` + `but received ${argsLength} args.`);
|
3440
3534
|
}
|
3441
3535
|
|
3442
3536
|
this.preprocessCommand(fn, args);
|
@@ -3457,7 +3551,7 @@ var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
|
|
3457
3551
|
args.push(obj);
|
3458
3552
|
|
3459
3553
|
if (args.length > 33) {
|
3460
|
-
throw new _util.FormatError(
|
3554
|
+
throw new _util.FormatError("Too many arguments");
|
3461
3555
|
}
|
3462
3556
|
}
|
3463
3557
|
}
|