pdfjs-dist 2.0.489 → 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 (169) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +18515 -11402
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +1 -1
  6. package/build/pdf.worker.js +48266 -37137
  7. package/build/pdf.worker.js.map +1 -1
  8. package/build/pdf.worker.min.js +1 -1
  9. package/external/url/url-lib.js +627 -0
  10. package/image_decoders/pdf.image_decoders.js +11350 -0
  11. package/image_decoders/pdf.image_decoders.js.map +1 -0
  12. package/image_decoders/pdf.image_decoders.min.js +1 -0
  13. package/lib/core/annotation.js +587 -242
  14. package/lib/core/arithmetic_decoder.js +275 -245
  15. package/lib/core/bidi.js +65 -6
  16. package/lib/core/ccitt.js +173 -18
  17. package/lib/core/ccitt_stream.js +15 -6
  18. package/lib/core/cff_parser.js +433 -61
  19. package/lib/core/charsets.js +5 -4
  20. package/lib/core/chunked_stream.js +400 -152
  21. package/lib/core/cmap.js +326 -87
  22. package/lib/core/colorspace.js +874 -594
  23. package/lib/core/core_utils.js +147 -0
  24. package/lib/core/crypto.js +290 -45
  25. package/lib/core/document.js +560 -268
  26. package/lib/core/encodings.js +19 -10
  27. package/lib/core/evaluator.js +1005 -360
  28. package/lib/core/font_renderer.js +331 -97
  29. package/lib/core/fonts.js +812 -195
  30. package/lib/core/function.js +284 -71
  31. package/lib/core/glyphlist.js +4 -3
  32. package/lib/core/image.js +169 -62
  33. package/lib/core/image_utils.js +111 -0
  34. package/lib/core/jbig2.js +479 -66
  35. package/lib/core/jbig2_stream.js +19 -8
  36. package/lib/core/jpeg_stream.js +38 -13
  37. package/lib/core/jpg.js +253 -29
  38. package/lib/core/jpx.js +396 -6
  39. package/lib/core/jpx_stream.js +18 -6
  40. package/lib/core/metrics.js +15 -15
  41. package/lib/core/murmurhash3.js +56 -34
  42. package/lib/core/obj.js +1354 -488
  43. package/lib/core/operator_list.js +144 -31
  44. package/lib/core/parser.js +539 -191
  45. package/lib/core/pattern.js +148 -14
  46. package/lib/core/pdf_manager.js +323 -133
  47. package/lib/core/primitives.js +111 -24
  48. package/lib/core/ps_parser.js +134 -45
  49. package/lib/core/standard_fonts.js +17 -17
  50. package/lib/core/stream.js +313 -34
  51. package/lib/core/type1_parser.js +143 -13
  52. package/lib/core/unicode.js +32 -5
  53. package/lib/core/worker.js +217 -190
  54. package/lib/core/worker_stream.js +277 -0
  55. package/lib/display/annotation_layer.js +450 -133
  56. package/lib/display/api.js +1597 -784
  57. package/lib/display/api_compatibility.js +11 -13
  58. package/lib/display/canvas.js +360 -44
  59. package/lib/display/content_disposition.js +83 -32
  60. package/lib/display/display_utils.js +747 -0
  61. package/lib/display/fetch_stream.js +221 -90
  62. package/lib/display/font_loader.js +468 -236
  63. package/lib/display/metadata.js +38 -16
  64. package/lib/display/network.js +635 -428
  65. package/lib/display/network_utils.js +32 -19
  66. package/lib/display/node_stream.js +367 -175
  67. package/lib/display/pattern_helper.js +81 -31
  68. package/lib/display/svg.js +1235 -519
  69. package/lib/display/text_layer.js +153 -29
  70. package/lib/display/transport_stream.js +345 -94
  71. package/lib/display/webgl.js +64 -18
  72. package/lib/display/worker_options.js +5 -4
  73. package/lib/display/xml_parser.js +166 -53
  74. package/lib/examples/node/domstubs.js +60 -4
  75. package/lib/pdf.js +36 -14
  76. package/lib/pdf.worker.js +5 -3
  77. package/lib/shared/compatibility.js +158 -564
  78. package/lib/shared/global_scope.js +2 -2
  79. package/lib/shared/is_node.js +4 -4
  80. package/lib/shared/message_handler.js +521 -0
  81. package/lib/shared/streams_polyfill.js +21 -17
  82. package/lib/shared/url_polyfill.js +56 -0
  83. package/lib/shared/util.js +243 -710
  84. package/lib/test/unit/annotation_spec.js +870 -401
  85. package/lib/test/unit/api_spec.js +657 -345
  86. package/lib/test/unit/bidi_spec.js +7 -7
  87. package/lib/test/unit/cff_parser_spec.js +54 -11
  88. package/lib/test/unit/clitests_helper.js +10 -8
  89. package/lib/test/unit/cmap_spec.js +95 -41
  90. package/lib/test/unit/colorspace_spec.js +115 -63
  91. package/lib/test/unit/core_utils_spec.js +191 -0
  92. package/lib/test/unit/crypto_spec.js +17 -5
  93. package/lib/test/unit/custom_spec.js +43 -55
  94. package/lib/test/unit/display_svg_spec.js +34 -18
  95. package/lib/test/unit/display_utils_spec.js +273 -0
  96. package/lib/test/unit/document_spec.js +8 -13
  97. package/lib/test/unit/encodings_spec.js +25 -45
  98. package/lib/test/unit/evaluator_spec.js +38 -15
  99. package/lib/test/unit/fetch_stream_spec.js +109 -0
  100. package/lib/test/unit/function_spec.js +17 -5
  101. package/lib/test/unit/jasmine-boot.js +33 -20
  102. package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
  103. package/lib/test/unit/metadata_spec.js +71 -11
  104. package/lib/test/unit/murmurhash3_spec.js +3 -3
  105. package/lib/test/unit/network_spec.js +19 -54
  106. package/lib/test/unit/network_utils_spec.js +91 -14
  107. package/lib/test/unit/node_stream_spec.js +56 -32
  108. package/lib/test/unit/parser_spec.js +162 -71
  109. package/lib/test/unit/pdf_find_controller_spec.js +230 -0
  110. package/lib/test/unit/pdf_find_utils_spec.js +63 -0
  111. package/lib/test/unit/pdf_history_spec.js +21 -9
  112. package/lib/test/unit/primitives_spec.js +53 -20
  113. package/lib/test/unit/stream_spec.js +12 -4
  114. package/lib/test/unit/test_utils.js +273 -56
  115. package/lib/test/unit/testreporter.js +21 -3
  116. package/lib/test/unit/type1_parser_spec.js +8 -6
  117. package/lib/test/unit/ui_utils_spec.js +454 -16
  118. package/lib/test/unit/unicode_spec.js +18 -15
  119. package/lib/test/unit/util_spec.js +87 -128
  120. package/lib/web/annotation_layer_builder.js +39 -22
  121. package/lib/web/app.js +1290 -588
  122. package/lib/web/app_options.js +100 -62
  123. package/lib/web/base_viewer.js +511 -182
  124. package/lib/web/chromecom.js +261 -117
  125. package/lib/web/debugger.js +166 -22
  126. package/lib/web/download_manager.js +32 -13
  127. package/lib/web/firefox_print_service.js +20 -10
  128. package/lib/web/firefoxcom.js +315 -80
  129. package/lib/web/genericcom.js +89 -30
  130. package/lib/web/genericl10n.js +142 -30
  131. package/lib/web/grab_to_pan.js +28 -4
  132. package/lib/web/interfaces.js +170 -47
  133. package/lib/web/overlay_manager.js +235 -85
  134. package/lib/web/password_prompt.js +22 -14
  135. package/lib/web/pdf_attachment_viewer.js +38 -18
  136. package/lib/web/pdf_cursor_tools.js +39 -16
  137. package/lib/web/pdf_document_properties.js +255 -136
  138. package/lib/web/pdf_find_bar.js +84 -40
  139. package/lib/web/pdf_find_controller.js +495 -184
  140. package/lib/web/pdf_find_utils.js +111 -0
  141. package/lib/web/pdf_history.js +190 -53
  142. package/lib/web/pdf_link_service.js +138 -77
  143. package/lib/web/pdf_outline_viewer.js +122 -46
  144. package/lib/web/pdf_page_view.js +191 -67
  145. package/lib/web/pdf_presentation_mode.js +99 -34
  146. package/lib/web/pdf_print_service.js +61 -13
  147. package/lib/web/pdf_rendering_queue.js +28 -9
  148. package/lib/web/pdf_sidebar.js +141 -81
  149. package/lib/web/pdf_sidebar_resizer.js +42 -16
  150. package/lib/web/pdf_single_page_viewer.js +74 -66
  151. package/lib/web/pdf_thumbnail_view.js +104 -33
  152. package/lib/web/pdf_thumbnail_viewer.js +66 -26
  153. package/lib/web/pdf_viewer.component.js +112 -32
  154. package/lib/web/pdf_viewer.js +91 -52
  155. package/lib/web/preferences.js +284 -89
  156. package/lib/web/secondary_toolbar.js +165 -40
  157. package/lib/web/text_layer_builder.js +134 -59
  158. package/lib/web/toolbar.js +78 -43
  159. package/lib/web/ui_utils.js +462 -136
  160. package/lib/web/view_history.js +215 -67
  161. package/lib/web/viewer_compatibility.js +4 -13
  162. package/package.json +5 -4
  163. package/web/pdf_viewer.css +79 -11
  164. package/web/pdf_viewer.js +6107 -3748
  165. package/web/pdf_viewer.js.map +1 -1
  166. package/lib/display/dom_utils.js +0 -309
  167. package/lib/test/unit/dom_utils_spec.js +0 -89
  168. package/lib/test/unit/fonts_spec.js +0 -81
  169. package/lib/web/dom_events.js +0 -137
@@ -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 2017 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.
@@ -19,23 +19,39 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
- exports.PDFDocumentProperties = undefined;
27
+ exports.PDFDocumentProperties = void 0;
28
28
 
29
- var _slicedToArray = function () { function sliceIterator(arr, i) { 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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
29
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
30
30
 
31
- var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
31
+ var _pdf = require("../pdf");
32
32
 
33
- var _ui_utils = require('./ui_utils');
33
+ var _ui_utils = require("./ui_utils");
34
34
 
35
- var _pdf = require('../pdf');
35
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
36
+
37
+ 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); } }
38
+
39
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
40
+
41
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
42
+
43
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
44
+
45
+ function _iterableToArrayLimit(arr, i) { 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; }
46
+
47
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
36
48
 
37
49
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
38
50
 
51
+ 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); } }
52
+
53
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
54
+
39
55
  var DEFAULT_FIELD_CONTENT = '-';
40
56
  var NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
41
57
  var US_PAGE_NAMES = {
@@ -46,21 +62,23 @@ var METRIC_PAGE_NAMES = {
46
62
  '297x420': 'A3',
47
63
  '210x297': 'A4'
48
64
  };
65
+
49
66
  function getPageName(size, isPortrait, pageNames) {
50
67
  var width = isPortrait ? size.width : size.height;
51
68
  var height = isPortrait ? size.height : size.width;
52
- return pageNames[width + 'x' + height];
69
+ return pageNames["".concat(width, "x").concat(height)];
53
70
  }
54
71
 
55
- var PDFDocumentProperties = function () {
72
+ var PDFDocumentProperties =
73
+ /*#__PURE__*/
74
+ function () {
56
75
  function PDFDocumentProperties(_ref, overlayManager, eventBus) {
76
+ var _this = this;
77
+
57
78
  var overlayName = _ref.overlayName,
58
79
  fields = _ref.fields,
59
80
  container = _ref.container,
60
81
  closeButton = _ref.closeButton;
61
-
62
- var _this = this;
63
-
64
82
  var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
65
83
 
66
84
  _classCallCheck(this, PDFDocumentProperties);
@@ -70,11 +88,15 @@ var PDFDocumentProperties = function () {
70
88
  this.container = container;
71
89
  this.overlayManager = overlayManager;
72
90
  this.l10n = l10n;
91
+
73
92
  this._reset();
93
+
74
94
  if (closeButton) {
75
95
  closeButton.addEventListener('click', this.close.bind(this));
76
96
  }
97
+
77
98
  this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
99
+
78
100
  if (eventBus) {
79
101
  eventBus.on('pagechanging', function (evt) {
80
102
  _this._currentPageNumber = evt.pageNumber;
@@ -83,6 +105,7 @@ var PDFDocumentProperties = function () {
83
105
  _this._pagesRotation = evt.pagesRotation;
84
106
  });
85
107
  }
108
+
86
109
  this._isNonMetricLocale = true;
87
110
  l10n.getLanguage().then(function (locale) {
88
111
  _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
@@ -90,7 +113,7 @@ var PDFDocumentProperties = function () {
90
113
  }
91
114
 
92
115
  _createClass(PDFDocumentProperties, [{
93
- key: 'open',
116
+ key: "open",
94
117
  value: function open() {
95
118
  var _this2 = this;
96
119
 
@@ -102,30 +125,34 @@ var PDFDocumentProperties = function () {
102
125
  configurable: true
103
126
  });
104
127
  };
128
+
105
129
  Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
106
130
  var currentPageNumber = _this2._currentPageNumber;
107
131
  var pagesRotation = _this2._pagesRotation;
132
+
108
133
  if (_this2.fieldData && currentPageNumber === _this2.fieldData['_currentPageNumber'] && pagesRotation === _this2.fieldData['_pagesRotation']) {
109
134
  _this2._updateUI();
135
+
110
136
  return;
111
137
  }
138
+
112
139
  _this2.pdfDocument.getMetadata().then(function (_ref2) {
113
140
  var info = _ref2.info,
114
141
  metadata = _ref2.metadata,
115
142
  contentDispositionFilename = _ref2.contentDispositionFilename;
116
-
117
- return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(_this2.url), _this2._parseFileSize(_this2.maybeFileSize), _this2._parseDate(info.CreationDate), _this2._parseDate(info.ModDate), _this2.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
143
+ return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(_this2.url || ''), _this2._parseFileSize(_this2.maybeFileSize), _this2._parseDate(info.CreationDate), _this2._parseDate(info.ModDate), _this2.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
118
144
  return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
119
- })]);
145
+ }), _this2._parseLinearization(info.IsLinearized)]);
120
146
  }).then(function (_ref3) {
121
- var _ref4 = _slicedToArray(_ref3, 7),
147
+ var _ref4 = _slicedToArray(_ref3, 8),
122
148
  info = _ref4[0],
123
149
  metadata = _ref4[1],
124
150
  fileName = _ref4[2],
125
151
  fileSize = _ref4[3],
126
152
  creationDate = _ref4[4],
127
153
  modDate = _ref4[5],
128
- pageSize = _ref4[6];
154
+ pageSize = _ref4[6],
155
+ isLinearized = _ref4[7];
129
156
 
130
157
  freezeFieldData({
131
158
  'fileName': fileName,
@@ -141,55 +168,65 @@ var PDFDocumentProperties = function () {
141
168
  'version': info.PDFFormatVersion,
142
169
  'pageCount': _this2.pdfDocument.numPages,
143
170
  'pageSize': pageSize,
171
+ 'linearized': isLinearized,
144
172
  '_currentPageNumber': currentPageNumber,
145
173
  '_pagesRotation': pagesRotation
146
174
  });
175
+
147
176
  _this2._updateUI();
177
+
148
178
  return _this2.pdfDocument.getDownloadInfo();
149
179
  }).then(function (_ref5) {
150
180
  var length = _ref5.length;
151
-
152
181
  _this2.maybeFileSize = length;
153
182
  return _this2._parseFileSize(length);
154
183
  }).then(function (fileSize) {
155
184
  if (fileSize === _this2.fieldData['fileSize']) {
156
185
  return;
157
186
  }
158
- var data = (0, _ui_utils.cloneObj)(_this2.fieldData);
187
+
188
+ var data = Object.assign(Object.create(null), _this2.fieldData);
159
189
  data['fileSize'] = fileSize;
160
190
  freezeFieldData(data);
191
+
161
192
  _this2._updateUI();
162
193
  });
163
194
  });
164
195
  }
165
196
  }, {
166
- key: 'close',
197
+ key: "close",
167
198
  value: function close() {
168
199
  this.overlayManager.close(this.overlayName);
169
200
  }
170
201
  }, {
171
- key: 'setDocument',
172
- value: function setDocument(pdfDocument, url) {
202
+ key: "setDocument",
203
+ value: function setDocument(pdfDocument) {
204
+ var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
205
+
173
206
  if (this.pdfDocument) {
174
207
  this._reset();
208
+
175
209
  this._updateUI(true);
176
210
  }
211
+
177
212
  if (!pdfDocument) {
178
213
  return;
179
214
  }
215
+
180
216
  this.pdfDocument = pdfDocument;
181
217
  this.url = url;
218
+
182
219
  this._dataAvailableCapability.resolve();
183
220
  }
184
221
  }, {
185
- key: 'setFileSize',
222
+ key: "setFileSize",
186
223
  value: function setFileSize(fileSize) {
187
224
  if (Number.isInteger(fileSize) && fileSize > 0) {
188
225
  this.maybeFileSize = fileSize;
189
226
  }
190
227
  }
191
228
  }, {
192
- key: '_reset',
229
+ key: "_reset",
193
230
  value: function _reset() {
194
231
  this.pdfDocument = null;
195
232
  this.url = null;
@@ -200,7 +237,7 @@ var PDFDocumentProperties = function () {
200
237
  this._pagesRotation = 0;
201
238
  }
202
239
  }, {
203
- key: '_updateUI',
240
+ key: "_updateUI",
204
241
  value: function _updateUI() {
205
242
  var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
206
243
 
@@ -208,134 +245,216 @@ var PDFDocumentProperties = function () {
208
245
  for (var id in this.fields) {
209
246
  this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
210
247
  }
248
+
211
249
  return;
212
250
  }
251
+
213
252
  if (this.overlayManager.active !== this.overlayName) {
214
253
  return;
215
254
  }
255
+
216
256
  for (var _id in this.fields) {
217
257
  var content = this.fieldData[_id];
218
258
  this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
219
259
  }
220
260
  }
221
261
  }, {
222
- key: '_parseFileSize',
223
- value: function _parseFileSize() {
224
- var fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
225
-
226
- var kb = fileSize / 1024;
227
- if (!kb) {
228
- return Promise.resolve(undefined);
229
- } else if (kb < 1024) {
230
- return this.l10n.get('document_properties_kb', {
231
- size_kb: (+kb.toPrecision(3)).toLocaleString(),
232
- size_b: fileSize.toLocaleString()
233
- }, '{{size_kb}} KB ({{size_b}} bytes)');
262
+ key: "_parseFileSize",
263
+ value: function () {
264
+ var _parseFileSize2 = _asyncToGenerator(
265
+ /*#__PURE__*/
266
+ _regenerator["default"].mark(function _callee() {
267
+ var fileSize,
268
+ kb,
269
+ _args = arguments;
270
+ return _regenerator["default"].wrap(function _callee$(_context) {
271
+ while (1) {
272
+ switch (_context.prev = _context.next) {
273
+ case 0:
274
+ fileSize = _args.length > 0 && _args[0] !== undefined ? _args[0] : 0;
275
+ kb = fileSize / 1024;
276
+
277
+ if (kb) {
278
+ _context.next = 6;
279
+ break;
280
+ }
281
+
282
+ return _context.abrupt("return", undefined);
283
+
284
+ case 6:
285
+ if (!(kb < 1024)) {
286
+ _context.next = 8;
287
+ break;
288
+ }
289
+
290
+ return _context.abrupt("return", this.l10n.get('document_properties_kb', {
291
+ size_kb: (+kb.toPrecision(3)).toLocaleString(),
292
+ size_b: fileSize.toLocaleString()
293
+ }, '{{size_kb}} KB ({{size_b}} bytes)'));
294
+
295
+ case 8:
296
+ return _context.abrupt("return", this.l10n.get('document_properties_mb', {
297
+ size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
298
+ size_b: fileSize.toLocaleString()
299
+ }, '{{size_mb}} MB ({{size_b}} bytes)'));
300
+
301
+ case 9:
302
+ case "end":
303
+ return _context.stop();
304
+ }
305
+ }
306
+ }, _callee, this);
307
+ }));
308
+
309
+ function _parseFileSize() {
310
+ return _parseFileSize2.apply(this, arguments);
234
311
  }
235
- return this.l10n.get('document_properties_mb', {
236
- size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
237
- size_b: fileSize.toLocaleString()
238
- }, '{{size_mb}} MB ({{size_b}} bytes)');
239
- }
312
+
313
+ return _parseFileSize;
314
+ }()
240
315
  }, {
241
- key: '_parsePageSize',
242
- value: function _parsePageSize(pageSizeInches, pagesRotation) {
243
- var _this3 = this;
316
+ key: "_parsePageSize",
317
+ value: function () {
318
+ var _parsePageSize2 = _asyncToGenerator(
319
+ /*#__PURE__*/
320
+ _regenerator["default"].mark(function _callee2(pageSizeInches, pagesRotation) {
321
+ var _this3 = this;
244
322
 
245
- if (!pageSizeInches) {
246
- return Promise.resolve(undefined);
247
- }
248
- if (pagesRotation % 180 !== 0) {
249
- pageSizeInches = {
250
- width: pageSizeInches.height,
251
- height: pageSizeInches.width
252
- };
253
- }
254
- var isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
255
- var sizeInches = {
256
- width: Math.round(pageSizeInches.width * 100) / 100,
257
- height: Math.round(pageSizeInches.height * 100) / 100
258
- };
259
- var sizeMillimeters = {
260
- width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
261
- height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
262
- };
263
- var pageName = null;
264
- var name = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
265
- if (!name && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
266
- var exactMillimeters = {
267
- width: pageSizeInches.width * 25.4,
268
- height: pageSizeInches.height * 25.4
269
- };
270
- var intMillimeters = {
271
- width: Math.round(sizeMillimeters.width),
272
- height: Math.round(sizeMillimeters.height)
273
- };
274
- if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
275
- name = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
276
- if (name) {
277
- sizeInches = {
278
- width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
279
- height: Math.round(intMillimeters.height / 25.4 * 100) / 100
280
- };
281
- sizeMillimeters = intMillimeters;
323
+ var isPortrait, sizeInches, sizeMillimeters, pageName, name, exactMillimeters, intMillimeters;
324
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
325
+ while (1) {
326
+ switch (_context2.prev = _context2.next) {
327
+ case 0:
328
+ if (pageSizeInches) {
329
+ _context2.next = 2;
330
+ break;
331
+ }
332
+
333
+ return _context2.abrupt("return", undefined);
334
+
335
+ case 2:
336
+ if (pagesRotation % 180 !== 0) {
337
+ pageSizeInches = {
338
+ width: pageSizeInches.height,
339
+ height: pageSizeInches.width
340
+ };
341
+ }
342
+
343
+ isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
344
+ sizeInches = {
345
+ width: Math.round(pageSizeInches.width * 100) / 100,
346
+ height: Math.round(pageSizeInches.height * 100) / 100
347
+ };
348
+ sizeMillimeters = {
349
+ width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
350
+ height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
351
+ };
352
+ pageName = null;
353
+ name = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
354
+
355
+ if (!name && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
356
+ exactMillimeters = {
357
+ width: pageSizeInches.width * 25.4,
358
+ height: pageSizeInches.height * 25.4
359
+ };
360
+ intMillimeters = {
361
+ width: Math.round(sizeMillimeters.width),
362
+ height: Math.round(sizeMillimeters.height)
363
+ };
364
+
365
+ if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
366
+ name = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
367
+
368
+ if (name) {
369
+ sizeInches = {
370
+ width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
371
+ height: Math.round(intMillimeters.height / 25.4 * 100) / 100
372
+ };
373
+ sizeMillimeters = intMillimeters;
374
+ }
375
+ }
376
+ }
377
+
378
+ if (name) {
379
+ pageName = this.l10n.get('document_properties_page_size_name_' + name.toLowerCase(), null, name);
380
+ }
381
+
382
+ return _context2.abrupt("return", Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get('document_properties_page_size_unit_' + (this._isNonMetricLocale ? 'inches' : 'millimeters'), null, this._isNonMetricLocale ? 'in' : 'mm'), pageName, this.l10n.get('document_properties_page_size_orientation_' + (isPortrait ? 'portrait' : 'landscape'), null, isPortrait ? 'portrait' : 'landscape')]).then(function (_ref6) {
383
+ var _ref7 = _slicedToArray(_ref6, 4),
384
+ _ref7$ = _ref7[0],
385
+ width = _ref7$.width,
386
+ height = _ref7$.height,
387
+ unit = _ref7[1],
388
+ name = _ref7[2],
389
+ orientation = _ref7[3];
390
+
391
+ return _this3.l10n.get('document_properties_page_size_dimension_' + (name ? 'name_' : '') + 'string', {
392
+ width: width.toLocaleString(),
393
+ height: height.toLocaleString(),
394
+ unit: unit,
395
+ name: name,
396
+ orientation: orientation
397
+ }, '{{width}} × {{height}} {{unit}} (' + (name ? '{{name}}, ' : '') + '{{orientation}})');
398
+ }));
399
+
400
+ case 11:
401
+ case "end":
402
+ return _context2.stop();
403
+ }
282
404
  }
283
- }
284
- }
285
- if (name) {
286
- pageName = this.l10n.get('document_properties_page_size_name_' + name.toLowerCase(), null, name);
405
+ }, _callee2, this);
406
+ }));
407
+
408
+ function _parsePageSize(_x, _x2) {
409
+ return _parsePageSize2.apply(this, arguments);
287
410
  }
288
- return Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get('document_properties_page_size_unit_' + (this._isNonMetricLocale ? 'inches' : 'millimeters'), null, this._isNonMetricLocale ? 'in' : 'mm'), pageName, this.l10n.get('document_properties_page_size_orientation_' + (isPortrait ? 'portrait' : 'landscape'), null, isPortrait ? 'portrait' : 'landscape')]).then(function (_ref6) {
289
- var _ref7 = _slicedToArray(_ref6, 4),
290
- _ref7$ = _ref7[0],
291
- width = _ref7$.width,
292
- height = _ref7$.height,
293
- unit = _ref7[1],
294
- name = _ref7[2],
295
- orientation = _ref7[3];
296
-
297
- return _this3.l10n.get('document_properties_page_size_dimension_' + (name ? 'name_' : '') + 'string', {
298
- width: width.toLocaleString(),
299
- height: height.toLocaleString(),
300
- unit: unit,
301
- name: name,
302
- orientation: orientation
303
- }, '{{width}} × {{height}} {{unit}} (' + (name ? '{{name}}, ' : '') + '{{orientation}})');
304
- });
305
- }
411
+
412
+ return _parsePageSize;
413
+ }()
306
414
  }, {
307
- key: '_parseDate',
308
- value: function _parseDate(inputDate) {
309
- if (!inputDate) {
310
- return;
311
- }
312
- var dateToParse = inputDate;
313
- if (dateToParse.substring(0, 2) === 'D:') {
314
- dateToParse = dateToParse.substring(2);
315
- }
316
- var year = parseInt(dateToParse.substring(0, 4), 10);
317
- var month = parseInt(dateToParse.substring(4, 6), 10) - 1;
318
- var day = parseInt(dateToParse.substring(6, 8), 10);
319
- var hours = parseInt(dateToParse.substring(8, 10), 10);
320
- var minutes = parseInt(dateToParse.substring(10, 12), 10);
321
- var seconds = parseInt(dateToParse.substring(12, 14), 10);
322
- var utRel = dateToParse.substring(14, 15);
323
- var offsetHours = parseInt(dateToParse.substring(15, 17), 10);
324
- var offsetMinutes = parseInt(dateToParse.substring(18, 20), 10);
325
- if (utRel === '-') {
326
- hours += offsetHours;
327
- minutes += offsetMinutes;
328
- } else if (utRel === '+') {
329
- hours -= offsetHours;
330
- minutes -= offsetMinutes;
415
+ key: "_parseDate",
416
+ value: function () {
417
+ var _parseDate2 = _asyncToGenerator(
418
+ /*#__PURE__*/
419
+ _regenerator["default"].mark(function _callee3(inputDate) {
420
+ var dateObject;
421
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
422
+ while (1) {
423
+ switch (_context3.prev = _context3.next) {
424
+ case 0:
425
+ dateObject = _pdf.PDFDateString.toDateObject(inputDate);
426
+
427
+ if (dateObject) {
428
+ _context3.next = 3;
429
+ break;
430
+ }
431
+
432
+ return _context3.abrupt("return", undefined);
433
+
434
+ case 3:
435
+ return _context3.abrupt("return", this.l10n.get('document_properties_date_string', {
436
+ date: dateObject.toLocaleDateString(),
437
+ time: dateObject.toLocaleTimeString()
438
+ }, '{{date}}, {{time}}'));
439
+
440
+ case 4:
441
+ case "end":
442
+ return _context3.stop();
443
+ }
444
+ }
445
+ }, _callee3, this);
446
+ }));
447
+
448
+ function _parseDate(_x3) {
449
+ return _parseDate2.apply(this, arguments);
331
450
  }
332
- var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
333
- var dateString = date.toLocaleDateString();
334
- var timeString = date.toLocaleTimeString();
335
- return this.l10n.get('document_properties_date_string', {
336
- date: dateString,
337
- time: timeString
338
- }, '{{date}}, {{time}}');
451
+
452
+ return _parseDate;
453
+ }()
454
+ }, {
455
+ key: "_parseLinearization",
456
+ value: function _parseLinearization(isLinearized) {
457
+ return this.l10n.get('document_properties_linearized_' + (isLinearized ? 'yes' : 'no'), null, isLinearized ? 'Yes' : 'No');
339
458
  }
340
459
  }]);
341
460