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