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.
- package/CODE_OF_CONDUCT.md +15 -0
- package/bower.json +1 -1
- package/build/pdf.js +18515 -11402
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +48266 -37137
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/external/url/url-lib.js +627 -0
- package/image_decoders/pdf.image_decoders.js +11350 -0
- package/image_decoders/pdf.image_decoders.js.map +1 -0
- package/image_decoders/pdf.image_decoders.min.js +1 -0
- package/lib/core/annotation.js +587 -242
- package/lib/core/arithmetic_decoder.js +275 -245
- package/lib/core/bidi.js +65 -6
- package/lib/core/ccitt.js +173 -18
- package/lib/core/ccitt_stream.js +15 -6
- package/lib/core/cff_parser.js +433 -61
- package/lib/core/charsets.js +5 -4
- package/lib/core/chunked_stream.js +400 -152
- package/lib/core/cmap.js +326 -87
- package/lib/core/colorspace.js +874 -594
- package/lib/core/core_utils.js +147 -0
- package/lib/core/crypto.js +290 -45
- package/lib/core/document.js +560 -268
- package/lib/core/encodings.js +19 -10
- package/lib/core/evaluator.js +1005 -360
- package/lib/core/font_renderer.js +331 -97
- package/lib/core/fonts.js +812 -195
- package/lib/core/function.js +284 -71
- package/lib/core/glyphlist.js +4 -3
- package/lib/core/image.js +169 -62
- package/lib/core/image_utils.js +111 -0
- package/lib/core/jbig2.js +479 -66
- package/lib/core/jbig2_stream.js +19 -8
- package/lib/core/jpeg_stream.js +38 -13
- package/lib/core/jpg.js +253 -29
- package/lib/core/jpx.js +396 -6
- package/lib/core/jpx_stream.js +18 -6
- package/lib/core/metrics.js +15 -15
- package/lib/core/murmurhash3.js +56 -34
- package/lib/core/obj.js +1354 -488
- package/lib/core/operator_list.js +144 -31
- package/lib/core/parser.js +539 -191
- package/lib/core/pattern.js +148 -14
- package/lib/core/pdf_manager.js +323 -133
- package/lib/core/primitives.js +111 -24
- package/lib/core/ps_parser.js +134 -45
- package/lib/core/standard_fonts.js +17 -17
- package/lib/core/stream.js +313 -34
- package/lib/core/type1_parser.js +143 -13
- package/lib/core/unicode.js +32 -5
- package/lib/core/worker.js +217 -190
- package/lib/core/worker_stream.js +277 -0
- package/lib/display/annotation_layer.js +450 -133
- package/lib/display/api.js +1597 -784
- package/lib/display/api_compatibility.js +11 -13
- package/lib/display/canvas.js +360 -44
- package/lib/display/content_disposition.js +83 -32
- package/lib/display/display_utils.js +747 -0
- package/lib/display/fetch_stream.js +221 -90
- package/lib/display/font_loader.js +468 -236
- package/lib/display/metadata.js +38 -16
- package/lib/display/network.js +635 -428
- package/lib/display/network_utils.js +32 -19
- package/lib/display/node_stream.js +367 -175
- package/lib/display/pattern_helper.js +81 -31
- package/lib/display/svg.js +1235 -519
- package/lib/display/text_layer.js +153 -29
- package/lib/display/transport_stream.js +345 -94
- package/lib/display/webgl.js +64 -18
- package/lib/display/worker_options.js +5 -4
- package/lib/display/xml_parser.js +166 -53
- package/lib/examples/node/domstubs.js +60 -4
- package/lib/pdf.js +36 -14
- package/lib/pdf.worker.js +5 -3
- package/lib/shared/compatibility.js +158 -564
- package/lib/shared/global_scope.js +2 -2
- package/lib/shared/is_node.js +4 -4
- package/lib/shared/message_handler.js +521 -0
- package/lib/shared/streams_polyfill.js +21 -17
- package/lib/shared/url_polyfill.js +56 -0
- package/lib/shared/util.js +243 -710
- package/lib/test/unit/annotation_spec.js +870 -401
- package/lib/test/unit/api_spec.js +657 -345
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +54 -11
- package/lib/test/unit/clitests_helper.js +10 -8
- package/lib/test/unit/cmap_spec.js +95 -41
- package/lib/test/unit/colorspace_spec.js +115 -63
- package/lib/test/unit/core_utils_spec.js +191 -0
- package/lib/test/unit/crypto_spec.js +17 -5
- package/lib/test/unit/custom_spec.js +43 -55
- package/lib/test/unit/display_svg_spec.js +34 -18
- package/lib/test/unit/display_utils_spec.js +273 -0
- package/lib/test/unit/document_spec.js +8 -13
- package/lib/test/unit/encodings_spec.js +25 -45
- package/lib/test/unit/evaluator_spec.js +38 -15
- package/lib/test/unit/fetch_stream_spec.js +109 -0
- package/lib/test/unit/function_spec.js +17 -5
- package/lib/test/unit/jasmine-boot.js +33 -20
- package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
- package/lib/test/unit/metadata_spec.js +71 -11
- package/lib/test/unit/murmurhash3_spec.js +3 -3
- package/lib/test/unit/network_spec.js +19 -54
- package/lib/test/unit/network_utils_spec.js +91 -14
- package/lib/test/unit/node_stream_spec.js +56 -32
- package/lib/test/unit/parser_spec.js +162 -71
- package/lib/test/unit/pdf_find_controller_spec.js +230 -0
- package/lib/test/unit/pdf_find_utils_spec.js +63 -0
- package/lib/test/unit/pdf_history_spec.js +21 -9
- package/lib/test/unit/primitives_spec.js +53 -20
- package/lib/test/unit/stream_spec.js +12 -4
- package/lib/test/unit/test_utils.js +273 -56
- package/lib/test/unit/testreporter.js +21 -3
- package/lib/test/unit/type1_parser_spec.js +8 -6
- package/lib/test/unit/ui_utils_spec.js +454 -16
- package/lib/test/unit/unicode_spec.js +18 -15
- package/lib/test/unit/util_spec.js +87 -128
- package/lib/web/annotation_layer_builder.js +39 -22
- package/lib/web/app.js +1290 -588
- package/lib/web/app_options.js +100 -62
- package/lib/web/base_viewer.js +511 -182
- package/lib/web/chromecom.js +261 -117
- package/lib/web/debugger.js +166 -22
- package/lib/web/download_manager.js +32 -13
- package/lib/web/firefox_print_service.js +20 -10
- package/lib/web/firefoxcom.js +315 -80
- package/lib/web/genericcom.js +89 -30
- package/lib/web/genericl10n.js +142 -30
- package/lib/web/grab_to_pan.js +28 -4
- package/lib/web/interfaces.js +170 -47
- package/lib/web/overlay_manager.js +235 -85
- package/lib/web/password_prompt.js +22 -14
- package/lib/web/pdf_attachment_viewer.js +38 -18
- package/lib/web/pdf_cursor_tools.js +39 -16
- package/lib/web/pdf_document_properties.js +255 -136
- package/lib/web/pdf_find_bar.js +84 -40
- package/lib/web/pdf_find_controller.js +495 -184
- package/lib/web/pdf_find_utils.js +111 -0
- package/lib/web/pdf_history.js +190 -53
- package/lib/web/pdf_link_service.js +138 -77
- package/lib/web/pdf_outline_viewer.js +122 -46
- package/lib/web/pdf_page_view.js +191 -67
- package/lib/web/pdf_presentation_mode.js +99 -34
- package/lib/web/pdf_print_service.js +61 -13
- package/lib/web/pdf_rendering_queue.js +28 -9
- package/lib/web/pdf_sidebar.js +141 -81
- package/lib/web/pdf_sidebar_resizer.js +42 -16
- package/lib/web/pdf_single_page_viewer.js +74 -66
- package/lib/web/pdf_thumbnail_view.js +104 -33
- package/lib/web/pdf_thumbnail_viewer.js +66 -26
- package/lib/web/pdf_viewer.component.js +112 -32
- package/lib/web/pdf_viewer.js +91 -52
- package/lib/web/preferences.js +284 -89
- package/lib/web/secondary_toolbar.js +165 -40
- package/lib/web/text_layer_builder.js +134 -59
- package/lib/web/toolbar.js +78 -43
- package/lib/web/ui_utils.js +462 -136
- package/lib/web/view_history.js +215 -67
- package/lib/web/viewer_compatibility.js +4 -13
- package/package.json +5 -4
- package/web/pdf_viewer.css +79 -11
- package/web/pdf_viewer.js +6107 -3748
- package/web/pdf_viewer.js.map +1 -1
- package/lib/display/dom_utils.js +0 -309
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/test/unit/fonts_spec.js +0 -81
- package/lib/web/dom_events.js +0 -137
package/lib/web/pdf_page_view.js
CHANGED
@@ -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
|
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
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.PDFPageView =
|
27
|
+
exports.PDFPageView = void 0;
|
28
28
|
|
29
|
-
var
|
29
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
30
30
|
|
31
|
-
var _ui_utils = require(
|
31
|
+
var _ui_utils = require("./ui_utils");
|
32
32
|
|
33
|
-
var _pdf = require(
|
33
|
+
var _pdf = require("../pdf");
|
34
34
|
|
35
|
-
var
|
35
|
+
var _pdf_rendering_queue = require("./pdf_rendering_queue");
|
36
36
|
|
37
|
-
var
|
37
|
+
var _viewer_compatibility = require("./viewer_compatibility");
|
38
38
|
|
39
|
-
|
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 =
|
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,
|
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,96 +99,115 @@ var PDFPageView = function () {
|
|
89
99
|
}
|
90
100
|
|
91
101
|
_createClass(PDFPageView, [{
|
92
|
-
key:
|
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(
|
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:
|
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:
|
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
|
-
this.paintedViewportMap
|
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:
|
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);
|
149
|
+
this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
|
133
150
|
var div = this.div;
|
134
151
|
div.style.width = Math.floor(this.viewport.width) + 'px';
|
135
152
|
div.style.height = Math.floor(this.viewport.height) + 'px';
|
136
153
|
var childNodes = div.childNodes;
|
137
154
|
var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
|
138
155
|
var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
|
156
|
+
|
139
157
|
for (var i = childNodes.length - 1; i >= 0; i--) {
|
140
158
|
var node = childNodes[i];
|
159
|
+
|
141
160
|
if (currentZoomLayerNode === node || currentAnnotationNode === node) {
|
142
161
|
continue;
|
143
162
|
}
|
163
|
+
|
144
164
|
div.removeChild(node);
|
145
165
|
}
|
166
|
+
|
146
167
|
div.removeAttribute('data-loaded');
|
168
|
+
|
147
169
|
if (currentAnnotationNode) {
|
148
170
|
this.annotationLayer.hide();
|
149
171
|
} else if (this.annotationLayer) {
|
150
172
|
this.annotationLayer.cancel();
|
151
173
|
this.annotationLayer = null;
|
152
174
|
}
|
175
|
+
|
153
176
|
if (!currentZoomLayerNode) {
|
154
177
|
if (this.canvas) {
|
155
|
-
this.paintedViewportMap
|
178
|
+
this.paintedViewportMap["delete"](this.canvas);
|
156
179
|
this.canvas.width = 0;
|
157
180
|
this.canvas.height = 0;
|
158
181
|
delete this.canvas;
|
159
182
|
}
|
183
|
+
|
160
184
|
this._resetZoomLayer();
|
161
185
|
}
|
186
|
+
|
162
187
|
if (this.svg) {
|
163
|
-
this.paintedViewportMap
|
188
|
+
this.paintedViewportMap["delete"](this.svg);
|
164
189
|
delete this.svg;
|
165
190
|
}
|
191
|
+
|
166
192
|
this.loadingIconDiv = document.createElement('div');
|
167
193
|
this.loadingIconDiv.className = 'loadingIcon';
|
168
194
|
div.appendChild(this.loadingIconDiv);
|
169
195
|
}
|
170
196
|
}, {
|
171
|
-
key:
|
197
|
+
key: "update",
|
172
198
|
value: function update(scale, rotation) {
|
173
199
|
this.scale = scale || this.scale;
|
200
|
+
|
174
201
|
if (typeof rotation !== 'undefined') {
|
175
202
|
this.rotation = rotation;
|
176
203
|
}
|
204
|
+
|
177
205
|
var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
|
178
206
|
this.viewport = this.viewport.clone({
|
179
207
|
scale: this.scale * _ui_utils.CSS_UNITS,
|
180
208
|
rotation: totalRotation
|
181
209
|
});
|
210
|
+
|
182
211
|
if (this.svg) {
|
183
212
|
this.cssTransform(this.svg, true);
|
184
213
|
this.eventBus.dispatch('pagerendered', {
|
@@ -188,13 +217,17 @@ var PDFPageView = function () {
|
|
188
217
|
});
|
189
218
|
return;
|
190
219
|
}
|
220
|
+
|
191
221
|
var isScalingRestricted = false;
|
222
|
+
|
192
223
|
if (this.canvas && this.maxCanvasPixels > 0) {
|
193
224
|
var outputScale = this.outputScale;
|
225
|
+
|
194
226
|
if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
|
195
227
|
isScalingRestricted = true;
|
196
228
|
}
|
197
229
|
}
|
230
|
+
|
198
231
|
if (this.canvas) {
|
199
232
|
if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
|
200
233
|
this.cssTransform(this.canvas, true);
|
@@ -205,18 +238,21 @@ var PDFPageView = function () {
|
|
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:
|
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
|
-
|
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:
|
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
|
268
|
-
|
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:
|
345
|
+
key: "getPagePoint",
|
298
346
|
value: function getPagePoint(x, y) {
|
299
347
|
return this.viewport.convertToPdfPoint(x, y);
|
300
348
|
}
|
301
349
|
}, {
|
302
|
-
key:
|
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,124 @@ 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
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
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
|
+
if (_this.onAfterDraw) {
|
451
|
+
_this.onAfterDraw();
|
452
|
+
}
|
453
|
+
|
454
|
+
_this.eventBus.dispatch('pagerendered', {
|
455
|
+
source: _this,
|
456
|
+
pageNumber: _this.id,
|
457
|
+
cssTransform: false
|
458
|
+
});
|
459
|
+
|
460
|
+
if (!error) {
|
461
|
+
_context.next = 13;
|
462
|
+
break;
|
463
|
+
}
|
464
|
+
|
465
|
+
throw error;
|
466
|
+
|
467
|
+
case 13:
|
468
|
+
case "end":
|
469
|
+
return _context.stop();
|
470
|
+
}
|
471
|
+
}
|
472
|
+
}, _callee);
|
473
|
+
}));
|
474
|
+
|
475
|
+
return function finishPaintTask(_x) {
|
476
|
+
return _ref.apply(this, arguments);
|
477
|
+
};
|
478
|
+
}();
|
479
|
+
|
383
480
|
var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
|
384
481
|
paintTask.onRenderContinue = renderContinueCallback;
|
385
482
|
this.paintTask = paintTask;
|
386
483
|
var resultPromise = paintTask.promise.then(function () {
|
387
484
|
return finishPaintTask(null).then(function () {
|
388
485
|
if (textLayer) {
|
389
|
-
var readableStream = pdfPage.streamTextContent({
|
486
|
+
var readableStream = pdfPage.streamTextContent({
|
487
|
+
normalizeWhitespace: true
|
488
|
+
});
|
390
489
|
textLayer.setTextContentStream(readableStream);
|
391
490
|
textLayer.render();
|
392
491
|
}
|
@@ -394,20 +493,25 @@ var PDFPageView = function () {
|
|
394
493
|
}, function (reason) {
|
395
494
|
return finishPaintTask(reason);
|
396
495
|
});
|
496
|
+
|
397
497
|
if (this.annotationLayerFactory) {
|
398
498
|
if (!this.annotationLayer) {
|
399
499
|
this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
|
400
500
|
}
|
501
|
+
|
401
502
|
this.annotationLayer.render(this.viewport, 'display');
|
402
503
|
}
|
504
|
+
|
403
505
|
div.setAttribute('data-loaded', true);
|
506
|
+
|
404
507
|
if (this.onBeforeDraw) {
|
405
508
|
this.onBeforeDraw();
|
406
509
|
}
|
510
|
+
|
407
511
|
return resultPromise;
|
408
512
|
}
|
409
513
|
}, {
|
410
|
-
key:
|
514
|
+
key: "paintOnCanvas",
|
411
515
|
value: function paintOnCanvas(canvasWrapper) {
|
412
516
|
var renderCapability = (0, _pdf.createPromiseCapability)();
|
413
517
|
var result = {
|
@@ -424,27 +528,36 @@ var PDFPageView = function () {
|
|
424
528
|
canvas.id = this.renderingId;
|
425
529
|
canvas.setAttribute('hidden', 'hidden');
|
426
530
|
var isCanvasHidden = true;
|
531
|
+
|
427
532
|
var showCanvas = function showCanvas() {
|
428
533
|
if (isCanvasHidden) {
|
429
534
|
canvas.removeAttribute('hidden');
|
430
535
|
isCanvasHidden = false;
|
431
536
|
}
|
432
537
|
};
|
538
|
+
|
433
539
|
canvasWrapper.appendChild(canvas);
|
434
540
|
this.canvas = canvas;
|
435
541
|
canvas.mozOpaque = true;
|
436
|
-
var ctx = canvas.getContext('2d', {
|
542
|
+
var ctx = canvas.getContext('2d', {
|
543
|
+
alpha: false
|
544
|
+
});
|
437
545
|
var outputScale = (0, _ui_utils.getOutputScale)(ctx);
|
438
546
|
this.outputScale = outputScale;
|
547
|
+
|
439
548
|
if (this.useOnlyCssZoom) {
|
440
|
-
var actualSizeViewport = viewport.clone({
|
549
|
+
var actualSizeViewport = viewport.clone({
|
550
|
+
scale: _ui_utils.CSS_UNITS
|
551
|
+
});
|
441
552
|
outputScale.sx *= actualSizeViewport.width / viewport.width;
|
442
553
|
outputScale.sy *= actualSizeViewport.height / viewport.height;
|
443
554
|
outputScale.scaled = true;
|
444
555
|
}
|
556
|
+
|
445
557
|
if (this.maxCanvasPixels > 0) {
|
446
558
|
var pixelsInViewport = viewport.width * viewport.height;
|
447
559
|
var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
|
560
|
+
|
448
561
|
if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
|
449
562
|
outputScale.sx = maxScale;
|
450
563
|
outputScale.sy = maxScale;
|
@@ -454,6 +567,7 @@ var PDFPageView = function () {
|
|
454
567
|
this.hasRestrictedScaling = false;
|
455
568
|
}
|
456
569
|
}
|
570
|
+
|
457
571
|
var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
|
458
572
|
var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
|
459
573
|
canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
|
@@ -470,14 +584,17 @@ var PDFPageView = function () {
|
|
470
584
|
renderInteractiveForms: this.renderInteractiveForms
|
471
585
|
};
|
472
586
|
var renderTask = this.pdfPage.render(renderContext);
|
587
|
+
|
473
588
|
renderTask.onContinue = function (cont) {
|
474
589
|
showCanvas();
|
590
|
+
|
475
591
|
if (result.onRenderContinue) {
|
476
592
|
result.onRenderContinue(cont);
|
477
593
|
} else {
|
478
594
|
cont();
|
479
595
|
}
|
480
596
|
};
|
597
|
+
|
481
598
|
renderTask.promise.then(function () {
|
482
599
|
showCanvas();
|
483
600
|
renderCapability.resolve(undefined);
|
@@ -488,25 +605,31 @@ var PDFPageView = function () {
|
|
488
605
|
return result;
|
489
606
|
}
|
490
607
|
}, {
|
491
|
-
key:
|
608
|
+
key: "paintOnSvg",
|
492
609
|
value: function paintOnSvg(wrapper) {
|
493
610
|
var _this2 = this;
|
494
611
|
|
495
612
|
var cancelled = false;
|
613
|
+
|
496
614
|
var ensureNotCancelled = function ensureNotCancelled() {
|
497
615
|
if (cancelled) {
|
498
616
|
throw new _pdf.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
|
499
617
|
}
|
500
618
|
};
|
619
|
+
|
501
620
|
var pdfPage = this.pdfPage;
|
502
|
-
var actualSizeViewport = this.viewport.clone({
|
621
|
+
var actualSizeViewport = this.viewport.clone({
|
622
|
+
scale: _ui_utils.CSS_UNITS
|
623
|
+
});
|
503
624
|
var promise = pdfPage.getOperatorList().then(function (opList) {
|
504
625
|
ensureNotCancelled();
|
505
626
|
var svgGfx = new _pdf.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
|
506
627
|
return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
|
507
628
|
ensureNotCancelled();
|
508
629
|
_this2.svg = svg;
|
630
|
+
|
509
631
|
_this2.paintedViewportMap.set(svg, actualSizeViewport);
|
632
|
+
|
510
633
|
svg.style.width = wrapper.style.width;
|
511
634
|
svg.style.height = wrapper.style.height;
|
512
635
|
_this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
|
@@ -524,9 +647,10 @@ var PDFPageView = function () {
|
|
524
647
|
};
|
525
648
|
}
|
526
649
|
}, {
|
527
|
-
key:
|
650
|
+
key: "setPageLabel",
|
528
651
|
value: function setPageLabel(label) {
|
529
652
|
this.pageLabel = typeof label === 'string' ? label : null;
|
653
|
+
|
530
654
|
if (this.pageLabel !== null) {
|
531
655
|
this.div.setAttribute('data-page-label', this.pageLabel);
|
532
656
|
} else {
|
@@ -534,12 +658,12 @@ var PDFPageView = function () {
|
|
534
658
|
}
|
535
659
|
}
|
536
660
|
}, {
|
537
|
-
key:
|
661
|
+
key: "width",
|
538
662
|
get: function get() {
|
539
663
|
return this.viewport.width;
|
540
664
|
}
|
541
665
|
}, {
|
542
|
-
key:
|
666
|
+
key: "height",
|
543
667
|
get: function get() {
|
544
668
|
return this.viewport.height;
|
545
669
|
}
|