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