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.

Files changed (166) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +3349 -2324
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +1 -1
  6. package/build/pdf.worker.js +2804 -1975
  7. package/build/pdf.worker.js.map +1 -1
  8. package/build/pdf.worker.min.js +1 -1
  9. package/image_decoders/pdf.image_decoders.js +431 -511
  10. package/image_decoders/pdf.image_decoders.js.map +1 -1
  11. package/image_decoders/pdf.image_decoders.min.js +1 -1
  12. package/lib/core/annotation.js +294 -224
  13. package/lib/core/arithmetic_decoder.js +1 -1
  14. package/lib/core/bidi.js +1 -1
  15. package/lib/core/ccitt.js +1 -1
  16. package/lib/core/ccitt_stream.js +1 -1
  17. package/lib/core/cff_parser.js +61 -12
  18. package/lib/core/charsets.js +1 -1
  19. package/lib/core/chunked_stream.js +24 -14
  20. package/lib/core/cmap.js +17 -13
  21. package/lib/core/colorspace.js +1 -1
  22. package/lib/core/core_utils.js +147 -0
  23. package/lib/core/crypto.js +1 -1
  24. package/lib/core/document.js +47 -40
  25. package/lib/core/encodings.js +1 -1
  26. package/lib/core/evaluator.js +346 -279
  27. package/lib/core/font_renderer.js +1 -1
  28. package/lib/core/fonts.js +23 -11
  29. package/lib/core/function.js +1 -1
  30. package/lib/core/glyphlist.js +2 -2
  31. package/lib/core/image.js +2 -2
  32. package/lib/core/image_utils.js +111 -0
  33. package/lib/core/jbig2.js +1 -1
  34. package/lib/core/jbig2_stream.js +1 -1
  35. package/lib/core/jpeg_stream.js +1 -1
  36. package/lib/core/jpg.js +2 -1
  37. package/lib/core/jpx.js +1 -1
  38. package/lib/core/jpx_stream.js +1 -1
  39. package/lib/core/metrics.js +13 -13
  40. package/lib/core/murmurhash3.js +37 -33
  41. package/lib/core/obj.js +245 -41
  42. package/lib/core/operator_list.js +43 -32
  43. package/lib/core/parser.js +228 -133
  44. package/lib/core/pattern.js +4 -2
  45. package/lib/core/pdf_manager.js +17 -15
  46. package/lib/core/primitives.js +40 -6
  47. package/lib/core/ps_parser.js +1 -1
  48. package/lib/core/standard_fonts.js +9 -9
  49. package/lib/core/stream.js +1 -1
  50. package/lib/core/type1_parser.js +1 -1
  51. package/lib/core/unicode.js +2 -2
  52. package/lib/core/worker.js +54 -171
  53. package/lib/core/worker_stream.js +277 -0
  54. package/lib/display/annotation_layer.js +112 -33
  55. package/lib/display/api.js +211 -123
  56. package/lib/display/api_compatibility.js +1 -1
  57. package/lib/display/canvas.js +40 -19
  58. package/lib/display/content_disposition.js +1 -1
  59. package/lib/display/display_utils.js +747 -0
  60. package/lib/display/fetch_stream.js +19 -12
  61. package/lib/display/font_loader.js +11 -8
  62. package/lib/display/metadata.js +1 -1
  63. package/lib/display/network.js +563 -521
  64. package/lib/display/network_utils.js +1 -1
  65. package/lib/display/node_stream.js +21 -12
  66. package/lib/display/pattern_helper.js +24 -25
  67. package/lib/display/svg.js +1068 -565
  68. package/lib/display/text_layer.js +24 -14
  69. package/lib/display/transport_stream.js +192 -70
  70. package/lib/display/webgl.js +1 -1
  71. package/lib/display/worker_options.js +1 -1
  72. package/lib/display/xml_parser.js +1 -1
  73. package/lib/examples/node/domstubs.js +4 -1
  74. package/lib/pdf.js +20 -15
  75. package/lib/pdf.worker.js +3 -3
  76. package/lib/shared/compatibility.js +6 -6
  77. package/lib/shared/global_scope.js +1 -1
  78. package/lib/shared/is_node.js +2 -2
  79. package/lib/shared/message_handler.js +7 -7
  80. package/lib/shared/streams_polyfill.js +1 -1
  81. package/lib/shared/url_polyfill.js +1 -1
  82. package/lib/shared/util.js +13 -125
  83. package/lib/test/unit/annotation_spec.js +278 -93
  84. package/lib/test/unit/api_spec.js +198 -188
  85. package/lib/test/unit/bidi_spec.js +1 -1
  86. package/lib/test/unit/cff_parser_spec.js +15 -1
  87. package/lib/test/unit/clitests_helper.js +3 -3
  88. package/lib/test/unit/cmap_spec.js +20 -20
  89. package/lib/test/unit/colorspace_spec.js +17 -12
  90. package/lib/test/unit/core_utils_spec.js +191 -0
  91. package/lib/test/unit/crypto_spec.js +1 -1
  92. package/lib/test/unit/custom_spec.js +8 -8
  93. package/lib/test/unit/display_svg_spec.js +8 -8
  94. package/lib/test/unit/display_utils_spec.js +273 -0
  95. package/lib/test/unit/document_spec.js +7 -12
  96. package/lib/test/unit/encodings_spec.js +5 -5
  97. package/lib/test/unit/evaluator_spec.js +8 -10
  98. package/lib/test/unit/fetch_stream_spec.js +109 -0
  99. package/lib/test/unit/function_spec.js +1 -1
  100. package/lib/test/unit/jasmine-boot.js +4 -4
  101. package/lib/test/unit/message_handler_spec.js +1 -1
  102. package/lib/test/unit/metadata_spec.js +1 -1
  103. package/lib/test/unit/murmurhash3_spec.js +1 -1
  104. package/lib/test/unit/network_spec.js +5 -55
  105. package/lib/test/unit/network_utils_spec.js +51 -1
  106. package/lib/test/unit/node_stream_spec.js +8 -8
  107. package/lib/test/unit/parser_spec.js +150 -86
  108. package/lib/test/unit/pdf_find_controller_spec.js +1 -1
  109. package/lib/test/unit/pdf_find_utils_spec.js +1 -1
  110. package/lib/test/unit/pdf_history_spec.js +1 -1
  111. package/lib/test/unit/primitives_spec.js +30 -17
  112. package/lib/test/unit/stream_spec.js +1 -1
  113. package/lib/test/unit/test_utils.js +197 -43
  114. package/lib/test/unit/testreporter.js +1 -1
  115. package/lib/test/unit/type1_parser_spec.js +1 -1
  116. package/lib/test/unit/ui_utils_spec.js +20 -20
  117. package/lib/test/unit/unicode_spec.js +5 -5
  118. package/lib/test/unit/util_spec.js +1 -164
  119. package/lib/web/annotation_layer_builder.js +1 -1
  120. package/lib/web/app.js +104 -60
  121. package/lib/web/app_options.js +45 -37
  122. package/lib/web/base_viewer.js +7 -7
  123. package/lib/web/chromecom.js +8 -8
  124. package/lib/web/debugger.js +7 -7
  125. package/lib/web/download_manager.js +3 -2
  126. package/lib/web/firefox_print_service.js +4 -2
  127. package/lib/web/firefoxcom.js +50 -19
  128. package/lib/web/genericcom.js +8 -8
  129. package/lib/web/genericl10n.js +10 -10
  130. package/lib/web/grab_to_pan.js +3 -1
  131. package/lib/web/interfaces.js +13 -13
  132. package/lib/web/overlay_manager.js +10 -10
  133. package/lib/web/password_prompt.js +2 -2
  134. package/lib/web/pdf_attachment_viewer.js +1 -1
  135. package/lib/web/pdf_cursor_tools.js +1 -1
  136. package/lib/web/pdf_document_properties.js +188 -119
  137. package/lib/web/pdf_find_bar.js +1 -1
  138. package/lib/web/pdf_find_controller.js +3 -3
  139. package/lib/web/pdf_find_utils.js +1 -1
  140. package/lib/web/pdf_history.js +1 -1
  141. package/lib/web/pdf_link_service.js +2 -2
  142. package/lib/web/pdf_outline_viewer.js +53 -28
  143. package/lib/web/pdf_page_view.js +9 -18
  144. package/lib/web/pdf_presentation_mode.js +1 -1
  145. package/lib/web/pdf_print_service.js +5 -3
  146. package/lib/web/pdf_rendering_queue.js +4 -7
  147. package/lib/web/pdf_sidebar.js +24 -17
  148. package/lib/web/pdf_sidebar_resizer.js +1 -1
  149. package/lib/web/pdf_single_page_viewer.js +1 -1
  150. package/lib/web/pdf_thumbnail_view.js +2 -2
  151. package/lib/web/pdf_thumbnail_viewer.js +3 -3
  152. package/lib/web/pdf_viewer.component.js +3 -3
  153. package/lib/web/pdf_viewer.js +3 -3
  154. package/lib/web/preferences.js +30 -30
  155. package/lib/web/secondary_toolbar.js +1 -1
  156. package/lib/web/text_layer_builder.js +23 -45
  157. package/lib/web/toolbar.js +1 -1
  158. package/lib/web/ui_utils.js +14 -14
  159. package/lib/web/view_history.js +15 -15
  160. package/lib/web/viewer_compatibility.js +1 -1
  161. package/package.json +1 -1
  162. package/web/pdf_viewer.css +21 -10
  163. package/web/pdf_viewer.js +126 -194
  164. package/web/pdf_viewer.js.map +1 -1
  165. package/lib/display/dom_utils.js +0 -494
  166. package/lib/test/unit/dom_utils_spec.js +0 -89
@@ -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 2018 Mozilla Foundation
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.
@@ -26,7 +26,7 @@ Object.defineProperty(exports, "__esModule", {
26
26
  });
27
27
  exports.AnnotationLayer = void 0;
28
28
 
29
- var _dom_utils = require("./dom_utils");
29
+ var _display_utils = require("./display_utils");
30
30
 
31
31
  var _util = require("../shared/util");
32
32
 
@@ -96,6 +96,9 @@ function () {
96
96
  case _util.AnnotationType.POPUP:
97
97
  return new PopupAnnotationElement(parameters);
98
98
 
99
+ case _util.AnnotationType.FREETEXT:
100
+ return new FreeTextAnnotationElement(parameters);
101
+
99
102
  case _util.AnnotationType.LINE:
100
103
  return new LineAnnotationElement(parameters);
101
104
 
@@ -108,6 +111,9 @@ function () {
108
111
  case _util.AnnotationType.POLYLINE:
109
112
  return new PolylineAnnotationElement(parameters);
110
113
 
114
+ case _util.AnnotationType.CARET:
115
+ return new CaretAnnotationElement(parameters);
116
+
111
117
  case _util.AnnotationType.INK:
112
118
  return new InkAnnotationElement(parameters);
113
119
 
@@ -252,6 +258,7 @@ function () {
252
258
  trigger: trigger,
253
259
  color: data.color,
254
260
  title: data.title,
261
+ modificationDate: data.modificationDate,
255
262
  contents: data.contents,
256
263
  hideWrapper: true
257
264
  });
@@ -288,9 +295,9 @@ function (_AnnotationElement) {
288
295
  var data = this.data,
289
296
  linkService = this.linkService;
290
297
  var link = document.createElement('a');
291
- (0, _dom_utils.addLinkAttributes)(link, {
298
+ (0, _display_utils.addLinkAttributes)(link, {
292
299
  url: data.url,
293
- target: data.newWindow ? _dom_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
300
+ target: data.newWindow ? _display_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
294
301
  rel: linkService.externalLinkRel
295
302
  });
296
303
 
@@ -655,6 +662,7 @@ function (_AnnotationElement4) {
655
662
  trigger: parentElement,
656
663
  color: this.data.color,
657
664
  title: this.data.title,
665
+ modificationDate: this.data.modificationDate,
658
666
  contents: this.data.contents
659
667
  });
660
668
  var parentLeft = parseFloat(parentElement.style.left);
@@ -679,6 +687,7 @@ function () {
679
687
  this.trigger = parameters.trigger;
680
688
  this.color = parameters.color;
681
689
  this.title = parameters.title;
690
+ this.modificationDate = parameters.modificationDate;
682
691
  this.contents = parameters.contents;
683
692
  this.hideWrapper = parameters.hideWrapper || false;
684
693
  this.pinned = false;
@@ -703,16 +712,30 @@ function () {
703
712
  popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
704
713
  }
705
714
 
706
- var contents = this._formatContents(this.contents);
707
-
708
715
  var title = document.createElement('h1');
709
716
  title.textContent = this.title;
717
+ popup.appendChild(title);
718
+
719
+ var dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);
720
+
721
+ if (dateObject) {
722
+ var modificationDate = document.createElement('span');
723
+ modificationDate.textContent = '{{date}}, {{time}}';
724
+ modificationDate.dataset.l10nId = 'annotation_date_string';
725
+ modificationDate.dataset.l10nArgs = JSON.stringify({
726
+ date: dateObject.toLocaleDateString(),
727
+ time: dateObject.toLocaleTimeString()
728
+ });
729
+ popup.appendChild(modificationDate);
730
+ }
731
+
732
+ var contents = this._formatContents(this.contents);
733
+
734
+ popup.appendChild(contents);
710
735
  this.trigger.addEventListener('click', this._toggle.bind(this));
711
736
  this.trigger.addEventListener('mouseover', this._show.bind(this, false));
712
737
  this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
713
738
  popup.addEventListener('click', this._hide.bind(this, true));
714
- popup.appendChild(title);
715
- popup.appendChild(contents);
716
739
  wrapper.appendChild(popup);
717
740
  return wrapper;
718
741
  }
@@ -775,10 +798,38 @@ function () {
775
798
  return PopupElement;
776
799
  }();
777
800
 
778
- var LineAnnotationElement =
801
+ var FreeTextAnnotationElement =
779
802
  /*#__PURE__*/
780
803
  function (_AnnotationElement5) {
781
- _inherits(LineAnnotationElement, _AnnotationElement5);
804
+ _inherits(FreeTextAnnotationElement, _AnnotationElement5);
805
+
806
+ function FreeTextAnnotationElement(parameters) {
807
+ _classCallCheck(this, FreeTextAnnotationElement);
808
+
809
+ var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
810
+ return _possibleConstructorReturn(this, _getPrototypeOf(FreeTextAnnotationElement).call(this, parameters, isRenderable, true));
811
+ }
812
+
813
+ _createClass(FreeTextAnnotationElement, [{
814
+ key: "render",
815
+ value: function render() {
816
+ this.container.className = 'freeTextAnnotation';
817
+
818
+ if (!this.data.hasPopup) {
819
+ this._createPopup(this.container, null, this.data);
820
+ }
821
+
822
+ return this.container;
823
+ }
824
+ }]);
825
+
826
+ return FreeTextAnnotationElement;
827
+ }(AnnotationElement);
828
+
829
+ var LineAnnotationElement =
830
+ /*#__PURE__*/
831
+ function (_AnnotationElement6) {
832
+ _inherits(LineAnnotationElement, _AnnotationElement6);
782
833
 
783
834
  function LineAnnotationElement(parameters) {
784
835
  _classCallCheck(this, LineAnnotationElement);
@@ -816,8 +867,8 @@ function (_AnnotationElement5) {
816
867
 
817
868
  var SquareAnnotationElement =
818
869
  /*#__PURE__*/
819
- function (_AnnotationElement6) {
820
- _inherits(SquareAnnotationElement, _AnnotationElement6);
870
+ function (_AnnotationElement7) {
871
+ _inherits(SquareAnnotationElement, _AnnotationElement7);
821
872
 
822
873
  function SquareAnnotationElement(parameters) {
823
874
  _classCallCheck(this, SquareAnnotationElement);
@@ -857,8 +908,8 @@ function (_AnnotationElement6) {
857
908
 
858
909
  var CircleAnnotationElement =
859
910
  /*#__PURE__*/
860
- function (_AnnotationElement7) {
861
- _inherits(CircleAnnotationElement, _AnnotationElement7);
911
+ function (_AnnotationElement8) {
912
+ _inherits(CircleAnnotationElement, _AnnotationElement8);
862
913
 
863
914
  function CircleAnnotationElement(parameters) {
864
915
  _classCallCheck(this, CircleAnnotationElement);
@@ -898,8 +949,8 @@ function (_AnnotationElement7) {
898
949
 
899
950
  var PolylineAnnotationElement =
900
951
  /*#__PURE__*/
901
- function (_AnnotationElement8) {
902
- _inherits(PolylineAnnotationElement, _AnnotationElement8);
952
+ function (_AnnotationElement9) {
953
+ _inherits(PolylineAnnotationElement, _AnnotationElement9);
903
954
 
904
955
  function PolylineAnnotationElement(parameters) {
905
956
  var _this3;
@@ -968,10 +1019,38 @@ function (_PolylineAnnotationEl) {
968
1019
  return PolygonAnnotationElement;
969
1020
  }(PolylineAnnotationElement);
970
1021
 
1022
+ var CaretAnnotationElement =
1023
+ /*#__PURE__*/
1024
+ function (_AnnotationElement10) {
1025
+ _inherits(CaretAnnotationElement, _AnnotationElement10);
1026
+
1027
+ function CaretAnnotationElement(parameters) {
1028
+ _classCallCheck(this, CaretAnnotationElement);
1029
+
1030
+ var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
1031
+ return _possibleConstructorReturn(this, _getPrototypeOf(CaretAnnotationElement).call(this, parameters, isRenderable, true));
1032
+ }
1033
+
1034
+ _createClass(CaretAnnotationElement, [{
1035
+ key: "render",
1036
+ value: function render() {
1037
+ this.container.className = 'caretAnnotation';
1038
+
1039
+ if (!this.data.hasPopup) {
1040
+ this._createPopup(this.container, null, this.data);
1041
+ }
1042
+
1043
+ return this.container;
1044
+ }
1045
+ }]);
1046
+
1047
+ return CaretAnnotationElement;
1048
+ }(AnnotationElement);
1049
+
971
1050
  var InkAnnotationElement =
972
1051
  /*#__PURE__*/
973
- function (_AnnotationElement9) {
974
- _inherits(InkAnnotationElement, _AnnotationElement9);
1052
+ function (_AnnotationElement11) {
1053
+ _inherits(InkAnnotationElement, _AnnotationElement11);
975
1054
 
976
1055
  function InkAnnotationElement(parameters) {
977
1056
  var _this5;
@@ -1028,8 +1107,8 @@ function (_AnnotationElement9) {
1028
1107
 
1029
1108
  var HighlightAnnotationElement =
1030
1109
  /*#__PURE__*/
1031
- function (_AnnotationElement10) {
1032
- _inherits(HighlightAnnotationElement, _AnnotationElement10);
1110
+ function (_AnnotationElement12) {
1111
+ _inherits(HighlightAnnotationElement, _AnnotationElement12);
1033
1112
 
1034
1113
  function HighlightAnnotationElement(parameters) {
1035
1114
  _classCallCheck(this, HighlightAnnotationElement);
@@ -1056,8 +1135,8 @@ function (_AnnotationElement10) {
1056
1135
 
1057
1136
  var UnderlineAnnotationElement =
1058
1137
  /*#__PURE__*/
1059
- function (_AnnotationElement11) {
1060
- _inherits(UnderlineAnnotationElement, _AnnotationElement11);
1138
+ function (_AnnotationElement13) {
1139
+ _inherits(UnderlineAnnotationElement, _AnnotationElement13);
1061
1140
 
1062
1141
  function UnderlineAnnotationElement(parameters) {
1063
1142
  _classCallCheck(this, UnderlineAnnotationElement);
@@ -1084,8 +1163,8 @@ function (_AnnotationElement11) {
1084
1163
 
1085
1164
  var SquigglyAnnotationElement =
1086
1165
  /*#__PURE__*/
1087
- function (_AnnotationElement12) {
1088
- _inherits(SquigglyAnnotationElement, _AnnotationElement12);
1166
+ function (_AnnotationElement14) {
1167
+ _inherits(SquigglyAnnotationElement, _AnnotationElement14);
1089
1168
 
1090
1169
  function SquigglyAnnotationElement(parameters) {
1091
1170
  _classCallCheck(this, SquigglyAnnotationElement);
@@ -1112,8 +1191,8 @@ function (_AnnotationElement12) {
1112
1191
 
1113
1192
  var StrikeOutAnnotationElement =
1114
1193
  /*#__PURE__*/
1115
- function (_AnnotationElement13) {
1116
- _inherits(StrikeOutAnnotationElement, _AnnotationElement13);
1194
+ function (_AnnotationElement15) {
1195
+ _inherits(StrikeOutAnnotationElement, _AnnotationElement15);
1117
1196
 
1118
1197
  function StrikeOutAnnotationElement(parameters) {
1119
1198
  _classCallCheck(this, StrikeOutAnnotationElement);
@@ -1140,8 +1219,8 @@ function (_AnnotationElement13) {
1140
1219
 
1141
1220
  var StampAnnotationElement =
1142
1221
  /*#__PURE__*/
1143
- function (_AnnotationElement14) {
1144
- _inherits(StampAnnotationElement, _AnnotationElement14);
1222
+ function (_AnnotationElement16) {
1223
+ _inherits(StampAnnotationElement, _AnnotationElement16);
1145
1224
 
1146
1225
  function StampAnnotationElement(parameters) {
1147
1226
  _classCallCheck(this, StampAnnotationElement);
@@ -1168,8 +1247,8 @@ function (_AnnotationElement14) {
1168
1247
 
1169
1248
  var FileAttachmentAnnotationElement =
1170
1249
  /*#__PURE__*/
1171
- function (_AnnotationElement15) {
1172
- _inherits(FileAttachmentAnnotationElement, _AnnotationElement15);
1250
+ function (_AnnotationElement17) {
1251
+ _inherits(FileAttachmentAnnotationElement, _AnnotationElement17);
1173
1252
 
1174
1253
  function FileAttachmentAnnotationElement(parameters) {
1175
1254
  var _this6;
@@ -1180,12 +1259,12 @@ function (_AnnotationElement15) {
1180
1259
  var _this6$data$file = _this6.data.file,
1181
1260
  filename = _this6$data$file.filename,
1182
1261
  content = _this6$data$file.content;
1183
- _this6.filename = (0, _dom_utils.getFilenameFromUrl)(filename);
1262
+ _this6.filename = (0, _display_utils.getFilenameFromUrl)(filename);
1184
1263
  _this6.content = content;
1185
1264
 
1186
1265
  if (_this6.linkService.eventBus) {
1187
1266
  _this6.linkService.eventBus.dispatch('fileattachmentannotation', {
1188
- source: _assertThisInitialized(_assertThisInitialized(_this6)),
1267
+ source: _assertThisInitialized(_this6),
1189
1268
  id: (0, _util.stringToPDFString)(filename),
1190
1269
  filename: filename,
1191
1270
  content: content
@@ -1252,7 +1331,7 @@ function () {
1252
1331
  downloadManager: parameters.downloadManager,
1253
1332
  imageResourcesPath: parameters.imageResourcesPath || '',
1254
1333
  renderInteractiveForms: parameters.renderInteractiveForms || false,
1255
- svgFactory: new _dom_utils.DOMSVGFactory()
1334
+ svgFactory: new _display_utils.DOMSVGFactory()
1256
1335
  });
1257
1336
 
1258
1337
  if (element.isRenderable) {