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/document.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,6 +32,8 @@ var _obj = require("./obj");
|
|
32
32
|
|
33
33
|
var _primitives = require("./primitives");
|
34
34
|
|
35
|
+
var _core_utils = require("./core_utils");
|
36
|
+
|
35
37
|
var _stream2 = require("./stream");
|
36
38
|
|
37
39
|
var _annotation = require("./annotation");
|
@@ -92,13 +94,15 @@ function () {
|
|
92
94
|
this.pdfFunctionFactory = pdfFunctionFactory;
|
93
95
|
this.evaluatorOptions = pdfManager.evaluatorOptions;
|
94
96
|
this.resourcesPromise = null;
|
95
|
-
var uniquePrefix = "p".concat(this.pageIndex, "_");
|
96
97
|
var idCounters = {
|
97
98
|
obj: 0
|
98
99
|
};
|
99
100
|
this.idFactory = {
|
100
101
|
createObjId: function createObjId() {
|
101
|
-
return
|
102
|
+
return "p".concat(pageIndex, "_").concat(++idCounters.obj);
|
103
|
+
},
|
104
|
+
getDocId: function getDocId() {
|
105
|
+
return "g_".concat(pdfManager.docId);
|
102
106
|
}
|
103
107
|
};
|
104
108
|
}
|
@@ -107,7 +111,7 @@ function () {
|
|
107
111
|
key: "_getInheritableProperty",
|
108
112
|
value: function _getInheritableProperty(key) {
|
109
113
|
var getArray = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
110
|
-
var value = (0,
|
114
|
+
var value = (0, _core_utils.getInheritableProperty)({
|
111
115
|
dict: this.pageDict,
|
112
116
|
key: key,
|
113
117
|
getArray: getArray,
|
@@ -147,8 +151,8 @@ function () {
|
|
147
151
|
_iteratorError = err;
|
148
152
|
} finally {
|
149
153
|
try {
|
150
|
-
if (!_iteratorNormalCompletion && _iterator
|
151
|
-
_iterator
|
154
|
+
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
|
155
|
+
_iterator["return"]();
|
152
156
|
}
|
153
157
|
} finally {
|
154
158
|
if (_didIteratorError) {
|
@@ -192,7 +196,6 @@ function () {
|
|
192
196
|
var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
|
193
197
|
var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
|
194
198
|
var partialEvaluator = new _evaluator.PartialEvaluator({
|
195
|
-
pdfManager: this.pdfManager,
|
196
199
|
xref: this.xref,
|
197
200
|
handler: handler,
|
198
201
|
pageIndex: this.pageIndex,
|
@@ -250,8 +253,8 @@ function () {
|
|
250
253
|
_iteratorError2 = err;
|
251
254
|
} finally {
|
252
255
|
try {
|
253
|
-
if (!_iteratorNormalCompletion2 && _iterator2
|
254
|
-
_iterator2
|
256
|
+
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
|
257
|
+
_iterator2["return"]();
|
255
258
|
}
|
256
259
|
} finally {
|
257
260
|
if (_didIteratorError2) {
|
@@ -276,8 +279,8 @@ function () {
|
|
276
279
|
_iteratorError3 = err;
|
277
280
|
} finally {
|
278
281
|
try {
|
279
|
-
if (!_iteratorNormalCompletion3 && _iterator3
|
280
|
-
_iterator3
|
282
|
+
if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
|
283
|
+
_iterator3["return"]();
|
281
284
|
}
|
282
285
|
} finally {
|
283
286
|
if (_didIteratorError3) {
|
@@ -310,7 +313,6 @@ function () {
|
|
310
313
|
contentStream = _ref9[0];
|
311
314
|
|
312
315
|
var partialEvaluator = new _evaluator.PartialEvaluator({
|
313
|
-
pdfManager: _this3.pdfManager,
|
314
316
|
xref: _this3.xref,
|
315
317
|
handler: handler,
|
316
318
|
pageIndex: _this3.pageIndex,
|
@@ -455,22 +457,10 @@ exports.Page = Page;
|
|
455
457
|
var FINGERPRINT_FIRST_BYTES = 1024;
|
456
458
|
var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
|
457
459
|
|
458
|
-
function find(stream, needle, limit
|
459
|
-
var
|
460
|
-
|
461
|
-
|
462
|
-
if (pos + limit > end) {
|
463
|
-
limit = end - pos;
|
464
|
-
}
|
465
|
-
|
466
|
-
var strBuf = [];
|
467
|
-
|
468
|
-
for (var i = 0; i < limit; ++i) {
|
469
|
-
strBuf.push(String.fromCharCode(stream.getByte()));
|
470
|
-
}
|
471
|
-
|
472
|
-
var str = strBuf.join('');
|
473
|
-
stream.pos = pos;
|
460
|
+
function find(stream, needle, limit) {
|
461
|
+
var backwards = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
462
|
+
(0, _util.assert)(limit > 0, 'The "limit" must be a positive integer.');
|
463
|
+
var str = (0, _util.bytesToString)(stream.peekBytes(limit));
|
474
464
|
var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
|
475
465
|
|
476
466
|
if (index === -1) {
|
@@ -528,18 +518,32 @@ function () {
|
|
528
518
|
this.xfa = this.acroForm.get('XFA');
|
529
519
|
var fields = this.acroForm.get('Fields');
|
530
520
|
|
531
|
-
if ((!
|
521
|
+
if ((!Array.isArray(fields) || fields.length === 0) && !this.xfa) {
|
532
522
|
this.acroForm = null;
|
533
523
|
}
|
534
524
|
}
|
535
525
|
} catch (ex) {
|
536
|
-
if (ex instanceof
|
526
|
+
if (ex instanceof _core_utils.MissingDataException) {
|
537
527
|
throw ex;
|
538
528
|
}
|
539
529
|
|
540
530
|
(0, _util.info)('Cannot fetch AcroForm entry; assuming no AcroForms are present');
|
541
531
|
this.acroForm = null;
|
542
532
|
}
|
533
|
+
|
534
|
+
try {
|
535
|
+
var collection = this.catalog.catDict.get('Collection');
|
536
|
+
|
537
|
+
if ((0, _primitives.isDict)(collection) && collection.getKeys().length > 0) {
|
538
|
+
this.collection = collection;
|
539
|
+
}
|
540
|
+
} catch (ex) {
|
541
|
+
if (ex instanceof _core_utils.MissingDataException) {
|
542
|
+
throw ex;
|
543
|
+
}
|
544
|
+
|
545
|
+
(0, _util.info)('Cannot fetch Collection dictionary.');
|
546
|
+
}
|
543
547
|
}
|
544
548
|
}, {
|
545
549
|
key: "checkHeader",
|
@@ -585,7 +589,9 @@ function () {
|
|
585
589
|
var catalog = this.catalog,
|
586
590
|
linearization = this.linearization;
|
587
591
|
(0, _util.assert)(linearization && linearization.pageFirst === pageIndex);
|
588
|
-
|
592
|
+
|
593
|
+
var ref = _primitives.Ref.get(linearization.objectNumberFirst, 0);
|
594
|
+
|
589
595
|
return this.xref.fetchAsync(ref).then(function (obj) {
|
590
596
|
if ((0, _primitives.isDict)(obj, 'Page') || (0, _primitives.isDict)(obj) && !obj.has('Type') && obj.has('Contents')) {
|
591
597
|
if (ref && !catalog.pageKidsCountCache.has(ref)) {
|
@@ -596,7 +602,7 @@ function () {
|
|
596
602
|
}
|
597
603
|
|
598
604
|
throw new _util.FormatError('The Linearization dictionary doesn\'t point ' + 'to a valid Page dictionary.');
|
599
|
-
})
|
605
|
+
})["catch"](function (reason) {
|
600
606
|
(0, _util.info)(reason);
|
601
607
|
return catalog.getPageDict(pageIndex);
|
602
608
|
});
|
@@ -635,13 +641,13 @@ function () {
|
|
635
641
|
value: function checkFirstPage() {
|
636
642
|
var _this6 = this;
|
637
643
|
|
638
|
-
return this.getPage(0)
|
639
|
-
if (reason instanceof
|
644
|
+
return this.getPage(0)["catch"](function (reason) {
|
645
|
+
if (reason instanceof _core_utils.XRefEntryException) {
|
640
646
|
_this6._pagePromises.length = 0;
|
641
647
|
|
642
648
|
_this6.cleanup();
|
643
649
|
|
644
|
-
throw new
|
650
|
+
throw new _core_utils.XRefParseException();
|
645
651
|
}
|
646
652
|
});
|
647
653
|
}
|
@@ -663,7 +669,7 @@ function () {
|
|
663
669
|
try {
|
664
670
|
linearization = _parser.Linearization.create(this.stream);
|
665
671
|
} catch (err) {
|
666
|
-
if (err instanceof
|
672
|
+
if (err instanceof _core_utils.MissingDataException) {
|
667
673
|
throw err;
|
668
674
|
}
|
669
675
|
|
@@ -751,14 +757,15 @@ function () {
|
|
751
757
|
PDFFormatVersion: this.pdfFormatVersion,
|
752
758
|
IsLinearized: !!this.linearization,
|
753
759
|
IsAcroFormPresent: !!this.acroForm,
|
754
|
-
IsXFAPresent: !!this.xfa
|
760
|
+
IsXFAPresent: !!this.xfa,
|
761
|
+
IsCollectionPresent: !!this.collection
|
755
762
|
};
|
756
763
|
var infoDict;
|
757
764
|
|
758
765
|
try {
|
759
766
|
infoDict = this.xref.trailer.get('Info');
|
760
767
|
} catch (err) {
|
761
|
-
if (err instanceof
|
768
|
+
if (err instanceof _core_utils.MissingDataException) {
|
762
769
|
throw err;
|
763
770
|
}
|
764
771
|
|
@@ -805,8 +812,8 @@ function () {
|
|
805
812
|
_iteratorError4 = err;
|
806
813
|
} finally {
|
807
814
|
try {
|
808
|
-
if (!_iteratorNormalCompletion4 && _iterator4
|
809
|
-
_iterator4
|
815
|
+
if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) {
|
816
|
+
_iterator4["return"]();
|
810
817
|
}
|
811
818
|
} finally {
|
812
819
|
if (_didIteratorError4) {
|
package/lib/core/encodings.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.
|