pdfjs-dist 2.2.228 → 2.3.200

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.

Files changed (84) hide show
  1. package/bower.json +1 -1
  2. package/build/pdf.js +8851 -8582
  3. package/build/pdf.js.map +1 -1
  4. package/build/pdf.min.js +1 -1
  5. package/build/pdf.worker.js +8717 -8394
  6. package/build/pdf.worker.js.map +1 -1
  7. package/build/pdf.worker.min.js +1 -1
  8. package/image_decoders/pdf.image_decoders.js +3014 -2864
  9. package/image_decoders/pdf.image_decoders.js.map +1 -1
  10. package/image_decoders/pdf.image_decoders.min.js +1 -1
  11. package/lib/core/annotation.js +203 -39
  12. package/lib/core/chunked_stream.js +32 -9
  13. package/lib/core/core_utils.js +48 -22
  14. package/lib/core/document.js +44 -33
  15. package/lib/core/evaluator.js +68 -32
  16. package/lib/core/fonts.js +2 -2
  17. package/lib/core/glyphlist.js +1 -0
  18. package/lib/core/image.js +1 -1
  19. package/lib/core/jbig2.js +23 -6
  20. package/lib/core/jpg.js +54 -23
  21. package/lib/core/jpx.js +23 -6
  22. package/lib/core/obj.js +18 -16
  23. package/lib/core/operator_list.js +17 -14
  24. package/lib/core/parser.js +9 -12
  25. package/lib/core/pattern.js +22 -7
  26. package/lib/core/pdf_manager.js +4 -4
  27. package/lib/core/primitives.js +63 -42
  28. package/lib/core/stream.js +14 -0
  29. package/lib/core/type1_parser.js +9 -1
  30. package/lib/core/worker.js +17 -56
  31. package/lib/display/annotation_layer.js +194 -85
  32. package/lib/display/api.js +331 -213
  33. package/lib/display/canvas.js +6 -1
  34. package/lib/display/content_disposition.js +1 -1
  35. package/lib/display/display_utils.js +48 -18
  36. package/lib/display/network_utils.js +6 -0
  37. package/lib/display/pattern_helper.js +22 -5
  38. package/lib/display/svg.js +1 -1
  39. package/lib/display/text_layer.js +62 -53
  40. package/lib/display/xml_parser.js +1 -1
  41. package/lib/pdf.js +2 -3
  42. package/lib/pdf.worker.js +2 -2
  43. package/lib/shared/compatibility.js +23 -19
  44. package/lib/shared/message_handler.js +163 -196
  45. package/lib/shared/streams_polyfill.js +1 -1
  46. package/lib/shared/util.js +288 -196
  47. package/lib/test/unit/annotation_spec.js +687 -93
  48. package/lib/test/unit/api_spec.js +72 -27
  49. package/lib/test/unit/display_utils_spec.js +1 -1
  50. package/lib/test/unit/evaluator_spec.js +21 -5
  51. package/lib/test/unit/fetch_stream_spec.js +3 -1
  52. package/lib/test/unit/message_handler_spec.js +10 -6
  53. package/lib/test/unit/network_spec.js +3 -1
  54. package/lib/test/unit/network_utils_spec.js +14 -0
  55. package/lib/test/unit/node_stream_spec.js +3 -3
  56. package/lib/test/unit/primitives_spec.js +2 -2
  57. package/lib/test/unit/type1_parser_spec.js +1 -1
  58. package/lib/test/unit/ui_utils_spec.js +1 -1
  59. package/lib/test/unit/util_spec.js +10 -10
  60. package/lib/web/app.js +47 -35
  61. package/lib/web/app_options.js +4 -4
  62. package/lib/web/base_viewer.js +36 -12
  63. package/lib/web/chromecom.js +1 -3
  64. package/lib/web/download_manager.js +1 -1
  65. package/lib/web/firefox_print_service.js +7 -4
  66. package/lib/web/firefoxcom.js +10 -5
  67. package/lib/web/interfaces.js +4 -0
  68. package/lib/web/pdf_document_properties.js +1 -1
  69. package/lib/web/pdf_history.js +1 -1
  70. package/lib/web/pdf_link_service.js +7 -3
  71. package/lib/web/pdf_outline_viewer.js +2 -1
  72. package/lib/web/pdf_page_view.js +12 -16
  73. package/lib/web/pdf_print_service.js +3 -5
  74. package/lib/web/pdf_sidebar.js +3 -0
  75. package/lib/web/pdf_viewer.component.js +2 -2
  76. package/lib/web/toolbar.js +2 -0
  77. package/lib/web/ui_utils.js +1 -1
  78. package/package.json +1 -1
  79. package/web/pdf_viewer.css +5 -9
  80. package/web/pdf_viewer.js +60 -45
  81. package/web/pdf_viewer.js.map +1 -1
  82. package/external/streams/streams-lib.js +0 -3962
  83. package/external/url/url-lib.js +0 -627
  84. package/lib/shared/url_polyfill.js +0 -56
@@ -24,6 +24,7 @@
24
24
  Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
+ exports.getQuadPoints = getQuadPoints;
27
28
  exports.MarkupAnnotation = exports.AnnotationFactory = exports.AnnotationBorderStyle = exports.Annotation = void 0;
28
29
 
29
30
  var _util = require("../shared/util");
@@ -56,6 +57,14 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
56
57
 
57
58
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
58
59
 
60
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
61
+
62
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
63
+
64
+ function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
65
+
66
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
67
+
59
68
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
60
69
 
61
70
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
@@ -184,13 +193,47 @@ function () {
184
193
 
185
194
  exports.AnnotationFactory = AnnotationFactory;
186
195
 
187
- function getTransformMatrix(rect, bbox, matrix) {
188
- var bounds = _util.Util.getAxialAlignedBoundingBox(bbox, matrix);
196
+ function getQuadPoints(dict, rect) {
197
+ if (!dict.has('QuadPoints')) {
198
+ return null;
199
+ }
200
+
201
+ var quadPoints = dict.getArray('QuadPoints');
202
+
203
+ if (!Array.isArray(quadPoints) || quadPoints.length % 8 > 0) {
204
+ return null;
205
+ }
206
+
207
+ var quadPointsLists = [];
208
+
209
+ for (var i = 0, ii = quadPoints.length / 8; i < ii; i++) {
210
+ quadPointsLists.push([]);
189
211
 
190
- var minX = bounds[0];
191
- var minY = bounds[1];
192
- var maxX = bounds[2];
193
- var maxY = bounds[3];
212
+ for (var j = i * 8, jj = i * 8 + 8; j < jj; j += 2) {
213
+ var x = quadPoints[j];
214
+ var y = quadPoints[j + 1];
215
+
216
+ if (x < rect[0] || x > rect[2] || y < rect[1] || y > rect[3]) {
217
+ return null;
218
+ }
219
+
220
+ quadPointsLists[i].push({
221
+ x: x,
222
+ y: y
223
+ });
224
+ }
225
+ }
226
+
227
+ return quadPointsLists;
228
+ }
229
+
230
+ function getTransformMatrix(rect, bbox, matrix) {
231
+ var _Util$getAxialAligned = _util.Util.getAxialAlignedBoundingBox(bbox, matrix),
232
+ _Util$getAxialAligned2 = _slicedToArray(_Util$getAxialAligned, 4),
233
+ minX = _Util$getAxialAligned2[0],
234
+ minY = _Util$getAxialAligned2[1],
235
+ maxX = _Util$getAxialAligned2[2],
236
+ maxY = _Util$getAxialAligned2[3];
194
237
 
195
238
  if (minX === maxX || minY === maxY) {
196
239
  return [1, 0, 0, 1, rect[0], rect[1]];
@@ -519,16 +562,34 @@ function () {
519
562
  if (Array.isArray(dashArray) && dashArray.length > 0) {
520
563
  var isValid = true;
521
564
  var allZeros = true;
522
-
523
- for (var i = 0, len = dashArray.length; i < len; i++) {
524
- var element = dashArray[i];
525
- var validNumber = +element >= 0;
526
-
527
- if (!validNumber) {
528
- isValid = false;
529
- break;
530
- } else if (element > 0) {
531
- allZeros = false;
565
+ var _iteratorNormalCompletion = true;
566
+ var _didIteratorError = false;
567
+ var _iteratorError = undefined;
568
+
569
+ try {
570
+ for (var _iterator = dashArray[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
571
+ var element = _step.value;
572
+ var validNumber = +element >= 0;
573
+
574
+ if (!validNumber) {
575
+ isValid = false;
576
+ break;
577
+ } else if (element > 0) {
578
+ allZeros = false;
579
+ }
580
+ }
581
+ } catch (err) {
582
+ _didIteratorError = true;
583
+ _iteratorError = err;
584
+ } finally {
585
+ try {
586
+ if (!_iteratorNormalCompletion && _iterator["return"] != null) {
587
+ _iterator["return"]();
588
+ }
589
+ } finally {
590
+ if (_didIteratorError) {
591
+ throw _iteratorError;
592
+ }
532
593
  }
533
594
  }
534
595
 
@@ -575,15 +636,59 @@ function (_Annotation) {
575
636
  _this2 = _possibleConstructorReturn(this, _getPrototypeOf(MarkupAnnotation).call(this, parameters));
576
637
  var dict = parameters.dict;
577
638
 
578
- if (!dict.has('C')) {
579
- _this2.data.color = null;
639
+ if (dict.has('IRT')) {
640
+ var rawIRT = dict.getRaw('IRT');
641
+ _this2.data.inReplyTo = (0, _primitives.isRef)(rawIRT) ? rawIRT.toString() : null;
642
+ var rt = dict.get('RT');
643
+ _this2.data.replyType = (0, _primitives.isName)(rt) ? rt.name : _util.AnnotationReplyType.REPLY;
580
644
  }
581
645
 
582
- _this2.setCreationDate(dict.get('CreationDate'));
646
+ if (_this2.data.replyType === _util.AnnotationReplyType.GROUP) {
647
+ var parent = dict.get('IRT');
648
+ _this2.data.title = (0, _util.stringToPDFString)(parent.get('T') || '');
649
+
650
+ _this2.setContents(parent.get('Contents'));
651
+
652
+ _this2.data.contents = _this2.contents;
653
+
654
+ if (!parent.has('CreationDate')) {
655
+ _this2.data.creationDate = null;
656
+ } else {
657
+ _this2.setCreationDate(parent.get('CreationDate'));
658
+
659
+ _this2.data.creationDate = _this2.creationDate;
660
+ }
661
+
662
+ if (!parent.has('M')) {
663
+ _this2.data.modificationDate = null;
664
+ } else {
665
+ _this2.setModificationDate(parent.get('M'));
666
+
667
+ _this2.data.modificationDate = _this2.modificationDate;
668
+ }
669
+
670
+ _this2.data.hasPopup = parent.has('Popup');
671
+
672
+ if (!parent.has('C')) {
673
+ _this2.data.color = null;
674
+ } else {
675
+ _this2.setColor(parent.getArray('C'));
676
+
677
+ _this2.data.color = _this2.color;
678
+ }
679
+ } else {
680
+ _this2.data.title = (0, _util.stringToPDFString)(dict.get('T') || '');
681
+
682
+ _this2.setCreationDate(dict.get('CreationDate'));
683
+
684
+ _this2.data.creationDate = _this2.creationDate;
685
+ _this2.data.hasPopup = dict.has('Popup');
686
+
687
+ if (!dict.has('C')) {
688
+ _this2.data.color = null;
689
+ }
690
+ }
583
691
 
584
- _this2.data.creationDate = _this2.creationDate;
585
- _this2.data.hasPopup = dict.has('Popup');
586
- _this2.data.title = (0, _util.stringToPDFString)(dict.get('T') || '');
587
692
  return _this2;
588
693
  }
589
694
 
@@ -854,12 +959,31 @@ function (_WidgetAnnotation2) {
854
959
  return;
855
960
  }
856
961
 
857
- var keys = normalAppearanceState.getKeys();
962
+ var _iteratorNormalCompletion2 = true;
963
+ var _didIteratorError2 = false;
964
+ var _iteratorError2 = undefined;
858
965
 
859
- for (var i = 0, ii = keys.length; i < ii; i++) {
860
- if (keys[i] !== 'Off') {
861
- this.data.buttonValue = keys[i];
862
- break;
966
+ try {
967
+ for (var _iterator2 = normalAppearanceState.getKeys()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
968
+ var key = _step2.value;
969
+
970
+ if (key !== 'Off') {
971
+ this.data.buttonValue = key;
972
+ break;
973
+ }
974
+ }
975
+ } catch (err) {
976
+ _didIteratorError2 = true;
977
+ _iteratorError2 = err;
978
+ } finally {
979
+ try {
980
+ if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
981
+ _iterator2["return"]();
982
+ }
983
+ } finally {
984
+ if (_didIteratorError2) {
985
+ throw _iteratorError2;
986
+ }
863
987
  }
864
988
  }
865
989
  }
@@ -936,6 +1060,7 @@ function (_MarkupAnnotation) {
936
1060
 
937
1061
  var DEFAULT_ICON_SIZE = 22;
938
1062
  _this7 = _possibleConstructorReturn(this, _getPrototypeOf(TextAnnotation).call(this, parameters));
1063
+ var dict = parameters.dict;
939
1064
  _this7.data.annotationType = _util.AnnotationType.TEXT;
940
1065
 
941
1066
  if (_this7.data.hasAppearance) {
@@ -943,7 +1068,15 @@ function (_MarkupAnnotation) {
943
1068
  } else {
944
1069
  _this7.data.rect[1] = _this7.data.rect[3] - DEFAULT_ICON_SIZE;
945
1070
  _this7.data.rect[2] = _this7.data.rect[0] + DEFAULT_ICON_SIZE;
946
- _this7.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
1071
+ _this7.data.name = dict.has('Name') ? dict.get('Name').name : 'Note';
1072
+ }
1073
+
1074
+ if (dict.has('State')) {
1075
+ _this7.data.state = dict.get('State') || null;
1076
+ _this7.data.stateModel = dict.get('StateModel') || null;
1077
+ } else {
1078
+ _this7.data.state = null;
1079
+ _this7.data.stateModel = null;
947
1080
  }
948
1081
 
949
1082
  return _this7;
@@ -964,6 +1097,11 @@ function (_Annotation3) {
964
1097
 
965
1098
  _this8 = _possibleConstructorReturn(this, _getPrototypeOf(LinkAnnotation).call(this, params));
966
1099
  _this8.data.annotationType = _util.AnnotationType.LINK;
1100
+ var quadPoints = getQuadPoints(params.dict, _this8.rectangle);
1101
+
1102
+ if (quadPoints) {
1103
+ _this8.data.quadPoints = quadPoints;
1104
+ }
967
1105
 
968
1106
  _obj.Catalog.parseDestDictionary({
969
1107
  destDict: params.dict,
@@ -989,8 +1127,7 @@ function (_Annotation4) {
989
1127
 
990
1128
  _this9 = _possibleConstructorReturn(this, _getPrototypeOf(PopupAnnotation).call(this, parameters));
991
1129
  _this9.data.annotationType = _util.AnnotationType.POPUP;
992
- var dict = parameters.dict;
993
- var parentItem = dict.get('Parent');
1130
+ var parentItem = parameters.dict.get('Parent');
994
1131
 
995
1132
  if (!parentItem) {
996
1133
  (0, _util.warn)('Popup annotation has a missing or invalid parent annotation.');
@@ -999,9 +1136,13 @@ function (_Annotation4) {
999
1136
 
1000
1137
  var parentSubtype = parentItem.get('Subtype');
1001
1138
  _this9.data.parentType = (0, _primitives.isName)(parentSubtype) ? parentSubtype.name : null;
1002
- _this9.data.parentId = dict.getRaw('Parent').toString();
1003
- _this9.data.title = (0, _util.stringToPDFString)(parentItem.get('T') || '');
1004
- _this9.data.contents = (0, _util.stringToPDFString)(parentItem.get('Contents') || '');
1139
+ var rawParent = parameters.dict.getRaw('Parent');
1140
+ _this9.data.parentId = (0, _primitives.isRef)(rawParent) ? rawParent.toString() : null;
1141
+ var rt = parentItem.get('RT');
1142
+
1143
+ if ((0, _primitives.isName)(rt, _util.AnnotationReplyType.GROUP)) {
1144
+ parentItem = parentItem.get('IRT');
1145
+ }
1005
1146
 
1006
1147
  if (!parentItem.has('M')) {
1007
1148
  _this9.data.modificationDate = null;
@@ -1027,6 +1168,8 @@ function (_Annotation4) {
1027
1168
  }
1028
1169
  }
1029
1170
 
1171
+ _this9.data.title = (0, _util.stringToPDFString)(parentItem.get('T') || '');
1172
+ _this9.data.contents = (0, _util.stringToPDFString)(parentItem.get('Contents') || '');
1030
1173
  return _this9;
1031
1174
  }
1032
1175
 
@@ -1063,8 +1206,7 @@ function (_MarkupAnnotation3) {
1063
1206
 
1064
1207
  _this11 = _possibleConstructorReturn(this, _getPrototypeOf(LineAnnotation).call(this, parameters));
1065
1208
  _this11.data.annotationType = _util.AnnotationType.LINE;
1066
- var dict = parameters.dict;
1067
- _this11.data.lineCoordinates = _util.Util.normalizeRect(dict.getArray('L'));
1209
+ _this11.data.lineCoordinates = _util.Util.normalizeRect(parameters.dict.getArray('L'));
1068
1210
  return _this11;
1069
1211
  }
1070
1212
 
@@ -1119,8 +1261,7 @@ function (_MarkupAnnotation6) {
1119
1261
 
1120
1262
  _this14 = _possibleConstructorReturn(this, _getPrototypeOf(PolylineAnnotation).call(this, parameters));
1121
1263
  _this14.data.annotationType = _util.AnnotationType.POLYLINE;
1122
- var dict = parameters.dict;
1123
- var rawVertices = dict.getArray('Vertices');
1264
+ var rawVertices = parameters.dict.getArray('Vertices');
1124
1265
  _this14.data.vertices = [];
1125
1266
 
1126
1267
  for (var i = 0, ii = rawVertices.length; i < ii; i += 2) {
@@ -1184,9 +1325,8 @@ function (_MarkupAnnotation8) {
1184
1325
 
1185
1326
  _this17 = _possibleConstructorReturn(this, _getPrototypeOf(InkAnnotation).call(this, parameters));
1186
1327
  _this17.data.annotationType = _util.AnnotationType.INK;
1187
- var dict = parameters.dict;
1188
1328
  var xref = parameters.xref;
1189
- var originalInkLists = dict.getArray('InkList');
1329
+ var originalInkLists = parameters.dict.getArray('InkList');
1190
1330
  _this17.data.inkLists = [];
1191
1331
 
1192
1332
  for (var i = 0, ii = originalInkLists.length; i < ii; ++i) {
@@ -1218,6 +1358,12 @@ function (_MarkupAnnotation9) {
1218
1358
 
1219
1359
  _this18 = _possibleConstructorReturn(this, _getPrototypeOf(HighlightAnnotation).call(this, parameters));
1220
1360
  _this18.data.annotationType = _util.AnnotationType.HIGHLIGHT;
1361
+ var quadPoints = getQuadPoints(parameters.dict, _this18.rectangle);
1362
+
1363
+ if (quadPoints) {
1364
+ _this18.data.quadPoints = quadPoints;
1365
+ }
1366
+
1221
1367
  return _this18;
1222
1368
  }
1223
1369
 
@@ -1236,6 +1382,12 @@ function (_MarkupAnnotation10) {
1236
1382
 
1237
1383
  _this19 = _possibleConstructorReturn(this, _getPrototypeOf(UnderlineAnnotation).call(this, parameters));
1238
1384
  _this19.data.annotationType = _util.AnnotationType.UNDERLINE;
1385
+ var quadPoints = getQuadPoints(parameters.dict, _this19.rectangle);
1386
+
1387
+ if (quadPoints) {
1388
+ _this19.data.quadPoints = quadPoints;
1389
+ }
1390
+
1239
1391
  return _this19;
1240
1392
  }
1241
1393
 
@@ -1254,6 +1406,12 @@ function (_MarkupAnnotation11) {
1254
1406
 
1255
1407
  _this20 = _possibleConstructorReturn(this, _getPrototypeOf(SquigglyAnnotation).call(this, parameters));
1256
1408
  _this20.data.annotationType = _util.AnnotationType.SQUIGGLY;
1409
+ var quadPoints = getQuadPoints(parameters.dict, _this20.rectangle);
1410
+
1411
+ if (quadPoints) {
1412
+ _this20.data.quadPoints = quadPoints;
1413
+ }
1414
+
1257
1415
  return _this20;
1258
1416
  }
1259
1417
 
@@ -1272,6 +1430,12 @@ function (_MarkupAnnotation12) {
1272
1430
 
1273
1431
  _this21 = _possibleConstructorReturn(this, _getPrototypeOf(StrikeOutAnnotation).call(this, parameters));
1274
1432
  _this21.data.annotationType = _util.AnnotationType.STRIKEOUT;
1433
+ var quadPoints = getQuadPoints(parameters.dict, _this21.rectangle);
1434
+
1435
+ if (quadPoints) {
1436
+ _this21.data.quadPoints = quadPoints;
1437
+ }
1438
+
1275
1439
  return _this21;
1276
1440
  }
1277
1441
 
@@ -190,7 +190,10 @@ function () {
190
190
  return -1;
191
191
  }
192
192
 
193
- this.ensureByte(pos);
193
+ if (pos >= this.progressiveDataLength) {
194
+ this.ensureByte(pos);
195
+ }
196
+
194
197
  return this.bytes[this.pos++];
195
198
  }
196
199
  }, {
@@ -223,7 +226,9 @@ function () {
223
226
  var strEnd = this.end;
224
227
 
225
228
  if (!length) {
226
- this.ensureRange(pos, strEnd);
229
+ if (strEnd > this.progressiveDataLength) {
230
+ this.ensureRange(pos, strEnd);
231
+ }
227
232
 
228
233
  var _subarray = bytes.subarray(pos, strEnd);
229
234
 
@@ -236,7 +241,10 @@ function () {
236
241
  end = strEnd;
237
242
  }
238
243
 
239
- this.ensureRange(pos, end);
244
+ if (end > this.progressiveDataLength) {
245
+ this.ensureRange(pos, end);
246
+ }
247
+
240
248
  this.pos = end;
241
249
  var subarray = bytes.subarray(pos, end);
242
250
  return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
@@ -259,7 +267,18 @@ function () {
259
267
  }, {
260
268
  key: "getByteRange",
261
269
  value: function getByteRange(begin, end) {
262
- this.ensureRange(begin, end);
270
+ if (begin < 0) {
271
+ begin = 0;
272
+ }
273
+
274
+ if (end > this.end) {
275
+ end = this.end;
276
+ }
277
+
278
+ if (end > this.progressiveDataLength) {
279
+ this.ensureRange(begin, end);
280
+ }
281
+
263
282
  return this.bytes.subarray(begin, end);
264
283
  }
265
284
  }, {
@@ -285,9 +304,13 @@ function () {
285
304
  key: "makeSubStream",
286
305
  value: function makeSubStream(start, length, dict) {
287
306
  if (length) {
288
- this.ensureRange(start, start + length);
307
+ if (start + length > this.progressiveDataLength) {
308
+ this.ensureRange(start, start + length);
309
+ }
289
310
  } else {
290
- this.ensureByte(start);
311
+ if (start >= this.progressiveDataLength) {
312
+ this.ensureByte(start);
313
+ }
291
314
  }
292
315
 
293
316
  function ChunkedStreamSubstream() {}
@@ -714,15 +737,15 @@ function () {
714
737
  }
715
738
  }, {
716
739
  key: "abort",
717
- value: function abort() {
740
+ value: function abort(reason) {
718
741
  this.aborted = true;
719
742
 
720
743
  if (this.pdfNetworkStream) {
721
- this.pdfNetworkStream.cancelAllRequests('abort');
744
+ this.pdfNetworkStream.cancelAllRequests(reason);
722
745
  }
723
746
 
724
747
  for (var requestId in this.promisesByRequest) {
725
- this.promisesByRequest[requestId].reject(new Error('Request was aborted'));
748
+ this.promisesByRequest[requestId].reject(reason);
726
749
  }
727
750
  }
728
751
  }]);
@@ -31,6 +31,20 @@ exports.XRefParseException = exports.XRefEntryException = exports.MissingDataExc
31
31
 
32
32
  var _util = require("../shared/util");
33
33
 
34
+ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
35
+
36
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
37
+
38
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
39
+
40
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
41
+
42
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
43
+
44
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
45
+
46
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
47
+
34
48
  function getLookupTableFactory(initializer) {
35
49
  var lookup;
36
50
  return function () {
@@ -44,44 +58,56 @@ function getLookupTableFactory(initializer) {
44
58
  };
45
59
  }
46
60
 
47
- var MissingDataException = function MissingDataExceptionClosure() {
61
+ var MissingDataException =
62
+ /*#__PURE__*/
63
+ function (_BaseException) {
64
+ _inherits(MissingDataException, _BaseException);
65
+
48
66
  function MissingDataException(begin, end) {
49
- this.begin = begin;
50
- this.end = end;
51
- this.message = "Missing data [".concat(begin, ", ").concat(end, ")");
67
+ var _this;
68
+
69
+ _classCallCheck(this, MissingDataException);
70
+
71
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(MissingDataException).call(this, "Missing data [".concat(begin, ", ").concat(end, ")")));
72
+ _this.begin = begin;
73
+ _this.end = end;
74
+ return _this;
52
75
  }
53
76
 
54
- MissingDataException.prototype = new Error();
55
- MissingDataException.prototype.name = 'MissingDataException';
56
- MissingDataException.constructor = MissingDataException;
57
77
  return MissingDataException;
58
- }();
78
+ }(_util.BaseException);
59
79
 
60
80
  exports.MissingDataException = MissingDataException;
61
81
 
62
- var XRefEntryException = function XRefEntryExceptionClosure() {
63
- function XRefEntryException(msg) {
64
- this.message = msg;
82
+ var XRefEntryException =
83
+ /*#__PURE__*/
84
+ function (_BaseException2) {
85
+ _inherits(XRefEntryException, _BaseException2);
86
+
87
+ function XRefEntryException() {
88
+ _classCallCheck(this, XRefEntryException);
89
+
90
+ return _possibleConstructorReturn(this, _getPrototypeOf(XRefEntryException).apply(this, arguments));
65
91
  }
66
92
 
67
- XRefEntryException.prototype = new Error();
68
- XRefEntryException.prototype.name = 'XRefEntryException';
69
- XRefEntryException.constructor = XRefEntryException;
70
93
  return XRefEntryException;
71
- }();
94
+ }(_util.BaseException);
72
95
 
73
96
  exports.XRefEntryException = XRefEntryException;
74
97
 
75
- var XRefParseException = function XRefParseExceptionClosure() {
76
- function XRefParseException(msg) {
77
- this.message = msg;
98
+ var XRefParseException =
99
+ /*#__PURE__*/
100
+ function (_BaseException3) {
101
+ _inherits(XRefParseException, _BaseException3);
102
+
103
+ function XRefParseException() {
104
+ _classCallCheck(this, XRefParseException);
105
+
106
+ return _possibleConstructorReturn(this, _getPrototypeOf(XRefParseException).apply(this, arguments));
78
107
  }
79
108
 
80
- XRefParseException.prototype = new Error();
81
- XRefParseException.prototype.name = 'XRefParseException';
82
- XRefParseException.constructor = XRefParseException;
83
109
  return XRefParseException;
84
- }();
110
+ }(_util.BaseException);
85
111
 
86
112
  exports.XRefParseException = XRefParseException;
87
113