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.
- package/CODE_OF_CONDUCT.md +15 -0
- package/bower.json +1 -1
- package/build/pdf.js +21618 -14369
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +22758 -11399
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/image_decoders/pdf.image_decoders.js +11500 -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 +767 -258
- 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 +428 -157
- package/lib/core/cmap.js +326 -87
- package/lib/core/colorspace.js +874 -594
- package/lib/core/core_utils.js +173 -0
- package/lib/core/crypto.js +290 -45
- package/lib/core/document.js +575 -272
- package/lib/core/encodings.js +19 -10
- package/lib/core/evaluator.js +1032 -351
- package/lib/core/font_renderer.js +331 -97
- package/lib/core/fonts.js +813 -196
- package/lib/core/function.js +253 -27
- package/lib/core/glyphlist.js +5 -3
- package/lib/core/image.js +169 -62
- package/lib/core/image_utils.js +111 -0
- package/lib/core/jbig2.js +502 -72
- package/lib/core/jbig2_stream.js +19 -8
- package/lib/core/jpeg_stream.js +38 -13
- package/lib/core/jpg.js +293 -52
- package/lib/core/jpx.js +419 -12
- 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 +1368 -500
- package/lib/core/operator_list.js +159 -43
- package/lib/core/parser.js +544 -199
- package/lib/core/pattern.js +170 -21
- package/lib/core/pdf_manager.js +324 -134
- package/lib/core/primitives.js +169 -61
- package/lib/core/ps_parser.js +134 -45
- package/lib/core/standard_fonts.js +17 -17
- package/lib/core/stream.js +327 -34
- package/lib/core/type1_parser.js +148 -8
- package/lib/core/unicode.js +32 -5
- package/lib/core/worker.js +215 -229
- package/lib/core/worker_stream.js +277 -0
- package/lib/display/annotation_layer.js +618 -192
- package/lib/display/api.js +1798 -882
- package/lib/display/api_compatibility.js +5 -10
- package/lib/display/canvas.js +366 -45
- package/lib/display/content_disposition.js +71 -24
- package/lib/display/display_utils.js +777 -0
- package/lib/display/fetch_stream.js +205 -87
- 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 +38 -19
- package/lib/display/node_stream.js +367 -175
- package/lib/display/pattern_helper.js +103 -36
- package/lib/display/svg.js +1232 -519
- package/lib/display/text_layer.js +208 -75
- 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 +35 -14
- package/lib/pdf.worker.js +5 -3
- package/lib/shared/compatibility.js +170 -572
- package/lib/shared/global_scope.js +2 -2
- package/lib/shared/is_node.js +4 -4
- package/lib/shared/message_handler.js +216 -163
- package/lib/shared/streams_polyfill.js +21 -17
- package/lib/shared/util.js +495 -385
- package/lib/test/unit/annotation_spec.js +1464 -401
- package/lib/test/unit/api_spec.js +718 -361
- 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 +9 -10
- 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 +59 -20
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +17 -5
- package/lib/test/unit/jasmine-boot.js +33 -20
- package/lib/test/unit/message_handler_spec.js +30 -13
- 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 +22 -55
- package/lib/test/unit/network_utils_spec.js +105 -14
- package/lib/test/unit/node_stream_spec.js +58 -34
- 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 +55 -22
- 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 +9 -7
- package/lib/test/unit/ui_utils_spec.js +236 -36
- 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 +1252 -609
- package/lib/web/app_options.js +103 -65
- package/lib/web/base_viewer.js +522 -242
- package/lib/web/chromecom.js +259 -117
- package/lib/web/debugger.js +166 -22
- package/lib/web/download_manager.js +31 -12
- package/lib/web/firefox_print_service.js +27 -14
- package/lib/web/firefoxcom.js +318 -78
- 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 +174 -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 +144 -79
- package/lib/web/pdf_outline_viewer.js +124 -47
- package/lib/web/pdf_page_view.js +194 -74
- package/lib/web/pdf_presentation_mode.js +99 -34
- package/lib/web/pdf_print_service.js +59 -13
- package/lib/web/pdf_rendering_queue.js +28 -9
- package/lib/web/pdf_sidebar.js +144 -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 +82 -87
- package/lib/web/preferences.js +284 -91
- package/lib/web/secondary_toolbar.js +132 -59
- package/lib/web/text_layer_builder.js +134 -59
- package/lib/web/toolbar.js +80 -43
- package/lib/web/ui_utils.js +400 -134
- package/lib/web/view_history.js +215 -67
- package/lib/web/viewer_compatibility.js +3 -8
- package/package.json +3 -2
- package/web/pdf_viewer.css +23 -15
- package/web/pdf_viewer.js +3429 -1245
- package/web/pdf_viewer.js.map +1 -1
- package/external/streams/streams-lib.js +0 -3962
- package/lib/display/dom_utils.js +0 -429
- 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;
|
@@ -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:
|
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(
|
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:
|
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:
|
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
|
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:
|
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
|
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
|
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:
|
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:
|
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,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
|
-
|
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
|
+
_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({
|
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
|
-
|
405
|
-
this
|
406
|
-
|
503
|
+
this.eventBus.dispatch('pagerender', {
|
504
|
+
source: this,
|
505
|
+
pageNumber: this.id
|
506
|
+
});
|
407
507
|
return resultPromise;
|
408
508
|
}
|
409
509
|
}, {
|
410
|
-
key:
|
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', {
|
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({
|
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:
|
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({
|
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:
|
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:
|
657
|
+
key: "width",
|
538
658
|
get: function get() {
|
539
659
|
return this.viewport.width;
|
540
660
|
}
|
541
661
|
}, {
|
542
|
-
key:
|
662
|
+
key: "height",
|
543
663
|
get: function get() {
|
544
664
|
return this.viewport.height;
|
545
665
|
}
|