pdfjs-dist 2.1.266 → 2.2.228
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/CODE_OF_CONDUCT.md +15 -0
- package/bower.json +1 -1
- package/build/pdf.js +3349 -2324
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +2804 -1975
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/image_decoders/pdf.image_decoders.js +431 -511
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +1 -1
- package/lib/core/annotation.js +294 -224
- package/lib/core/arithmetic_decoder.js +1 -1
- package/lib/core/bidi.js +1 -1
- package/lib/core/ccitt.js +1 -1
- package/lib/core/ccitt_stream.js +1 -1
- package/lib/core/cff_parser.js +61 -12
- package/lib/core/charsets.js +1 -1
- package/lib/core/chunked_stream.js +24 -14
- package/lib/core/cmap.js +17 -13
- package/lib/core/colorspace.js +1 -1
- package/lib/core/core_utils.js +147 -0
- package/lib/core/crypto.js +1 -1
- package/lib/core/document.js +47 -40
- package/lib/core/encodings.js +1 -1
- package/lib/core/evaluator.js +346 -279
- package/lib/core/font_renderer.js +1 -1
- package/lib/core/fonts.js +23 -11
- package/lib/core/function.js +1 -1
- package/lib/core/glyphlist.js +2 -2
- package/lib/core/image.js +2 -2
- package/lib/core/image_utils.js +111 -0
- package/lib/core/jbig2.js +1 -1
- package/lib/core/jbig2_stream.js +1 -1
- package/lib/core/jpeg_stream.js +1 -1
- package/lib/core/jpg.js +2 -1
- package/lib/core/jpx.js +1 -1
- package/lib/core/jpx_stream.js +1 -1
- package/lib/core/metrics.js +13 -13
- package/lib/core/murmurhash3.js +37 -33
- package/lib/core/obj.js +245 -41
- package/lib/core/operator_list.js +43 -32
- package/lib/core/parser.js +228 -133
- package/lib/core/pattern.js +4 -2
- package/lib/core/pdf_manager.js +17 -15
- package/lib/core/primitives.js +40 -6
- package/lib/core/ps_parser.js +1 -1
- package/lib/core/standard_fonts.js +9 -9
- package/lib/core/stream.js +1 -1
- package/lib/core/type1_parser.js +1 -1
- package/lib/core/unicode.js +2 -2
- package/lib/core/worker.js +54 -171
- package/lib/core/worker_stream.js +277 -0
- package/lib/display/annotation_layer.js +112 -33
- package/lib/display/api.js +211 -123
- package/lib/display/api_compatibility.js +1 -1
- package/lib/display/canvas.js +40 -19
- package/lib/display/content_disposition.js +1 -1
- package/lib/display/display_utils.js +747 -0
- package/lib/display/fetch_stream.js +19 -12
- package/lib/display/font_loader.js +11 -8
- package/lib/display/metadata.js +1 -1
- package/lib/display/network.js +563 -521
- package/lib/display/network_utils.js +1 -1
- package/lib/display/node_stream.js +21 -12
- package/lib/display/pattern_helper.js +24 -25
- package/lib/display/svg.js +1068 -565
- package/lib/display/text_layer.js +24 -14
- package/lib/display/transport_stream.js +192 -70
- package/lib/display/webgl.js +1 -1
- package/lib/display/worker_options.js +1 -1
- package/lib/display/xml_parser.js +1 -1
- package/lib/examples/node/domstubs.js +4 -1
- package/lib/pdf.js +20 -15
- package/lib/pdf.worker.js +3 -3
- package/lib/shared/compatibility.js +6 -6
- package/lib/shared/global_scope.js +1 -1
- package/lib/shared/is_node.js +2 -2
- package/lib/shared/message_handler.js +7 -7
- package/lib/shared/streams_polyfill.js +1 -1
- package/lib/shared/url_polyfill.js +1 -1
- package/lib/shared/util.js +13 -125
- package/lib/test/unit/annotation_spec.js +278 -93
- package/lib/test/unit/api_spec.js +198 -188
- package/lib/test/unit/bidi_spec.js +1 -1
- package/lib/test/unit/cff_parser_spec.js +15 -1
- package/lib/test/unit/clitests_helper.js +3 -3
- package/lib/test/unit/cmap_spec.js +20 -20
- package/lib/test/unit/colorspace_spec.js +17 -12
- package/lib/test/unit/core_utils_spec.js +191 -0
- package/lib/test/unit/crypto_spec.js +1 -1
- package/lib/test/unit/custom_spec.js +8 -8
- package/lib/test/unit/display_svg_spec.js +8 -8
- package/lib/test/unit/display_utils_spec.js +273 -0
- package/lib/test/unit/document_spec.js +7 -12
- package/lib/test/unit/encodings_spec.js +5 -5
- package/lib/test/unit/evaluator_spec.js +8 -10
- package/lib/test/unit/fetch_stream_spec.js +109 -0
- package/lib/test/unit/function_spec.js +1 -1
- package/lib/test/unit/jasmine-boot.js +4 -4
- package/lib/test/unit/message_handler_spec.js +1 -1
- package/lib/test/unit/metadata_spec.js +1 -1
- package/lib/test/unit/murmurhash3_spec.js +1 -1
- package/lib/test/unit/network_spec.js +5 -55
- package/lib/test/unit/network_utils_spec.js +51 -1
- package/lib/test/unit/node_stream_spec.js +8 -8
- package/lib/test/unit/parser_spec.js +150 -86
- package/lib/test/unit/pdf_find_controller_spec.js +1 -1
- package/lib/test/unit/pdf_find_utils_spec.js +1 -1
- package/lib/test/unit/pdf_history_spec.js +1 -1
- package/lib/test/unit/primitives_spec.js +30 -17
- package/lib/test/unit/stream_spec.js +1 -1
- package/lib/test/unit/test_utils.js +197 -43
- package/lib/test/unit/testreporter.js +1 -1
- package/lib/test/unit/type1_parser_spec.js +1 -1
- package/lib/test/unit/ui_utils_spec.js +20 -20
- package/lib/test/unit/unicode_spec.js +5 -5
- package/lib/test/unit/util_spec.js +1 -164
- package/lib/web/annotation_layer_builder.js +1 -1
- package/lib/web/app.js +104 -60
- package/lib/web/app_options.js +45 -37
- package/lib/web/base_viewer.js +7 -7
- package/lib/web/chromecom.js +8 -8
- package/lib/web/debugger.js +7 -7
- package/lib/web/download_manager.js +3 -2
- package/lib/web/firefox_print_service.js +4 -2
- package/lib/web/firefoxcom.js +50 -19
- package/lib/web/genericcom.js +8 -8
- package/lib/web/genericl10n.js +10 -10
- package/lib/web/grab_to_pan.js +3 -1
- package/lib/web/interfaces.js +13 -13
- package/lib/web/overlay_manager.js +10 -10
- package/lib/web/password_prompt.js +2 -2
- package/lib/web/pdf_attachment_viewer.js +1 -1
- package/lib/web/pdf_cursor_tools.js +1 -1
- package/lib/web/pdf_document_properties.js +188 -119
- package/lib/web/pdf_find_bar.js +1 -1
- package/lib/web/pdf_find_controller.js +3 -3
- package/lib/web/pdf_find_utils.js +1 -1
- package/lib/web/pdf_history.js +1 -1
- package/lib/web/pdf_link_service.js +2 -2
- package/lib/web/pdf_outline_viewer.js +53 -28
- package/lib/web/pdf_page_view.js +9 -18
- package/lib/web/pdf_presentation_mode.js +1 -1
- package/lib/web/pdf_print_service.js +5 -3
- package/lib/web/pdf_rendering_queue.js +4 -7
- package/lib/web/pdf_sidebar.js +24 -17
- package/lib/web/pdf_sidebar_resizer.js +1 -1
- package/lib/web/pdf_single_page_viewer.js +1 -1
- package/lib/web/pdf_thumbnail_view.js +2 -2
- package/lib/web/pdf_thumbnail_viewer.js +3 -3
- package/lib/web/pdf_viewer.component.js +3 -3
- package/lib/web/pdf_viewer.js +3 -3
- package/lib/web/preferences.js +30 -30
- package/lib/web/secondary_toolbar.js +1 -1
- package/lib/web/text_layer_builder.js +23 -45
- package/lib/web/toolbar.js +1 -1
- package/lib/web/ui_utils.js +14 -14
- package/lib/web/view_history.js +15 -15
- package/lib/web/viewer_compatibility.js +1 -1
- package/package.json +1 -1
- package/web/pdf_viewer.css +21 -10
- package/web/pdf_viewer.js +126 -194
- package/web/pdf_viewer.js.map +1 -1
- package/lib/display/dom_utils.js +0 -494
- package/lib/test/unit/dom_utils_spec.js +0 -89
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 2019 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.
|
@@ -32,8 +32,6 @@ var _util = require("../shared/util");
|
|
32
32
|
|
33
33
|
var _cmap = require("./cmap");
|
34
34
|
|
35
|
-
var _stream = require("./stream");
|
36
|
-
|
37
35
|
var _primitives = require("./primitives");
|
38
36
|
|
39
37
|
var _fonts = require("./fonts");
|
@@ -52,8 +50,12 @@ var _bidi = require("./bidi");
|
|
52
50
|
|
53
51
|
var _colorspace = require("./colorspace");
|
54
52
|
|
53
|
+
var _stream = require("./stream");
|
54
|
+
|
55
55
|
var _glyphlist = require("./glyphlist");
|
56
56
|
|
57
|
+
var _core_utils = require("./core_utils");
|
58
|
+
|
57
59
|
var _metrics = require("./metrics");
|
58
60
|
|
59
61
|
var _function = require("./function");
|
@@ -62,11 +64,13 @@ var _jpeg_stream = require("./jpeg_stream");
|
|
62
64
|
|
63
65
|
var _murmurhash = require("./murmurhash3");
|
64
66
|
|
67
|
+
var _image_utils = require("./image_utils");
|
68
|
+
|
65
69
|
var _operator_list = require("./operator_list");
|
66
70
|
|
67
71
|
var _image = require("./image");
|
68
72
|
|
69
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
73
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
70
74
|
|
71
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); } }
|
72
76
|
|
@@ -82,77 +86,19 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
82
86
|
isEvalSupported: true
|
83
87
|
};
|
84
88
|
|
85
|
-
function
|
89
|
+
function PartialEvaluator(_ref) {
|
90
|
+
var _this = this;
|
91
|
+
|
86
92
|
var xref = _ref.xref,
|
87
|
-
resources = _ref.resources,
|
88
93
|
handler = _ref.handler,
|
89
|
-
|
90
|
-
|
94
|
+
pageIndex = _ref.pageIndex,
|
95
|
+
idFactory = _ref.idFactory,
|
96
|
+
fontCache = _ref.fontCache,
|
97
|
+
builtInCMapCache = _ref.builtInCMapCache,
|
98
|
+
_ref$options = _ref.options,
|
99
|
+
options = _ref$options === void 0 ? null : _ref$options,
|
91
100
|
pdfFunctionFactory = _ref.pdfFunctionFactory;
|
92
101
|
this.xref = xref;
|
93
|
-
this.resources = resources;
|
94
|
-
this.handler = handler;
|
95
|
-
this.forceDataSchema = forceDataSchema;
|
96
|
-
this.pdfFunctionFactory = pdfFunctionFactory;
|
97
|
-
}
|
98
|
-
|
99
|
-
NativeImageDecoder.prototype = {
|
100
|
-
canDecode: function canDecode(image) {
|
101
|
-
return image instanceof _jpeg_stream.JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources, this.pdfFunctionFactory);
|
102
|
-
},
|
103
|
-
decode: function decode(image) {
|
104
|
-
var dict = image.dict;
|
105
|
-
var colorSpace = dict.get('ColorSpace', 'CS');
|
106
|
-
colorSpace = _colorspace.ColorSpace.parse(colorSpace, this.xref, this.resources, this.pdfFunctionFactory);
|
107
|
-
return this.handler.sendWithPromise('JpegDecode', [image.getIR(this.forceDataSchema), colorSpace.numComps]).then(function (_ref2) {
|
108
|
-
var data = _ref2.data,
|
109
|
-
width = _ref2.width,
|
110
|
-
height = _ref2.height;
|
111
|
-
return new _stream.Stream(data, 0, data.length, image.dict);
|
112
|
-
});
|
113
|
-
}
|
114
|
-
};
|
115
|
-
|
116
|
-
NativeImageDecoder.isSupported = function (image, xref, res, pdfFunctionFactory) {
|
117
|
-
var dict = image.dict;
|
118
|
-
|
119
|
-
if (dict.has('DecodeParms') || dict.has('DP')) {
|
120
|
-
return false;
|
121
|
-
}
|
122
|
-
|
123
|
-
var cs = _colorspace.ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res, pdfFunctionFactory);
|
124
|
-
|
125
|
-
return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
|
126
|
-
};
|
127
|
-
|
128
|
-
NativeImageDecoder.isDecodable = function (image, xref, res, pdfFunctionFactory) {
|
129
|
-
var dict = image.dict;
|
130
|
-
|
131
|
-
if (dict.has('DecodeParms') || dict.has('DP')) {
|
132
|
-
return false;
|
133
|
-
}
|
134
|
-
|
135
|
-
var cs = _colorspace.ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res, pdfFunctionFactory);
|
136
|
-
|
137
|
-
var bpc = dict.get('BitsPerComponent', 'BPC') || 1;
|
138
|
-
return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'), bpc);
|
139
|
-
};
|
140
|
-
|
141
|
-
function PartialEvaluator(_ref3) {
|
142
|
-
var _this = this;
|
143
|
-
|
144
|
-
var pdfManager = _ref3.pdfManager,
|
145
|
-
xref = _ref3.xref,
|
146
|
-
handler = _ref3.handler,
|
147
|
-
pageIndex = _ref3.pageIndex,
|
148
|
-
idFactory = _ref3.idFactory,
|
149
|
-
fontCache = _ref3.fontCache,
|
150
|
-
builtInCMapCache = _ref3.builtInCMapCache,
|
151
|
-
_ref3$options = _ref3.options,
|
152
|
-
options = _ref3$options === void 0 ? null : _ref3$options,
|
153
|
-
pdfFunctionFactory = _ref3.pdfFunctionFactory;
|
154
|
-
this.pdfManager = pdfManager;
|
155
|
-
this.xref = xref;
|
156
102
|
this.handler = handler;
|
157
103
|
this.pageIndex = pageIndex;
|
158
104
|
this.idFactory = idFactory;
|
@@ -160,15 +106,16 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
160
106
|
this.builtInCMapCache = builtInCMapCache;
|
161
107
|
this.options = options || DefaultPartialEvaluatorOptions;
|
162
108
|
this.pdfFunctionFactory = pdfFunctionFactory;
|
109
|
+
this.parsingType3Font = false;
|
163
110
|
|
164
111
|
this.fetchBuiltInCMap =
|
165
112
|
/*#__PURE__*/
|
166
113
|
function () {
|
167
|
-
var
|
114
|
+
var _ref2 = _asyncToGenerator(
|
168
115
|
/*#__PURE__*/
|
169
|
-
_regenerator
|
116
|
+
_regenerator["default"].mark(function _callee(name) {
|
170
117
|
var data;
|
171
|
-
return _regenerator
|
118
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
172
119
|
while (1) {
|
173
120
|
switch (_context.prev = _context.next) {
|
174
121
|
case 0:
|
@@ -199,11 +146,11 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
199
146
|
return _context.stop();
|
200
147
|
}
|
201
148
|
}
|
202
|
-
}, _callee
|
149
|
+
}, _callee);
|
203
150
|
}));
|
204
151
|
|
205
152
|
return function (_x) {
|
206
|
-
return
|
153
|
+
return _ref2.apply(this, arguments);
|
207
154
|
};
|
208
155
|
}();
|
209
156
|
}
|
@@ -435,154 +382,213 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
435
382
|
}
|
436
383
|
});
|
437
384
|
},
|
438
|
-
buildPaintImageXObject: function
|
439
|
-
var
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
_ref5$isInline = _ref5.isInline,
|
444
|
-
isInline = _ref5$isInline === void 0 ? false : _ref5$isInline,
|
445
|
-
operatorList = _ref5.operatorList,
|
446
|
-
cacheKey = _ref5.cacheKey,
|
447
|
-
imageCache = _ref5.imageCache,
|
448
|
-
_ref5$forceDisableNat = _ref5.forceDisableNativeImageDecoder,
|
449
|
-
forceDisableNativeImageDecoder = _ref5$forceDisableNat === void 0 ? false : _ref5$forceDisableNat;
|
450
|
-
var dict = image.dict;
|
451
|
-
var w = dict.get('Width', 'W');
|
452
|
-
var h = dict.get('Height', 'H');
|
453
|
-
|
454
|
-
if (!(w && (0, _util.isNum)(w)) || !(h && (0, _util.isNum)(h))) {
|
455
|
-
(0, _util.warn)('Image dimensions are missing, or not numbers.');
|
456
|
-
return Promise.resolve();
|
457
|
-
}
|
458
|
-
|
459
|
-
var maxImageSize = this.options.maxImageSize;
|
460
|
-
|
461
|
-
if (maxImageSize !== -1 && w * h > maxImageSize) {
|
462
|
-
(0, _util.warn)('Image exceeded maximum allowed size and was removed.');
|
463
|
-
return Promise.resolve();
|
464
|
-
}
|
465
|
-
|
466
|
-
var imageMask = dict.get('ImageMask', 'IM') || false;
|
467
|
-
var imgData, args;
|
468
|
-
|
469
|
-
if (imageMask) {
|
470
|
-
var width = dict.get('Width', 'W');
|
471
|
-
var height = dict.get('Height', 'H');
|
472
|
-
var bitStrideLength = width + 7 >> 3;
|
473
|
-
var imgArray = image.getBytes(bitStrideLength * height, true);
|
474
|
-
var decode = dict.getArray('Decode', 'D');
|
475
|
-
imgData = _image.PDFImage.createMask({
|
476
|
-
imgArray: imgArray,
|
477
|
-
width: width,
|
478
|
-
height: height,
|
479
|
-
imageIsFromDecodeStream: image instanceof _stream.DecodeStream,
|
480
|
-
inverseDecode: !!decode && decode[0] > 0
|
481
|
-
});
|
482
|
-
imgData.cached = true;
|
483
|
-
args = [imgData];
|
484
|
-
operatorList.addOp(_util.OPS.paintImageMaskXObject, args);
|
485
|
-
|
486
|
-
if (cacheKey) {
|
487
|
-
imageCache[cacheKey] = {
|
488
|
-
fn: _util.OPS.paintImageMaskXObject,
|
489
|
-
args: args
|
490
|
-
};
|
491
|
-
}
|
385
|
+
buildPaintImageXObject: function () {
|
386
|
+
var _buildPaintImageXObject = _asyncToGenerator(
|
387
|
+
/*#__PURE__*/
|
388
|
+
_regenerator["default"].mark(function _callee2(_ref3) {
|
389
|
+
var _this2 = this;
|
492
390
|
|
493
|
-
|
494
|
-
}
|
391
|
+
var resources, image, _ref3$isInline, isInline, operatorList, cacheKey, imageCache, _ref3$forceDisableNat, forceDisableNativeImageDecoder, dict, w, h, maxImageSize, imageMask, imgData, args, width, height, bitStrideLength, imgArray, decode, softMask, mask, SMALL_IMAGE_DIMENSIONS, imageObj, nativeImageDecoderSupport, objId, nativeImageDecoder, imgPromise;
|
495
392
|
|
496
|
-
|
497
|
-
|
498
|
-
|
393
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
394
|
+
while (1) {
|
395
|
+
switch (_context2.prev = _context2.next) {
|
396
|
+
case 0:
|
397
|
+
resources = _ref3.resources, image = _ref3.image, _ref3$isInline = _ref3.isInline, isInline = _ref3$isInline === void 0 ? false : _ref3$isInline, operatorList = _ref3.operatorList, cacheKey = _ref3.cacheKey, imageCache = _ref3.imageCache, _ref3$forceDisableNat = _ref3.forceDisableNativeImageDecoder, forceDisableNativeImageDecoder = _ref3$forceDisableNat === void 0 ? false : _ref3$forceDisableNat;
|
398
|
+
dict = image.dict;
|
399
|
+
w = dict.get('Width', 'W');
|
400
|
+
h = dict.get('Height', 'H');
|
499
401
|
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
image: image,
|
505
|
-
isInline: isInline,
|
506
|
-
pdfFunctionFactory: this.pdfFunctionFactory
|
507
|
-
});
|
508
|
-
imgData = imageObj.createImageData(true);
|
509
|
-
operatorList.addOp(_util.OPS.paintInlineImageXObject, [imgData]);
|
510
|
-
return Promise.resolve();
|
511
|
-
}
|
402
|
+
if (!(!(w && (0, _util.isNum)(w)) || !(h && (0, _util.isNum)(h)))) {
|
403
|
+
_context2.next = 7;
|
404
|
+
break;
|
405
|
+
}
|
512
406
|
|
513
|
-
|
514
|
-
|
407
|
+
(0, _util.warn)('Image dimensions are missing, or not numbers.');
|
408
|
+
return _context2.abrupt("return", undefined);
|
515
409
|
|
516
|
-
|
517
|
-
|
518
|
-
operatorList.addDependency(objId);
|
519
|
-
args = [objId, w, h];
|
520
|
-
operatorList.addOp(_util.OPS.paintJpegXObject, args);
|
410
|
+
case 7:
|
411
|
+
maxImageSize = this.options.maxImageSize;
|
521
412
|
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
};
|
527
|
-
}
|
528
|
-
}, function (reason) {
|
529
|
-
(0, _util.warn)('Native JPEG decoding failed -- trying to recover: ' + (reason && reason.message));
|
530
|
-
return _this2.buildPaintImageXObject({
|
531
|
-
resources: resources,
|
532
|
-
image: image,
|
533
|
-
isInline: isInline,
|
534
|
-
operatorList: operatorList,
|
535
|
-
cacheKey: cacheKey,
|
536
|
-
imageCache: imageCache,
|
537
|
-
forceDisableNativeImageDecoder: true
|
538
|
-
});
|
539
|
-
});
|
540
|
-
}
|
413
|
+
if (!(maxImageSize !== -1 && w * h > maxImageSize)) {
|
414
|
+
_context2.next = 11;
|
415
|
+
break;
|
416
|
+
}
|
541
417
|
|
542
|
-
|
418
|
+
(0, _util.warn)('Image exceeded maximum allowed size and was removed.');
|
419
|
+
return _context2.abrupt("return", undefined);
|
543
420
|
|
544
|
-
|
545
|
-
|
546
|
-
xref: this.xref,
|
547
|
-
resources: resources,
|
548
|
-
handler: this.handler,
|
549
|
-
forceDataSchema: this.options.forceDataSchema,
|
550
|
-
pdfFunctionFactory: this.pdfFunctionFactory
|
551
|
-
});
|
552
|
-
}
|
421
|
+
case 11:
|
422
|
+
imageMask = dict.get('ImageMask', 'IM') || false;
|
553
423
|
|
554
|
-
|
555
|
-
|
424
|
+
if (!imageMask) {
|
425
|
+
_context2.next = 24;
|
426
|
+
break;
|
427
|
+
}
|
556
428
|
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
429
|
+
width = dict.get('Width', 'W');
|
430
|
+
height = dict.get('Height', 'H');
|
431
|
+
bitStrideLength = width + 7 >> 3;
|
432
|
+
imgArray = image.getBytes(bitStrideLength * height, true);
|
433
|
+
decode = dict.getArray('Decode', 'D');
|
434
|
+
imgData = _image.PDFImage.createMask({
|
435
|
+
imgArray: imgArray,
|
436
|
+
width: width,
|
437
|
+
height: height,
|
438
|
+
imageIsFromDecodeStream: image instanceof _stream.DecodeStream,
|
439
|
+
inverseDecode: !!decode && decode[0] > 0
|
440
|
+
});
|
441
|
+
imgData.cached = !!cacheKey;
|
442
|
+
args = [imgData];
|
443
|
+
operatorList.addOp(_util.OPS.paintImageMaskXObject, args);
|
444
|
+
|
445
|
+
if (cacheKey) {
|
446
|
+
imageCache[cacheKey] = {
|
447
|
+
fn: _util.OPS.paintImageMaskXObject,
|
448
|
+
args: args
|
449
|
+
};
|
450
|
+
}
|
567
451
|
|
568
|
-
|
569
|
-
}).catch(function (reason) {
|
570
|
-
(0, _util.warn)('Unable to decode image: ' + reason);
|
452
|
+
return _context2.abrupt("return", undefined);
|
571
453
|
|
572
|
-
|
573
|
-
|
454
|
+
case 24:
|
455
|
+
softMask = dict.get('SMask', 'SM') || false;
|
456
|
+
mask = dict.get('Mask') || false;
|
457
|
+
SMALL_IMAGE_DIMENSIONS = 200;
|
574
458
|
|
575
|
-
|
459
|
+
if (!(isInline && !softMask && !mask && !(image instanceof _jpeg_stream.JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS)) {
|
460
|
+
_context2.next = 32;
|
461
|
+
break;
|
462
|
+
}
|
576
463
|
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
464
|
+
imageObj = new _image.PDFImage({
|
465
|
+
xref: this.xref,
|
466
|
+
res: resources,
|
467
|
+
image: image,
|
468
|
+
isInline: isInline,
|
469
|
+
pdfFunctionFactory: this.pdfFunctionFactory
|
470
|
+
});
|
471
|
+
imgData = imageObj.createImageData(true);
|
472
|
+
operatorList.addOp(_util.OPS.paintInlineImageXObject, [imgData]);
|
473
|
+
return _context2.abrupt("return", undefined);
|
474
|
+
|
475
|
+
case 32:
|
476
|
+
nativeImageDecoderSupport = forceDisableNativeImageDecoder ? _util.NativeImageDecoding.NONE : this.options.nativeImageDecoderSupport;
|
477
|
+
objId = "img_".concat(this.idFactory.createObjId());
|
478
|
+
|
479
|
+
if (this.parsingType3Font) {
|
480
|
+
(0, _util.assert)(nativeImageDecoderSupport === _util.NativeImageDecoding.NONE, 'Type3 image resources should be completely decoded in the worker.');
|
481
|
+
objId = "".concat(this.idFactory.getDocId(), "_type3res_").concat(objId);
|
482
|
+
}
|
483
|
+
|
484
|
+
if (!(nativeImageDecoderSupport !== _util.NativeImageDecoding.NONE && !softMask && !mask && image instanceof _jpeg_stream.JpegStream && _image_utils.NativeImageDecoder.isSupported(image, this.xref, resources, this.pdfFunctionFactory))) {
|
485
|
+
_context2.next = 37;
|
486
|
+
break;
|
487
|
+
}
|
488
|
+
|
489
|
+
return _context2.abrupt("return", this.handler.sendWithPromise('obj', [objId, this.pageIndex, 'JpegStream', image.getIR(this.options.forceDataSchema)]).then(function () {
|
490
|
+
operatorList.addDependency(objId);
|
491
|
+
args = [objId, w, h];
|
492
|
+
operatorList.addOp(_util.OPS.paintJpegXObject, args);
|
493
|
+
|
494
|
+
if (cacheKey) {
|
495
|
+
imageCache[cacheKey] = {
|
496
|
+
fn: _util.OPS.paintJpegXObject,
|
497
|
+
args: args
|
498
|
+
};
|
499
|
+
}
|
500
|
+
}, function (reason) {
|
501
|
+
(0, _util.warn)('Native JPEG decoding failed -- trying to recover: ' + (reason && reason.message));
|
502
|
+
return _this2.buildPaintImageXObject({
|
503
|
+
resources: resources,
|
504
|
+
image: image,
|
505
|
+
isInline: isInline,
|
506
|
+
operatorList: operatorList,
|
507
|
+
cacheKey: cacheKey,
|
508
|
+
imageCache: imageCache,
|
509
|
+
forceDisableNativeImageDecoder: true
|
510
|
+
});
|
511
|
+
}));
|
512
|
+
|
513
|
+
case 37:
|
514
|
+
nativeImageDecoder = null;
|
515
|
+
|
516
|
+
if (nativeImageDecoderSupport === _util.NativeImageDecoding.DECODE && (image instanceof _jpeg_stream.JpegStream || mask instanceof _jpeg_stream.JpegStream || softMask instanceof _jpeg_stream.JpegStream)) {
|
517
|
+
nativeImageDecoder = new _image_utils.NativeImageDecoder({
|
518
|
+
xref: this.xref,
|
519
|
+
resources: resources,
|
520
|
+
handler: this.handler,
|
521
|
+
forceDataSchema: this.options.forceDataSchema,
|
522
|
+
pdfFunctionFactory: this.pdfFunctionFactory
|
523
|
+
});
|
524
|
+
}
|
525
|
+
|
526
|
+
operatorList.addDependency(objId);
|
527
|
+
args = [objId, w, h];
|
528
|
+
imgPromise = _image.PDFImage.buildImage({
|
529
|
+
handler: this.handler,
|
530
|
+
xref: this.xref,
|
531
|
+
res: resources,
|
532
|
+
image: image,
|
533
|
+
isInline: isInline,
|
534
|
+
nativeDecoder: nativeImageDecoder,
|
535
|
+
pdfFunctionFactory: this.pdfFunctionFactory
|
536
|
+
}).then(function (imageObj) {
|
537
|
+
var imgData = imageObj.createImageData(false);
|
538
|
+
|
539
|
+
if (_this2.parsingType3Font) {
|
540
|
+
return _this2.handler.sendWithPromise('commonobj', [objId, 'FontType3Res', imgData], [imgData.data.buffer]);
|
541
|
+
}
|
542
|
+
|
543
|
+
_this2.handler.send('obj', [objId, _this2.pageIndex, 'Image', imgData], [imgData.data.buffer]);
|
544
|
+
|
545
|
+
return undefined;
|
546
|
+
})["catch"](function (reason) {
|
547
|
+
(0, _util.warn)('Unable to decode image: ' + reason);
|
548
|
+
|
549
|
+
if (_this2.parsingType3Font) {
|
550
|
+
return _this2.handler.sendWithPromise('commonobj', [objId, 'FontType3Res', null]);
|
551
|
+
}
|
552
|
+
|
553
|
+
_this2.handler.send('obj', [objId, _this2.pageIndex, 'Image', null]);
|
554
|
+
|
555
|
+
return undefined;
|
556
|
+
});
|
557
|
+
|
558
|
+
if (!this.parsingType3Font) {
|
559
|
+
_context2.next = 45;
|
560
|
+
break;
|
561
|
+
}
|
562
|
+
|
563
|
+
_context2.next = 45;
|
564
|
+
return imgPromise;
|
565
|
+
|
566
|
+
case 45:
|
567
|
+
operatorList.addOp(_util.OPS.paintImageXObject, args);
|
568
|
+
|
569
|
+
if (cacheKey) {
|
570
|
+
imageCache[cacheKey] = {
|
571
|
+
fn: _util.OPS.paintImageXObject,
|
572
|
+
args: args
|
573
|
+
};
|
574
|
+
}
|
575
|
+
|
576
|
+
return _context2.abrupt("return", undefined);
|
577
|
+
|
578
|
+
case 48:
|
579
|
+
case "end":
|
580
|
+
return _context2.stop();
|
581
|
+
}
|
582
|
+
}
|
583
|
+
}, _callee2, this);
|
584
|
+
}));
|
585
|
+
|
586
|
+
function buildPaintImageXObject(_x2) {
|
587
|
+
return _buildPaintImageXObject.apply(this, arguments);
|
582
588
|
}
|
583
589
|
|
584
|
-
return
|
585
|
-
},
|
590
|
+
return buildPaintImageXObject;
|
591
|
+
}(),
|
586
592
|
handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
|
587
593
|
var smaskContent = smask.get('G');
|
588
594
|
var smaskOptions = {
|
@@ -658,7 +664,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
658
664
|
|
659
665
|
return translated.loadType3Data(_this4, resources, operatorList, task).then(function () {
|
660
666
|
return translated;
|
661
|
-
})
|
667
|
+
})["catch"](function (reason) {
|
662
668
|
_this4.handler.send('UnsupportedFeature', {
|
663
669
|
featureId: _util.UNSUPPORTED_FEATURES.font
|
664
670
|
});
|
@@ -823,7 +829,8 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
823
829
|
|
824
830
|
var fontCapability = (0, _util.createPromiseCapability)();
|
825
831
|
var preEvaluatedFont = this.preEvaluateFont(font);
|
826
|
-
var descriptor = preEvaluatedFont.descriptor
|
832
|
+
var descriptor = preEvaluatedFont.descriptor,
|
833
|
+
hash = preEvaluatedFont.hash;
|
827
834
|
var fontRefIsRef = (0, _primitives.isRef)(fontRef),
|
828
835
|
fontID;
|
829
836
|
|
@@ -831,13 +838,12 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
831
838
|
fontID = fontRef.toString();
|
832
839
|
}
|
833
840
|
|
834
|
-
if ((0, _primitives.isDict)(descriptor)) {
|
841
|
+
if (hash && (0, _primitives.isDict)(descriptor)) {
|
835
842
|
if (!descriptor.fontAliases) {
|
836
843
|
descriptor.fontAliases = Object.create(null);
|
837
844
|
}
|
838
845
|
|
839
846
|
var fontAliases = descriptor.fontAliases;
|
840
|
-
var hash = preEvaluatedFont.hash;
|
841
847
|
|
842
848
|
if (fontAliases[hash]) {
|
843
849
|
var aliasFontRef = fontAliases[hash].aliasRef;
|
@@ -866,11 +872,11 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
866
872
|
fontID = this.idFactory.createObjId();
|
867
873
|
}
|
868
874
|
|
869
|
-
this.fontCache.put(
|
875
|
+
this.fontCache.put("id_".concat(fontID), fontCapability.promise);
|
870
876
|
}
|
871
877
|
|
872
878
|
(0, _util.assert)(fontID, 'The "fontID" must be defined.');
|
873
|
-
font.loadedName =
|
879
|
+
font.loadedName = "".concat(this.idFactory.getDocId(), "_f").concat(fontID);
|
874
880
|
font.translated = fontCapability.promise;
|
875
881
|
var translatedPromise;
|
876
882
|
|
@@ -887,13 +893,12 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
887
893
|
}
|
888
894
|
|
889
895
|
fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
|
890
|
-
})
|
896
|
+
})["catch"](function (reason) {
|
891
897
|
_this6.handler.send('UnsupportedFeature', {
|
892
898
|
featureId: _util.UNSUPPORTED_FEATURES.font
|
893
899
|
});
|
894
900
|
|
895
901
|
try {
|
896
|
-
var descriptor = preEvaluatedFont.descriptor;
|
897
902
|
var fontFile3 = descriptor && descriptor.get('FontFile3');
|
898
903
|
var subtype = fontFile3 && fontFile3.get('Subtype');
|
899
904
|
var fontType = (0, _fonts.getFontType)(preEvaluatedFont.type, subtype && subtype.name);
|
@@ -905,7 +910,8 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
905
910
|
});
|
906
911
|
return fontCapability.promise;
|
907
912
|
},
|
908
|
-
buildPath: function
|
913
|
+
buildPath: function buildPath(operatorList, fn, args) {
|
914
|
+
var parsingText = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
909
915
|
var lastIndex = operatorList.length - 1;
|
910
916
|
|
911
917
|
if (!args) {
|
@@ -913,47 +919,90 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
913
919
|
}
|
914
920
|
|
915
921
|
if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== _util.OPS.constructPath) {
|
922
|
+
if (parsingText) {
|
923
|
+
(0, _util.warn)("Encountered path operator \"".concat(fn, "\" inside of a text object."));
|
924
|
+
operatorList.addOp(_util.OPS.save, null);
|
925
|
+
}
|
926
|
+
|
916
927
|
operatorList.addOp(_util.OPS.constructPath, [[fn], args]);
|
928
|
+
|
929
|
+
if (parsingText) {
|
930
|
+
operatorList.addOp(_util.OPS.restore, null);
|
931
|
+
}
|
917
932
|
} else {
|
918
933
|
var opArgs = operatorList.argsArray[lastIndex];
|
919
934
|
opArgs[0].push(fn);
|
920
935
|
Array.prototype.push.apply(opArgs[1], args);
|
921
936
|
}
|
922
937
|
},
|
923
|
-
handleColorN: function
|
924
|
-
var
|
925
|
-
|
938
|
+
handleColorN: function () {
|
939
|
+
var _handleColorN = _asyncToGenerator(
|
940
|
+
/*#__PURE__*/
|
941
|
+
_regenerator["default"].mark(function _callee3(operatorList, fn, args, cs, patterns, resources, task) {
|
942
|
+
var patternName, pattern, dict, typeNum, color, shading, matrix;
|
943
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
944
|
+
while (1) {
|
945
|
+
switch (_context3.prev = _context3.next) {
|
946
|
+
case 0:
|
947
|
+
patternName = args[args.length - 1];
|
926
948
|
|
927
|
-
|
928
|
-
|
929
|
-
|
949
|
+
if (!((0, _primitives.isName)(patternName) && (pattern = patterns.get(patternName.name)))) {
|
950
|
+
_context3.next = 16;
|
951
|
+
break;
|
952
|
+
}
|
930
953
|
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
954
|
+
dict = (0, _primitives.isStream)(pattern) ? pattern.dict : pattern;
|
955
|
+
typeNum = dict.get('PatternType');
|
956
|
+
|
957
|
+
if (!(typeNum === TILING_PATTERN)) {
|
958
|
+
_context3.next = 9;
|
959
|
+
break;
|
960
|
+
}
|
961
|
+
|
962
|
+
color = cs.base ? cs.base.getRgb(args, 0) : null;
|
963
|
+
return _context3.abrupt("return", this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task));
|
964
|
+
|
965
|
+
case 9:
|
966
|
+
if (!(typeNum === SHADING_PATTERN)) {
|
967
|
+
_context3.next = 15;
|
968
|
+
break;
|
969
|
+
}
|
970
|
+
|
971
|
+
shading = dict.get('Shading');
|
972
|
+
matrix = dict.getArray('Matrix');
|
973
|
+
pattern = _pattern.Pattern.parseShading(shading, matrix, this.xref, resources, this.handler, this.pdfFunctionFactory);
|
974
|
+
operatorList.addOp(fn, pattern.getIR());
|
975
|
+
return _context3.abrupt("return", undefined);
|
976
|
+
|
977
|
+
case 15:
|
978
|
+
throw new _util.FormatError("Unknown PatternType: ".concat(typeNum));
|
979
|
+
|
980
|
+
case 16:
|
981
|
+
throw new _util.FormatError("Unknown PatternName: ".concat(patternName));
|
982
|
+
|
983
|
+
case 17:
|
984
|
+
case "end":
|
985
|
+
return _context3.stop();
|
986
|
+
}
|
987
|
+
}
|
988
|
+
}, _callee3, this);
|
989
|
+
}));
|
941
990
|
|
942
|
-
|
991
|
+
function handleColorN(_x3, _x4, _x5, _x6, _x7, _x8, _x9) {
|
992
|
+
return _handleColorN.apply(this, arguments);
|
943
993
|
}
|
944
994
|
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
getOperatorList: function getOperatorList(_ref6) {
|
995
|
+
return handleColorN;
|
996
|
+
}(),
|
997
|
+
getOperatorList: function getOperatorList(_ref4) {
|
949
998
|
var _this7 = this;
|
950
999
|
|
951
|
-
var stream =
|
952
|
-
task =
|
953
|
-
resources =
|
954
|
-
operatorList =
|
955
|
-
|
956
|
-
initialState =
|
1000
|
+
var stream = _ref4.stream,
|
1001
|
+
task = _ref4.task,
|
1002
|
+
resources = _ref4.resources,
|
1003
|
+
operatorList = _ref4.operatorList,
|
1004
|
+
_ref4$initialState = _ref4.initialState,
|
1005
|
+
initialState = _ref4$initialState === void 0 ? null : _ref4$initialState;
|
957
1006
|
resources = resources || _primitives.Dict.empty;
|
958
1007
|
initialState = initialState || new EvalState();
|
959
1008
|
|
@@ -963,6 +1012,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
963
1012
|
|
964
1013
|
var self = this;
|
965
1014
|
var xref = this.xref;
|
1015
|
+
var parsingText = false;
|
966
1016
|
var imageCache = Object.create(null);
|
967
1017
|
|
968
1018
|
var xobjs = resources.get('XObject') || _primitives.Dict.empty;
|
@@ -1064,7 +1114,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1064
1114
|
}
|
1065
1115
|
|
1066
1116
|
resolveXObject();
|
1067
|
-
})
|
1117
|
+
})["catch"](function (reason) {
|
1068
1118
|
if (self.options.ignoreErrors) {
|
1069
1119
|
self.handler.send('UnsupportedFeature', {
|
1070
1120
|
featureId: _util.UNSUPPORTED_FEATURES.unknown
|
@@ -1085,6 +1135,14 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1085
1135
|
}));
|
1086
1136
|
return;
|
1087
1137
|
|
1138
|
+
case _util.OPS.beginText:
|
1139
|
+
parsingText = true;
|
1140
|
+
break;
|
1141
|
+
|
1142
|
+
case _util.OPS.endText:
|
1143
|
+
parsingText = false;
|
1144
|
+
break;
|
1145
|
+
|
1088
1146
|
case _util.OPS.endInlineImage:
|
1089
1147
|
var cacheKey = args[0].cacheKey;
|
1090
1148
|
|
@@ -1266,11 +1324,8 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1266
1324
|
case _util.OPS.curveTo2:
|
1267
1325
|
case _util.OPS.curveTo3:
|
1268
1326
|
case _util.OPS.closePath:
|
1269
|
-
self.buildPath(operatorList, fn, args);
|
1270
|
-
continue;
|
1271
|
-
|
1272
1327
|
case _util.OPS.rectangle:
|
1273
|
-
self.buildPath(operatorList, fn, args);
|
1328
|
+
self.buildPath(operatorList, fn, args, parsingText);
|
1274
1329
|
continue;
|
1275
1330
|
|
1276
1331
|
case _util.OPS.markPoint:
|
@@ -1308,7 +1363,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1308
1363
|
|
1309
1364
|
closePendingRestoreOPS();
|
1310
1365
|
resolve();
|
1311
|
-
})
|
1366
|
+
})["catch"](function (reason) {
|
1312
1367
|
if (_this7.options.ignoreErrors) {
|
1313
1368
|
_this7.handler.send('UnsupportedFeature', {
|
1314
1369
|
featureId: _util.UNSUPPORTED_FEATURES.unknown
|
@@ -1322,21 +1377,21 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1322
1377
|
throw reason;
|
1323
1378
|
});
|
1324
1379
|
},
|
1325
|
-
getTextContent: function getTextContent(
|
1380
|
+
getTextContent: function getTextContent(_ref5) {
|
1326
1381
|
var _this8 = this;
|
1327
1382
|
|
1328
|
-
var stream =
|
1329
|
-
task =
|
1330
|
-
resources =
|
1331
|
-
|
1332
|
-
stateManager =
|
1333
|
-
|
1334
|
-
normalizeWhitespace =
|
1335
|
-
|
1336
|
-
combineTextItems =
|
1337
|
-
sink =
|
1338
|
-
|
1339
|
-
seenStyles =
|
1383
|
+
var stream = _ref5.stream,
|
1384
|
+
task = _ref5.task,
|
1385
|
+
resources = _ref5.resources,
|
1386
|
+
_ref5$stateManager = _ref5.stateManager,
|
1387
|
+
stateManager = _ref5$stateManager === void 0 ? null : _ref5$stateManager,
|
1388
|
+
_ref5$normalizeWhites = _ref5.normalizeWhitespace,
|
1389
|
+
normalizeWhitespace = _ref5$normalizeWhites === void 0 ? false : _ref5$normalizeWhites,
|
1390
|
+
_ref5$combineTextItem = _ref5.combineTextItems,
|
1391
|
+
combineTextItems = _ref5$combineTextItem === void 0 ? false : _ref5$combineTextItem,
|
1392
|
+
sink = _ref5.sink,
|
1393
|
+
_ref5$seenStyles = _ref5.seenStyles,
|
1394
|
+
seenStyles = _ref5$seenStyles === void 0 ? Object.create(null) : _ref5$seenStyles;
|
1340
1395
|
resources = resources || _primitives.Dict.empty;
|
1341
1396
|
stateManager = stateManager || new StateManager(new TextState());
|
1342
1397
|
var WhitespaceRegexp = /\s/g;
|
@@ -1391,12 +1446,11 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1391
1446
|
textContentItem.fontName = font.loadedName;
|
1392
1447
|
var tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise];
|
1393
1448
|
|
1394
|
-
if (font.isType3Font && textState.
|
1449
|
+
if (font.isType3Font && textState.fontSize <= 1 && !(0, _util.isArrayEqual)(textState.fontMatrix, _util.FONT_IDENTITY_MATRIX)) {
|
1395
1450
|
var glyphHeight = font.bbox[3] - font.bbox[1];
|
1396
1451
|
|
1397
1452
|
if (glyphHeight > 0) {
|
1398
|
-
|
1399
|
-
tsm[3] *= glyphHeight;
|
1453
|
+
tsm[3] *= glyphHeight * textState.fontMatrix[3];
|
1400
1454
|
}
|
1401
1455
|
}
|
1402
1456
|
|
@@ -1846,7 +1900,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1846
1900
|
|
1847
1901
|
resolveXObject();
|
1848
1902
|
}, rejectXObject);
|
1849
|
-
})
|
1903
|
+
})["catch"](function (reason) {
|
1850
1904
|
if (reason instanceof _util.AbortException) {
|
1851
1905
|
return;
|
1852
1906
|
}
|
@@ -1901,7 +1955,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1901
1955
|
flushTextContentItem();
|
1902
1956
|
enqueueChunk();
|
1903
1957
|
resolve();
|
1904
|
-
})
|
1958
|
+
})["catch"](function (reason) {
|
1905
1959
|
if (reason instanceof _util.AbortException) {
|
1906
1960
|
return;
|
1907
1961
|
}
|
@@ -1919,7 +1973,8 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1919
1973
|
extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) {
|
1920
1974
|
var _this9 = this;
|
1921
1975
|
|
1922
|
-
var xref = this.xref
|
1976
|
+
var xref = this.xref,
|
1977
|
+
cidToGidBytes;
|
1923
1978
|
var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
|
1924
1979
|
var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
|
1925
1980
|
|
@@ -1937,7 +1992,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
1937
1992
|
var cidToGidMap = dict.get('CIDToGIDMap');
|
1938
1993
|
|
1939
1994
|
if ((0, _primitives.isStream)(cidToGidMap)) {
|
1940
|
-
|
1995
|
+
cidToGidBytes = cidToGidMap.getBytes();
|
1941
1996
|
}
|
1942
1997
|
}
|
1943
1998
|
|
@@ -2014,6 +2069,11 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2014
2069
|
return _this9.buildToUnicode(properties);
|
2015
2070
|
}).then(function (toUnicode) {
|
2016
2071
|
properties.toUnicode = toUnicode;
|
2072
|
+
|
2073
|
+
if (cidToGidBytes) {
|
2074
|
+
properties.cidToGidMap = _this9.readCidToGidMap(cidToGidBytes, toUnicode);
|
2075
|
+
}
|
2076
|
+
|
2017
2077
|
return properties;
|
2018
2078
|
});
|
2019
2079
|
},
|
@@ -2194,18 +2254,17 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2194
2254
|
|
2195
2255
|
return Promise.resolve(null);
|
2196
2256
|
},
|
2197
|
-
readCidToGidMap: function
|
2198
|
-
var glyphsData = cidToGidStream.getBytes();
|
2257
|
+
readCidToGidMap: function readCidToGidMap(glyphsData, toUnicode) {
|
2199
2258
|
var result = [];
|
2200
2259
|
|
2201
2260
|
for (var j = 0, jj = glyphsData.length; j < jj; j++) {
|
2202
2261
|
var glyphID = glyphsData[j++] << 8 | glyphsData[j];
|
2262
|
+
var code = j >> 1;
|
2203
2263
|
|
2204
|
-
if (glyphID === 0) {
|
2264
|
+
if (glyphID === 0 && !toUnicode.has(code)) {
|
2205
2265
|
continue;
|
2206
2266
|
}
|
2207
2267
|
|
2208
|
-
var code = j >> 1;
|
2209
2268
|
result[code] = glyphID;
|
2210
2269
|
}
|
2211
2270
|
|
@@ -2440,6 +2499,9 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2440
2499
|
}
|
2441
2500
|
}
|
2442
2501
|
|
2502
|
+
var firstChar = dict.get('FirstChar') || 0;
|
2503
|
+
var lastChar = dict.get('LastChar') || (composite ? 0xFFFF : 0xFF);
|
2504
|
+
hash.update("".concat(firstChar, "-").concat(lastChar));
|
2443
2505
|
var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
|
2444
2506
|
|
2445
2507
|
if ((0, _primitives.isStream)(toUnicode)) {
|
@@ -2645,8 +2707,8 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|
2645
2707
|
_iteratorError = err;
|
2646
2708
|
} finally {
|
2647
2709
|
try {
|
2648
|
-
if (!_iteratorNormalCompletion && _iterator
|
2649
|
-
_iterator
|
2710
|
+
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
|
2711
|
+
_iterator["return"]();
|
2650
2712
|
}
|
2651
2713
|
} finally {
|
2652
2714
|
if (_didIteratorError) {
|
@@ -2699,7 +2761,9 @@ var TranslatedFont = function TranslatedFontClosure() {
|
|
2699
2761
|
|
2700
2762
|
var type3Options = Object.create(evaluator.options);
|
2701
2763
|
type3Options.ignoreErrors = false;
|
2764
|
+
type3Options.nativeImageDecoderSupport = _util.NativeImageDecoding.NONE;
|
2702
2765
|
var type3Evaluator = evaluator.clone(type3Options);
|
2766
|
+
type3Evaluator.parsingType3Font = true;
|
2703
2767
|
var translatedFont = this.font;
|
2704
2768
|
var loadCharProcsPromise = Promise.resolve();
|
2705
2769
|
var charProcs = this.dict.get('CharProcs');
|
@@ -2720,7 +2784,7 @@ var TranslatedFont = function TranslatedFontClosure() {
|
|
2720
2784
|
}).then(function () {
|
2721
2785
|
charProcOperatorList[key] = operatorList.getIR();
|
2722
2786
|
parentOperatorList.addDependencies(operatorList.dependencies);
|
2723
|
-
})
|
2787
|
+
})["catch"](function (reason) {
|
2724
2788
|
(0, _util.warn)("Type3 font resource \"".concat(key, "\" is not available."));
|
2725
2789
|
var operatorList = new _operator_list.OperatorList();
|
2726
2790
|
charProcOperatorList[key] = operatorList.getIR();
|
@@ -2887,7 +2951,7 @@ var EvalState = function EvalStateClosure() {
|
|
2887
2951
|
}();
|
2888
2952
|
|
2889
2953
|
var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
|
2890
|
-
var getOPMap = (0,
|
2954
|
+
var getOPMap = (0, _core_utils.getLookupTableFactory)(function (t) {
|
2891
2955
|
t['w'] = {
|
2892
2956
|
id: _util.OPS.setLineWidth,
|
2893
2957
|
numArgs: 1,
|
@@ -3268,7 +3332,10 @@ var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
|
|
3268
3332
|
|
3269
3333
|
function EvaluatorPreprocessor(stream, xref, stateManager) {
|
3270
3334
|
this.opMap = getOPMap();
|
3271
|
-
this.parser = new _parser.Parser(
|
3335
|
+
this.parser = new _parser.Parser({
|
3336
|
+
lexer: new _parser.Lexer(stream, this.opMap),
|
3337
|
+
xref: xref
|
3338
|
+
});
|
3272
3339
|
this.stateManager = stateManager;
|
3273
3340
|
this.nonProcessedArgs = [];
|
3274
3341
|
this._numInvalidPathOPS = 0;
|