pdfjs-dist 2.0.943 → 2.1.266

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 (159) hide show
  1. package/bower.json +1 -1
  2. package/build/pdf.js +15329 -11095
  3. package/build/pdf.js.map +1 -1
  4. package/build/pdf.min.js +1 -1
  5. package/build/pdf.worker.js +12497 -4184
  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 +3438 -1209
  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 +335 -109
  12. package/lib/core/arithmetic_decoder.js +274 -244
  13. package/lib/core/bidi.js +64 -5
  14. package/lib/core/ccitt.js +172 -17
  15. package/lib/core/ccitt_stream.js +14 -5
  16. package/lib/core/cff_parser.js +304 -28
  17. package/lib/core/charsets.js +4 -3
  18. package/lib/core/chunked_stream.js +379 -149
  19. package/lib/core/cmap.js +210 -40
  20. package/lib/core/colorspace.js +332 -187
  21. package/lib/core/crypto.js +289 -44
  22. package/lib/core/document.js +508 -249
  23. package/lib/core/encodings.js +18 -9
  24. package/lib/core/evaluator.js +657 -119
  25. package/lib/core/font_renderer.js +217 -34
  26. package/lib/core/fonts.js +632 -41
  27. package/lib/core/function.js +252 -26
  28. package/lib/core/glyphlist.js +2 -1
  29. package/lib/core/image.js +124 -27
  30. package/lib/core/jbig2.js +425 -65
  31. package/lib/core/jbig2_stream.js +18 -7
  32. package/lib/core/jpeg_stream.js +24 -8
  33. package/lib/core/jpg.js +208 -16
  34. package/lib/core/jpx.js +395 -5
  35. package/lib/core/jpx_stream.js +17 -5
  36. package/lib/core/metrics.js +3 -3
  37. package/lib/core/murmurhash3.js +23 -5
  38. package/lib/core/obj.js +625 -132
  39. package/lib/core/operator_list.js +104 -3
  40. package/lib/core/parser.js +262 -25
  41. package/lib/core/pattern.js +144 -12
  42. package/lib/core/pdf_manager.js +104 -70
  43. package/lib/core/primitives.js +74 -21
  44. package/lib/core/ps_parser.js +133 -44
  45. package/lib/core/standard_fonts.js +9 -9
  46. package/lib/core/stream.js +283 -31
  47. package/lib/core/type1_parser.js +138 -6
  48. package/lib/core/unicode.js +28 -1
  49. package/lib/core/worker.js +192 -57
  50. package/lib/display/annotation_layer.js +303 -123
  51. package/lib/display/api.js +1073 -574
  52. package/lib/display/api_compatibility.js +4 -1
  53. package/lib/display/canvas.js +314 -18
  54. package/lib/display/content_disposition.js +70 -23
  55. package/lib/display/dom_utils.js +112 -59
  56. package/lib/display/fetch_stream.js +95 -50
  57. package/lib/display/font_loader.js +250 -132
  58. package/lib/display/metadata.js +37 -15
  59. package/lib/display/network.js +123 -34
  60. package/lib/display/network_utils.js +23 -10
  61. package/lib/display/node_stream.js +162 -65
  62. package/lib/display/pattern_helper.js +57 -6
  63. package/lib/display/svg.js +194 -18
  64. package/lib/display/text_layer.js +128 -14
  65. package/lib/display/transport_stream.js +83 -27
  66. package/lib/display/webgl.js +63 -17
  67. package/lib/display/worker_options.js +4 -3
  68. package/lib/display/xml_parser.js +162 -52
  69. package/lib/examples/node/domstubs.js +56 -3
  70. package/lib/pdf.js +15 -2
  71. package/lib/pdf.worker.js +4 -2
  72. package/lib/shared/compatibility.js +129 -26
  73. package/lib/shared/global_scope.js +1 -1
  74. package/lib/shared/is_node.js +3 -3
  75. package/lib/shared/message_handler.js +103 -45
  76. package/lib/shared/streams_polyfill.js +20 -16
  77. package/lib/shared/url_polyfill.js +8 -2
  78. package/lib/shared/util.js +246 -84
  79. package/lib/test/unit/annotation_spec.js +99 -73
  80. package/lib/test/unit/api_spec.js +347 -113
  81. package/lib/test/unit/bidi_spec.js +6 -6
  82. package/lib/test/unit/cff_parser_spec.js +17 -5
  83. package/lib/test/unit/clitests_helper.js +7 -8
  84. package/lib/test/unit/cmap_spec.js +79 -25
  85. package/lib/test/unit/colorspace_spec.js +65 -18
  86. package/lib/test/unit/crypto_spec.js +16 -4
  87. package/lib/test/unit/custom_spec.js +40 -52
  88. package/lib/test/unit/display_svg_spec.js +32 -16
  89. package/lib/test/unit/document_spec.js +2 -2
  90. package/lib/test/unit/dom_utils_spec.js +8 -8
  91. package/lib/test/unit/encodings_spec.js +24 -44
  92. package/lib/test/unit/evaluator_spec.js +15 -8
  93. package/lib/test/unit/function_spec.js +16 -4
  94. package/lib/test/unit/jasmine-boot.js +29 -16
  95. package/lib/test/unit/message_handler_spec.js +19 -6
  96. package/lib/test/unit/metadata_spec.js +64 -11
  97. package/lib/test/unit/murmurhash3_spec.js +2 -2
  98. package/lib/test/unit/network_spec.js +19 -4
  99. package/lib/test/unit/network_utils_spec.js +6 -4
  100. package/lib/test/unit/node_stream_spec.js +50 -26
  101. package/lib/test/unit/parser_spec.js +13 -29
  102. package/lib/test/unit/pdf_find_controller_spec.js +144 -32
  103. package/lib/test/unit/pdf_find_utils_spec.js +10 -9
  104. package/lib/test/unit/pdf_history_spec.js +20 -8
  105. package/lib/test/unit/primitives_spec.js +23 -3
  106. package/lib/test/unit/stream_spec.js +8 -3
  107. package/lib/test/unit/test_utils.js +89 -26
  108. package/lib/test/unit/testreporter.js +19 -1
  109. package/lib/test/unit/type1_parser_spec.js +7 -5
  110. package/lib/test/unit/ui_utils_spec.js +162 -38
  111. package/lib/test/unit/unicode_spec.js +13 -10
  112. package/lib/test/unit/util_spec.js +89 -9
  113. package/lib/web/annotation_layer_builder.js +38 -21
  114. package/lib/web/app.js +610 -245
  115. package/lib/web/app_options.js +54 -34
  116. package/lib/web/base_viewer.js +359 -162
  117. package/lib/web/chromecom.js +159 -80
  118. package/lib/web/debugger.js +161 -17
  119. package/lib/web/download_manager.js +29 -11
  120. package/lib/web/firefox_print_service.js +16 -8
  121. package/lib/web/firefoxcom.js +127 -91
  122. package/lib/web/genericcom.js +50 -31
  123. package/lib/web/genericl10n.js +46 -34
  124. package/lib/web/grab_to_pan.js +25 -3
  125. package/lib/web/interfaces.js +108 -61
  126. package/lib/web/overlay_manager.js +67 -45
  127. package/lib/web/password_prompt.js +20 -12
  128. package/lib/web/pdf_attachment_viewer.js +37 -17
  129. package/lib/web/pdf_cursor_tools.js +38 -15
  130. package/lib/web/pdf_document_properties.js +65 -24
  131. package/lib/web/pdf_find_bar.js +48 -20
  132. package/lib/web/pdf_find_controller.js +290 -89
  133. package/lib/web/pdf_find_utils.js +19 -3
  134. package/lib/web/pdf_history.js +186 -49
  135. package/lib/web/pdf_link_service.js +127 -52
  136. package/lib/web/pdf_outline_viewer.js +71 -21
  137. package/lib/web/pdf_page_view.js +188 -63
  138. package/lib/web/pdf_presentation_mode.js +98 -33
  139. package/lib/web/pdf_print_service.js +54 -10
  140. package/lib/web/pdf_rendering_queue.js +26 -4
  141. package/lib/web/pdf_sidebar.js +116 -62
  142. package/lib/web/pdf_sidebar_resizer.js +41 -15
  143. package/lib/web/pdf_single_page_viewer.js +65 -68
  144. package/lib/web/pdf_thumbnail_view.js +102 -31
  145. package/lib/web/pdf_thumbnail_viewer.js +62 -22
  146. package/lib/web/pdf_viewer.component.js +111 -31
  147. package/lib/web/pdf_viewer.js +80 -60
  148. package/lib/web/preferences.js +61 -39
  149. package/lib/web/secondary_toolbar.js +101 -82
  150. package/lib/web/text_layer_builder.js +124 -69
  151. package/lib/web/toolbar.js +67 -27
  152. package/lib/web/ui_utils.js +284 -128
  153. package/lib/web/view_history.js +75 -51
  154. package/lib/web/viewer_compatibility.js +2 -1
  155. package/package.json +1 -1
  156. package/web/pdf_viewer.css +1 -1
  157. package/web/pdf_viewer.js +2200 -973
  158. package/web/pdf_viewer.js.map +1 -1
  159. package/lib/web/dom_events.js +0 -140
@@ -19,30 +19,40 @@
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.PDFPageView = undefined;
27
+ exports.PDFPageView = void 0;
28
28
 
29
- 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; }; }();
29
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
30
30
 
31
- var _ui_utils = require('./ui_utils');
31
+ var _ui_utils = require("./ui_utils");
32
32
 
33
- var _pdf = require('../pdf');
33
+ var _pdf = require("../pdf");
34
34
 
35
- var _dom_events = require('./dom_events');
35
+ var _pdf_rendering_queue = require("./pdf_rendering_queue");
36
36
 
37
- var _pdf_rendering_queue = require('./pdf_rendering_queue');
37
+ var _viewer_compatibility = require("./viewer_compatibility");
38
38
 
39
- var _viewer_compatibility = require('./viewer_compatibility');
39
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
+
41
+ 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); } }
42
+
43
+ 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
44
 
41
45
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
42
46
 
47
+ 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); } }
48
+
49
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
50
+
43
51
  var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
44
52
 
45
- var PDFPageView = function () {
53
+ var PDFPageView =
54
+ /*#__PURE__*/
55
+ function () {
46
56
  function PDFPageView(options) {
47
57
  _classCallCheck(this, PDFPageView);
48
58
 
@@ -62,7 +72,7 @@ var PDFPageView = function () {
62
72
  this.renderInteractiveForms = options.renderInteractiveForms || false;
63
73
  this.useOnlyCssZoom = options.useOnlyCssZoom || false;
64
74
  this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
65
- this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
75
+ this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
66
76
  this.renderingQueue = options.renderingQueue;
67
77
  this.textLayerFactory = options.textLayerFactory;
68
78
  this.annotationLayerFactory = options.annotationLayerFactory;
@@ -89,46 +99,52 @@ var PDFPageView = function () {
89
99
  }
90
100
 
91
101
  _createClass(PDFPageView, [{
92
- key: 'setPdfPage',
102
+ key: "setPdfPage",
93
103
  value: function setPdfPage(pdfPage) {
94
104
  this.pdfPage = pdfPage;
95
105
  this.pdfPageRotate = pdfPage.rotate;
96
106
  var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
97
- this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);
107
+ this.viewport = pdfPage.getViewport({
108
+ scale: this.scale * _ui_utils.CSS_UNITS,
109
+ rotation: totalRotation
110
+ });
98
111
  this.stats = pdfPage.stats;
99
112
  this.reset();
100
113
  }
101
114
  }, {
102
- key: 'destroy',
115
+ key: "destroy",
103
116
  value: function destroy() {
104
117
  this.reset();
118
+
105
119
  if (this.pdfPage) {
106
120
  this.pdfPage.cleanup();
107
121
  }
108
122
  }
109
123
  }, {
110
- key: '_resetZoomLayer',
124
+ key: "_resetZoomLayer",
111
125
  value: function _resetZoomLayer() {
112
126
  var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
113
127
 
114
128
  if (!this.zoomLayer) {
115
129
  return;
116
130
  }
131
+
117
132
  var zoomLayerCanvas = this.zoomLayer.firstChild;
118
133
  this.paintedViewportMap.delete(zoomLayerCanvas);
119
134
  zoomLayerCanvas.width = 0;
120
135
  zoomLayerCanvas.height = 0;
136
+
121
137
  if (removeFromDOM) {
122
138
  this.zoomLayer.remove();
123
139
  }
140
+
124
141
  this.zoomLayer = null;
125
142
  }
126
143
  }, {
127
- key: 'reset',
144
+ key: "reset",
128
145
  value: function reset() {
129
146
  var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
130
147
  var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
131
-
132
148
  this.cancelRendering(keepAnnotations);
133
149
  var div = this.div;
134
150
  div.style.width = Math.floor(this.viewport.width) + 'px';
@@ -136,20 +152,26 @@ var PDFPageView = function () {
136
152
  var childNodes = div.childNodes;
137
153
  var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
138
154
  var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
155
+
139
156
  for (var i = childNodes.length - 1; i >= 0; i--) {
140
157
  var node = childNodes[i];
158
+
141
159
  if (currentZoomLayerNode === node || currentAnnotationNode === node) {
142
160
  continue;
143
161
  }
162
+
144
163
  div.removeChild(node);
145
164
  }
165
+
146
166
  div.removeAttribute('data-loaded');
167
+
147
168
  if (currentAnnotationNode) {
148
169
  this.annotationLayer.hide();
149
170
  } else if (this.annotationLayer) {
150
171
  this.annotationLayer.cancel();
151
172
  this.annotationLayer = null;
152
173
  }
174
+
153
175
  if (!currentZoomLayerNode) {
154
176
  if (this.canvas) {
155
177
  this.paintedViewportMap.delete(this.canvas);
@@ -157,28 +179,34 @@ var PDFPageView = function () {
157
179
  this.canvas.height = 0;
158
180
  delete this.canvas;
159
181
  }
182
+
160
183
  this._resetZoomLayer();
161
184
  }
185
+
162
186
  if (this.svg) {
163
187
  this.paintedViewportMap.delete(this.svg);
164
188
  delete this.svg;
165
189
  }
190
+
166
191
  this.loadingIconDiv = document.createElement('div');
167
192
  this.loadingIconDiv.className = 'loadingIcon';
168
193
  div.appendChild(this.loadingIconDiv);
169
194
  }
170
195
  }, {
171
- key: 'update',
196
+ key: "update",
172
197
  value: function update(scale, rotation) {
173
198
  this.scale = scale || this.scale;
199
+
174
200
  if (typeof rotation !== 'undefined') {
175
201
  this.rotation = rotation;
176
202
  }
203
+
177
204
  var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
178
205
  this.viewport = this.viewport.clone({
179
206
  scale: this.scale * _ui_utils.CSS_UNITS,
180
207
  rotation: totalRotation
181
208
  });
209
+
182
210
  if (this.svg) {
183
211
  this.cssTransform(this.svg, true);
184
212
  this.eventBus.dispatch('pagerendered', {
@@ -188,13 +216,17 @@ var PDFPageView = function () {
188
216
  });
189
217
  return;
190
218
  }
219
+
191
220
  var isScalingRestricted = false;
221
+
192
222
  if (this.canvas && this.maxCanvasPixels > 0) {
193
223
  var outputScale = this.outputScale;
224
+
194
225
  if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
195
226
  isScalingRestricted = true;
196
227
  }
197
228
  }
229
+
198
230
  if (this.canvas) {
199
231
  if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
200
232
  this.cssTransform(this.canvas, true);
@@ -205,36 +237,43 @@ var PDFPageView = function () {
205
237
  });
206
238
  return;
207
239
  }
240
+
208
241
  if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
209
242
  this.zoomLayer = this.canvas.parentNode;
210
243
  this.zoomLayer.style.position = 'absolute';
211
244
  }
212
245
  }
246
+
213
247
  if (this.zoomLayer) {
214
248
  this.cssTransform(this.zoomLayer.firstChild);
215
249
  }
250
+
216
251
  this.reset(true, true);
217
252
  }
218
253
  }, {
219
- key: 'cancelRendering',
254
+ key: "cancelRendering",
220
255
  value: function cancelRendering() {
221
256
  var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
222
-
223
257
  var renderingState = this.renderingState;
258
+
224
259
  if (this.paintTask) {
225
260
  this.paintTask.cancel();
226
261
  this.paintTask = null;
227
262
  }
263
+
228
264
  this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
229
265
  this.resume = null;
266
+
230
267
  if (this.textLayer) {
231
268
  this.textLayer.cancel();
232
269
  this.textLayer = null;
233
270
  }
271
+
234
272
  if (!keepAnnotations && this.annotationLayer) {
235
273
  this.annotationLayer.cancel();
236
274
  this.annotationLayer = null;
237
275
  }
276
+
238
277
  if (renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
239
278
  this.eventBus.dispatch('pagecancelled', {
240
279
  source: this,
@@ -244,10 +283,9 @@ var PDFPageView = function () {
244
283
  }
245
284
  }
246
285
  }, {
247
- key: 'cssTransform',
286
+ key: "cssTransform",
248
287
  value: function cssTransform(target) {
249
288
  var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
250
-
251
289
  var width = this.viewport.width;
252
290
  var height = this.viewport.height;
253
291
  var div = this.div;
@@ -257,57 +295,68 @@ var PDFPageView = function () {
257
295
  var absRotation = Math.abs(relativeRotation);
258
296
  var scaleX = 1,
259
297
  scaleY = 1;
298
+
260
299
  if (absRotation === 90 || absRotation === 270) {
261
300
  scaleX = height / width;
262
301
  scaleY = width / height;
263
302
  }
303
+
264
304
  var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
265
305
  target.style.transform = cssTransform;
306
+
266
307
  if (this.textLayer) {
267
308
  var textLayerViewport = this.textLayer.viewport;
268
309
  var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
269
310
  var textAbsRotation = Math.abs(textRelativeRotation);
270
311
  var scale = width / textLayerViewport.width;
312
+
271
313
  if (textAbsRotation === 90 || textAbsRotation === 270) {
272
314
  scale = width / textLayerViewport.height;
273
315
  }
316
+
274
317
  var textLayerDiv = this.textLayer.textLayerDiv;
275
- var transX = void 0,
276
- transY = void 0;
318
+ var transX, transY;
319
+
277
320
  switch (textAbsRotation) {
278
321
  case 0:
279
322
  transX = transY = 0;
280
323
  break;
324
+
281
325
  case 90:
282
326
  transX = 0;
283
327
  transY = '-' + textLayerDiv.style.height;
284
328
  break;
329
+
285
330
  case 180:
286
331
  transX = '-' + textLayerDiv.style.width;
287
332
  transY = '-' + textLayerDiv.style.height;
288
333
  break;
334
+
289
335
  case 270:
290
336
  transX = '-' + textLayerDiv.style.width;
291
337
  transY = 0;
292
338
  break;
339
+
293
340
  default:
294
341
  console.error('Bad rotation value.');
295
342
  break;
296
343
  }
344
+
297
345
  textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
298
346
  textLayerDiv.style.transformOrigin = '0% 0%';
299
347
  }
348
+
300
349
  if (redrawAnnotations && this.annotationLayer) {
301
350
  this.annotationLayer.render(this.viewport, 'display');
302
351
  }
303
352
  }
304
353
  }, {
305
- key: 'getPagePoint',
354
+ key: "getPagePoint",
306
355
  value: function getPagePoint(x, y) {
307
356
  return this.viewport.convertToPdfPoint(x, y);
308
357
  }
309
358
  }, {
310
- key: 'draw',
359
+ key: "draw",
311
360
  value: function draw() {
312
361
  var _this = this;
313
362
 
@@ -315,10 +364,12 @@ var PDFPageView = function () {
315
364
  console.error('Must be in new state before drawing');
316
365
  this.reset();
317
366
  }
367
+
318
368
  if (!this.pdfPage) {
319
369
  this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
320
370
  return Promise.reject(new Error('Page is not loaded'));
321
371
  }
372
+
322
373
  this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
323
374
  var pdfPage = this.pdfPage;
324
375
  var div = this.div;
@@ -326,75 +377,124 @@ var PDFPageView = function () {
326
377
  canvasWrapper.style.width = div.style.width;
327
378
  canvasWrapper.style.height = div.style.height;
328
379
  canvasWrapper.classList.add('canvasWrapper');
380
+
329
381
  if (this.annotationLayer && this.annotationLayer.div) {
330
382
  div.insertBefore(canvasWrapper, this.annotationLayer.div);
331
383
  } else {
332
384
  div.appendChild(canvasWrapper);
333
385
  }
386
+
334
387
  var textLayer = null;
388
+
335
389
  if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
336
390
  var textLayerDiv = document.createElement('div');
337
391
  textLayerDiv.className = 'textLayer';
338
392
  textLayerDiv.style.width = canvasWrapper.style.width;
339
393
  textLayerDiv.style.height = canvasWrapper.style.height;
394
+
340
395
  if (this.annotationLayer && this.annotationLayer.div) {
341
396
  div.insertBefore(textLayerDiv, this.annotationLayer.div);
342
397
  } else {
343
398
  div.appendChild(textLayerDiv);
344
399
  }
400
+
345
401
  textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
346
402
  }
403
+
347
404
  this.textLayer = textLayer;
348
405
  var renderContinueCallback = null;
406
+
349
407
  if (this.renderingQueue) {
350
408
  renderContinueCallback = function renderContinueCallback(cont) {
351
409
  if (!_this.renderingQueue.isHighestPriority(_this)) {
352
410
  _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
411
+
353
412
  _this.resume = function () {
354
413
  _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
355
414
  cont();
356
415
  };
416
+
357
417
  return;
358
418
  }
419
+
359
420
  cont();
360
421
  };
361
422
  }
362
- var finishPaintTask = function finishPaintTask(error) {
363
- if (paintTask === _this.paintTask) {
364
- _this.paintTask = null;
365
- }
366
- if (error instanceof _pdf.RenderingCancelledException) {
367
- _this.error = null;
368
- return Promise.resolve(undefined);
369
- }
370
- _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
371
- if (_this.loadingIconDiv) {
372
- div.removeChild(_this.loadingIconDiv);
373
- delete _this.loadingIconDiv;
374
- }
375
- _this._resetZoomLayer(true);
376
- _this.error = error;
377
- _this.stats = pdfPage.stats;
378
- if (_this.onAfterDraw) {
379
- _this.onAfterDraw();
380
- }
381
- _this.eventBus.dispatch('pagerendered', {
382
- source: _this,
383
- pageNumber: _this.id,
384
- cssTransform: false
385
- });
386
- if (error) {
387
- return Promise.reject(error);
388
- }
389
- return Promise.resolve(undefined);
390
- };
423
+
424
+ var finishPaintTask =
425
+ /*#__PURE__*/
426
+ function () {
427
+ var _ref = _asyncToGenerator(
428
+ /*#__PURE__*/
429
+ _regenerator.default.mark(function _callee(error) {
430
+ return _regenerator.default.wrap(function _callee$(_context) {
431
+ while (1) {
432
+ switch (_context.prev = _context.next) {
433
+ case 0:
434
+ if (paintTask === _this.paintTask) {
435
+ _this.paintTask = null;
436
+ }
437
+
438
+ if (!(error instanceof _pdf.RenderingCancelledException)) {
439
+ _context.next = 4;
440
+ break;
441
+ }
442
+
443
+ _this.error = null;
444
+ return _context.abrupt("return");
445
+
446
+ case 4:
447
+ _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
448
+
449
+ if (_this.loadingIconDiv) {
450
+ div.removeChild(_this.loadingIconDiv);
451
+ delete _this.loadingIconDiv;
452
+ }
453
+
454
+ _this._resetZoomLayer(true);
455
+
456
+ _this.error = error;
457
+ _this.stats = pdfPage.stats;
458
+
459
+ if (_this.onAfterDraw) {
460
+ _this.onAfterDraw();
461
+ }
462
+
463
+ _this.eventBus.dispatch('pagerendered', {
464
+ source: _this,
465
+ pageNumber: _this.id,
466
+ cssTransform: false
467
+ });
468
+
469
+ if (!error) {
470
+ _context.next = 13;
471
+ break;
472
+ }
473
+
474
+ throw error;
475
+
476
+ case 13:
477
+ case "end":
478
+ return _context.stop();
479
+ }
480
+ }
481
+ }, _callee, this);
482
+ }));
483
+
484
+ return function finishPaintTask(_x) {
485
+ return _ref.apply(this, arguments);
486
+ };
487
+ }();
488
+
391
489
  var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
392
490
  paintTask.onRenderContinue = renderContinueCallback;
393
491
  this.paintTask = paintTask;
394
492
  var resultPromise = paintTask.promise.then(function () {
395
493
  return finishPaintTask(null).then(function () {
396
494
  if (textLayer) {
397
- var readableStream = pdfPage.streamTextContent({ normalizeWhitespace: true });
495
+ var readableStream = pdfPage.streamTextContent({
496
+ normalizeWhitespace: true
497
+ });
398
498
  textLayer.setTextContentStream(readableStream);
399
499
  textLayer.render();
400
500
  }
@@ -402,20 +502,25 @@ var PDFPageView = function () {
402
502
  }, function (reason) {
403
503
  return finishPaintTask(reason);
404
504
  });
505
+
405
506
  if (this.annotationLayerFactory) {
406
507
  if (!this.annotationLayer) {
407
508
  this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
408
509
  }
510
+
409
511
  this.annotationLayer.render(this.viewport, 'display');
410
512
  }
513
+
411
514
  div.setAttribute('data-loaded', true);
515
+
412
516
  if (this.onBeforeDraw) {
413
517
  this.onBeforeDraw();
414
518
  }
519
+
415
520
  return resultPromise;
416
521
  }
417
522
  }, {
418
- key: 'paintOnCanvas',
523
+ key: "paintOnCanvas",
419
524
  value: function paintOnCanvas(canvasWrapper) {
420
525
  var renderCapability = (0, _pdf.createPromiseCapability)();
421
526
  var result = {
@@ -432,27 +537,36 @@ var PDFPageView = function () {
432
537
  canvas.id = this.renderingId;
433
538
  canvas.setAttribute('hidden', 'hidden');
434
539
  var isCanvasHidden = true;
540
+
435
541
  var showCanvas = function showCanvas() {
436
542
  if (isCanvasHidden) {
437
543
  canvas.removeAttribute('hidden');
438
544
  isCanvasHidden = false;
439
545
  }
440
546
  };
547
+
441
548
  canvasWrapper.appendChild(canvas);
442
549
  this.canvas = canvas;
443
550
  canvas.mozOpaque = true;
444
- var ctx = canvas.getContext('2d', { alpha: false });
551
+ var ctx = canvas.getContext('2d', {
552
+ alpha: false
553
+ });
445
554
  var outputScale = (0, _ui_utils.getOutputScale)(ctx);
446
555
  this.outputScale = outputScale;
556
+
447
557
  if (this.useOnlyCssZoom) {
448
- var actualSizeViewport = viewport.clone({ scale: _ui_utils.CSS_UNITS });
558
+ var actualSizeViewport = viewport.clone({
559
+ scale: _ui_utils.CSS_UNITS
560
+ });
449
561
  outputScale.sx *= actualSizeViewport.width / viewport.width;
450
562
  outputScale.sy *= actualSizeViewport.height / viewport.height;
451
563
  outputScale.scaled = true;
452
564
  }
565
+
453
566
  if (this.maxCanvasPixels > 0) {
454
567
  var pixelsInViewport = viewport.width * viewport.height;
455
568
  var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
569
+
456
570
  if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
457
571
  outputScale.sx = maxScale;
458
572
  outputScale.sy = maxScale;
@@ -462,6 +576,7 @@ var PDFPageView = function () {
462
576
  this.hasRestrictedScaling = false;
463
577
  }
464
578
  }
579
+
465
580
  var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
466
581
  var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
467
582
  canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
@@ -478,14 +593,17 @@ var PDFPageView = function () {
478
593
  renderInteractiveForms: this.renderInteractiveForms
479
594
  };
480
595
  var renderTask = this.pdfPage.render(renderContext);
596
+
481
597
  renderTask.onContinue = function (cont) {
482
598
  showCanvas();
599
+
483
600
  if (result.onRenderContinue) {
484
601
  result.onRenderContinue(cont);
485
602
  } else {
486
603
  cont();
487
604
  }
488
605
  };
606
+
489
607
  renderTask.promise.then(function () {
490
608
  showCanvas();
491
609
  renderCapability.resolve(undefined);
@@ -496,25 +614,31 @@ var PDFPageView = function () {
496
614
  return result;
497
615
  }
498
616
  }, {
499
- key: 'paintOnSvg',
617
+ key: "paintOnSvg",
500
618
  value: function paintOnSvg(wrapper) {
501
619
  var _this2 = this;
502
620
 
503
621
  var cancelled = false;
622
+
504
623
  var ensureNotCancelled = function ensureNotCancelled() {
505
624
  if (cancelled) {
506
625
  throw new _pdf.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
507
626
  }
508
627
  };
628
+
509
629
  var pdfPage = this.pdfPage;
510
- var actualSizeViewport = this.viewport.clone({ scale: _ui_utils.CSS_UNITS });
630
+ var actualSizeViewport = this.viewport.clone({
631
+ scale: _ui_utils.CSS_UNITS
632
+ });
511
633
  var promise = pdfPage.getOperatorList().then(function (opList) {
512
634
  ensureNotCancelled();
513
635
  var svgGfx = new _pdf.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
514
636
  return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
515
637
  ensureNotCancelled();
516
638
  _this2.svg = svg;
639
+
517
640
  _this2.paintedViewportMap.set(svg, actualSizeViewport);
641
+
518
642
  svg.style.width = wrapper.style.width;
519
643
  svg.style.height = wrapper.style.height;
520
644
  _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
@@ -532,9 +656,10 @@ var PDFPageView = function () {
532
656
  };
533
657
  }
534
658
  }, {
535
- key: 'setPageLabel',
659
+ key: "setPageLabel",
536
660
  value: function setPageLabel(label) {
537
661
  this.pageLabel = typeof label === 'string' ? label : null;
662
+
538
663
  if (this.pageLabel !== null) {
539
664
  this.div.setAttribute('data-page-label', this.pageLabel);
540
665
  } else {
@@ -542,12 +667,12 @@ var PDFPageView = function () {
542
667
  }
543
668
  }
544
669
  }, {
545
- key: 'width',
670
+ key: "width",
546
671
  get: function get() {
547
672
  return this.viewport.width;
548
673
  }
549
674
  }, {
550
- key: 'height',
675
+ key: "height",
551
676
  get: function get() {
552
677
  return this.viewport.height;
553
678
  }