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