pdfjs-dist 2.0.943 → 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/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8286 -14230
- 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 +25500 -26628
- 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 +2887 -4094
- 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 +855 -778
- package/lib/core/arithmetic_decoder.js +325 -311
- package/lib/core/bidi.js +117 -50
- package/lib/core/ccitt.js +251 -89
- package/lib/core/ccitt_stream.js +26 -16
- package/lib/core/cff_parser.js +525 -197
- package/lib/core/charsets.js +6 -5
- package/lib/core/chunked_stream.js +541 -406
- package/lib/core/cmap.js +368 -253
- package/lib/core/colorspace.js +781 -800
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +609 -422
- package/lib/core/document.js +649 -481
- package/lib/core/encodings.js +33 -24
- package/lib/core/evaluator.js +1471 -736
- package/lib/core/font_renderer.js +289 -149
- package/lib/core/fonts.js +1067 -413
- package/lib/core/function.js +517 -287
- package/lib/core/glyphlist.js +4529 -4527
- package/lib/core/image.js +232 -114
- package/lib/core/image_utils.js +94 -0
- package/lib/core/jbig2.js +711 -342
- package/lib/core/jbig2_stream.js +31 -19
- package/lib/core/jpeg_stream.js +151 -26
- package/lib/core/jpg.js +433 -181
- package/lib/core/jpx.js +551 -143
- package/lib/core/jpx_stream.js +40 -28
- package/lib/core/metrics.js +2931 -2931
- package/lib/core/murmurhash3.js +104 -97
- package/lib/core/obj.js +1561 -1053
- package/lib/core/operator_list.js +192 -64
- package/lib/core/parser.js +1162 -864
- package/lib/core/pattern.js +224 -75
- package/lib/core/pdf_manager.js +154 -285
- package/lib/core/primitives.js +145 -69
- package/lib/core/ps_parser.js +212 -162
- package/lib/core/standard_fonts.js +245 -244
- package/lib/core/stream.js +353 -81
- package/lib/core/type1_parser.js +218 -68
- package/lib/core/unicode.js +1682 -1655
- package/lib/core/worker.js +233 -302
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +808 -862
- package/lib/display/api.js +1778 -1462
- package/lib/display/api_compatibility.js +14 -9
- package/lib/display/canvas.js +463 -140
- package/lib/display/content_disposition.js +86 -58
- package/lib/display/display_utils.js +524 -0
- package/lib/display/fetch_stream.js +202 -274
- package/lib/display/font_loader.js +311 -333
- package/lib/display/metadata.js +98 -88
- package/lib/display/network.js +343 -347
- package/lib/display/network_utils.js +46 -26
- package/lib/display/node_stream.js +326 -404
- package/lib/display/pattern_helper.js +168 -69
- package/lib/display/svg.js +1296 -885
- package/lib/display/text_layer.js +229 -103
- package/lib/display/transport_stream.js +290 -250
- package/lib/display/webgl.js +116 -83
- package/lib/display/worker_options.js +6 -5
- package/lib/display/xml_parser.js +358 -337
- package/lib/examples/node/domstubs.js +95 -39
- package/lib/pdf.js +49 -31
- package/lib/pdf.worker.js +7 -5
- package/lib/shared/compatibility.js +3 -145
- package/lib/shared/is_node.js +8 -7
- package/lib/shared/message_handler.js +367 -314
- package/lib/shared/util.js +421 -415
- package/lib/test/unit/annotation_spec.js +1570 -690
- package/lib/test/unit/api_spec.js +855 -493
- package/lib/test/unit/bidi_spec.js +12 -12
- package/lib/test/unit/cff_parser_spec.js +88 -61
- package/lib/test/unit/clitests_helper.js +9 -12
- package/lib/test/unit/cmap_spec.js +140 -88
- package/lib/test/unit/colorspace_spec.js +204 -152
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +194 -182
- package/lib/test/unit/custom_spec.js +50 -64
- package/lib/test/unit/display_svg_spec.js +53 -38
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +17 -22
- package/lib/test/unit/encodings_spec.js +15 -57
- package/lib/test/unit/evaluator_spec.js +90 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +219 -205
- package/lib/test/unit/jasmine-boot.js +68 -39
- package/lib/test/unit/message_handler_spec.js +187 -160
- package/lib/test/unit/metadata_spec.js +87 -34
- package/lib/test/unit/murmurhash3_spec.js +13 -13
- package/lib/test/unit/network_spec.js +26 -59
- package/lib/test/unit/network_utils_spec.js +187 -121
- package/lib/test/unit/node_stream_spec.js +98 -90
- package/lib/test/unit/parser_spec.js +173 -131
- package/lib/test/unit/pdf_find_controller_spec.js +148 -67
- package/lib/test/unit/pdf_find_utils_spec.js +35 -34
- package/lib/test/unit/pdf_history_spec.js +45 -33
- package/lib/test/unit/primitives_spec.js +161 -126
- package/lib/test/unit/stream_spec.js +22 -15
- package/lib/test/unit/test_utils.js +149 -98
- package/lib/test/unit/testreporter.js +36 -18
- package/lib/test/unit/type1_parser_spec.js +46 -44
- package/lib/test/unit/ui_utils_spec.js +388 -372
- package/lib/test/unit/unicode_spec.js +49 -46
- package/lib/test/unit/util_spec.js +144 -248
- package/lib/web/annotation_layer_builder.js +75 -95
- package/lib/web/app.js +1538 -1147
- package/lib/web/app_options.js +116 -104
- package/lib/web/base_viewer.js +950 -775
- package/lib/web/chromecom.js +217 -225
- package/lib/web/debugger.js +236 -148
- package/lib/web/download_manager.js +50 -50
- package/lib/web/firefox_print_service.js +51 -33
- package/lib/web/firefoxcom.js +225 -352
- package/lib/web/genericcom.js +30 -93
- package/lib/web/genericl10n.js +26 -143
- package/lib/web/grab_to_pan.js +57 -33
- package/lib/web/interfaces.js +105 -232
- package/lib/web/overlay_manager.js +73 -227
- package/lib/web/password_prompt.js +44 -62
- package/lib/web/pdf_attachment_viewer.js +118 -123
- package/lib/web/pdf_cursor_tools.js +89 -93
- package/lib/web/pdf_document_properties.js +242 -281
- package/lib/web/pdf_find_bar.js +157 -163
- package/lib/web/pdf_find_controller.js +598 -454
- package/lib/web/pdf_find_utils.js +32 -16
- package/lib/web/pdf_history.js +481 -355
- package/lib/web/pdf_link_service.js +355 -323
- package/lib/web/pdf_outline_viewer.js +167 -152
- package/lib/web/pdf_page_view.js +511 -457
- package/lib/web/pdf_presentation_mode.js +347 -335
- package/lib/web/pdf_print_service.js +133 -103
- package/lib/web/pdf_rendering_queue.js +98 -100
- package/lib/web/pdf_sidebar.js +323 -299
- package/lib/web/pdf_sidebar_resizer.js +107 -108
- package/lib/web/pdf_single_page_viewer.js +94 -146
- package/lib/web/pdf_thumbnail_view.js +319 -269
- package/lib/web/pdf_thumbnail_viewer.js +219 -199
- package/lib/web/pdf_viewer.component.js +111 -32
- package/lib/web/pdf_viewer.js +61 -101
- package/lib/web/preferences.js +87 -272
- package/lib/web/secondary_toolbar.js +207 -220
- package/lib/web/text_layer_builder.js +322 -322
- package/lib/web/toolbar.js +227 -180
- package/lib/web/ui_utils.js +476 -421
- package/lib/web/view_history.js +59 -208
- package/lib/web/viewer_compatibility.js +9 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +36 -22
- package/web/pdf_viewer.js +4407 -4516
- 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 -441
- package/lib/shared/streams_polyfill.js +0 -39
- package/lib/shared/url_polyfill.js +0 -50
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/web/dom_events.js +0 -140
package/lib/web/app.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.
|
@@ -19,99 +19,115 @@
|
|
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.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication =
|
27
|
+
exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
|
28
28
|
|
29
|
-
var
|
29
|
+
var _ui_utils = require("./ui_utils.js");
|
30
30
|
|
31
|
-
var
|
31
|
+
var _app_options = require("./app_options.js");
|
32
32
|
|
33
|
-
var
|
33
|
+
var _pdf = require("../pdf");
|
34
34
|
|
35
|
-
var
|
35
|
+
var _pdf_cursor_tools = require("./pdf_cursor_tools.js");
|
36
36
|
|
37
|
-
var
|
37
|
+
var _pdf_rendering_queue = require("./pdf_rendering_queue.js");
|
38
38
|
|
39
|
-
var
|
39
|
+
var _pdf_sidebar = require("./pdf_sidebar.js");
|
40
40
|
|
41
|
-
var
|
41
|
+
var _overlay_manager = require("./overlay_manager.js");
|
42
42
|
|
43
|
-
var
|
43
|
+
var _password_prompt = require("./password_prompt.js");
|
44
44
|
|
45
|
-
var
|
45
|
+
var _pdf_attachment_viewer = require("./pdf_attachment_viewer.js");
|
46
46
|
|
47
|
-
var
|
47
|
+
var _pdf_document_properties = require("./pdf_document_properties.js");
|
48
48
|
|
49
|
-
var
|
49
|
+
var _pdf_find_bar = require("./pdf_find_bar.js");
|
50
50
|
|
51
|
-
var
|
51
|
+
var _pdf_find_controller = require("./pdf_find_controller.js");
|
52
52
|
|
53
|
-
var
|
53
|
+
var _pdf_history = require("./pdf_history.js");
|
54
54
|
|
55
|
-
var
|
55
|
+
var _pdf_link_service = require("./pdf_link_service.js");
|
56
56
|
|
57
|
-
var
|
57
|
+
var _pdf_outline_viewer = require("./pdf_outline_viewer.js");
|
58
58
|
|
59
|
-
var
|
59
|
+
var _pdf_presentation_mode = require("./pdf_presentation_mode.js");
|
60
60
|
|
61
|
-
var
|
61
|
+
var _pdf_sidebar_resizer = require("./pdf_sidebar_resizer.js");
|
62
62
|
|
63
|
-
var
|
63
|
+
var _pdf_thumbnail_viewer = require("./pdf_thumbnail_viewer.js");
|
64
64
|
|
65
|
-
var
|
65
|
+
var _pdf_viewer = require("./pdf_viewer.js");
|
66
66
|
|
67
|
-
var
|
67
|
+
var _secondary_toolbar = require("./secondary_toolbar.js");
|
68
68
|
|
69
|
-
var
|
69
|
+
var _toolbar = require("./toolbar.js");
|
70
70
|
|
71
|
-
var
|
71
|
+
var _view_history = require("./view_history.js");
|
72
72
|
|
73
|
-
|
73
|
+
const DEFAULT_SCALE_DELTA = 1.1;
|
74
|
+
const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
|
75
|
+
const FORCE_PAGES_LOADED_TIMEOUT = 10000;
|
76
|
+
const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
|
77
|
+
const ViewOnLoad = {
|
78
|
+
UNKNOWN: -1,
|
79
|
+
PREVIOUS: 0,
|
80
|
+
INITIAL: 1
|
81
|
+
};
|
74
82
|
|
75
|
-
|
83
|
+
class DefaultExternalServices {
|
84
|
+
constructor() {
|
85
|
+
throw new Error("Cannot initialize DefaultExternalServices.");
|
86
|
+
}
|
76
87
|
|
77
|
-
|
88
|
+
static updateFindControlState(data) {}
|
78
89
|
|
79
|
-
|
90
|
+
static updateFindMatchesCount(data) {}
|
80
91
|
|
81
|
-
|
92
|
+
static initPassiveLoading(callbacks) {}
|
82
93
|
|
83
|
-
|
94
|
+
static fallback(data, callback) {}
|
84
95
|
|
85
|
-
|
86
|
-
var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
|
87
|
-
var FORCE_PAGES_LOADED_TIMEOUT = 10000;
|
88
|
-
var DefaultExternalServices = {
|
89
|
-
updateFindControlState: function updateFindControlState(data) {},
|
90
|
-
updateFindMatchesCount: function updateFindMatchesCount(data) {},
|
91
|
-
initPassiveLoading: function initPassiveLoading(callbacks) {},
|
92
|
-
fallback: function fallback(data, callback) {},
|
93
|
-
reportTelemetry: function reportTelemetry(data) {},
|
94
|
-
createDownloadManager: function createDownloadManager(options) {
|
95
|
-
throw new Error('Not implemented: createDownloadManager');
|
96
|
-
},
|
97
|
-
createPreferences: function createPreferences() {
|
98
|
-
throw new Error('Not implemented: createPreferences');
|
99
|
-
},
|
100
|
-
createL10n: function createL10n(options) {
|
101
|
-
throw new Error('Not implemented: createL10n');
|
102
|
-
},
|
96
|
+
static reportTelemetry(data) {}
|
103
97
|
|
104
|
-
|
105
|
-
|
106
|
-
supportsDocumentColors: true,
|
107
|
-
supportedMouseWheelZoomModifierKeys: {
|
108
|
-
ctrlKey: true,
|
109
|
-
metaKey: true
|
98
|
+
static createDownloadManager(options) {
|
99
|
+
throw new Error("Not implemented: createDownloadManager");
|
110
100
|
}
|
111
|
-
|
112
|
-
|
101
|
+
|
102
|
+
static createPreferences() {
|
103
|
+
throw new Error("Not implemented: createPreferences");
|
104
|
+
}
|
105
|
+
|
106
|
+
static createL10n(options) {
|
107
|
+
throw new Error("Not implemented: createL10n");
|
108
|
+
}
|
109
|
+
|
110
|
+
static get supportsIntegratedFind() {
|
111
|
+
return (0, _pdf.shadow)(this, "supportsIntegratedFind", false);
|
112
|
+
}
|
113
|
+
|
114
|
+
static get supportsDocumentFonts() {
|
115
|
+
return (0, _pdf.shadow)(this, "supportsDocumentFonts", true);
|
116
|
+
}
|
117
|
+
|
118
|
+
static get supportedMouseWheelZoomModifierKeys() {
|
119
|
+
return (0, _pdf.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
|
120
|
+
ctrlKey: true,
|
121
|
+
metaKey: true
|
122
|
+
});
|
123
|
+
}
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
exports.DefaultExternalServices = DefaultExternalServices;
|
128
|
+
const PDFViewerApplication = {
|
113
129
|
initialBookmark: document.location.hash.substring(1),
|
114
|
-
|
130
|
+
_initializedCapability: (0, _pdf.createPromiseCapability)(),
|
115
131
|
fellback: false,
|
116
132
|
appConfig: null,
|
117
133
|
pdfDocument: null,
|
@@ -140,444 +156,353 @@ var PDFViewerApplication = {
|
|
140
156
|
isInitialViewSet: false,
|
141
157
|
downloadComplete: false,
|
142
158
|
isViewerEmbedded: window.parent !== window,
|
143
|
-
url:
|
144
|
-
baseUrl:
|
159
|
+
url: "",
|
160
|
+
baseUrl: "",
|
145
161
|
externalServices: DefaultExternalServices,
|
146
162
|
_boundEvents: {},
|
147
163
|
contentDispositionFilename: null,
|
148
|
-
initialize: function () {
|
149
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(appConfig) {
|
150
|
-
var _this = this;
|
151
|
-
|
152
|
-
var appContainer;
|
153
|
-
return _regenerator2.default.wrap(function _callee$(_context) {
|
154
|
-
while (1) {
|
155
|
-
switch (_context.prev = _context.next) {
|
156
|
-
case 0:
|
157
|
-
this.preferences = this.externalServices.createPreferences();
|
158
|
-
this.appConfig = appConfig;
|
159
|
-
_context.next = 4;
|
160
|
-
return this._readPreferences();
|
161
|
-
|
162
|
-
case 4:
|
163
|
-
_context.next = 6;
|
164
|
-
return this._parseHashParameters();
|
165
|
-
|
166
|
-
case 6:
|
167
|
-
_context.next = 8;
|
168
|
-
return this._initializeL10n();
|
169
|
-
|
170
|
-
case 8:
|
171
|
-
if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdf.LinkTarget.NONE) {
|
172
|
-
_app_options.AppOptions.set('externalLinkTarget', _pdf.LinkTarget.TOP);
|
173
|
-
}
|
174
|
-
_context.next = 11;
|
175
|
-
return this._initializeViewerComponents();
|
176
|
-
|
177
|
-
case 11:
|
178
|
-
this.bindEvents();
|
179
|
-
this.bindWindowEvents();
|
180
|
-
appContainer = appConfig.appContainer || document.documentElement;
|
181
|
-
|
182
|
-
this.l10n.translate(appContainer).then(function () {
|
183
|
-
_this.eventBus.dispatch('localized', { source: _this });
|
184
|
-
});
|
185
|
-
this.initialized = true;
|
186
|
-
|
187
|
-
case 16:
|
188
|
-
case 'end':
|
189
|
-
return _context.stop();
|
190
|
-
}
|
191
|
-
}
|
192
|
-
}, _callee, this);
|
193
|
-
}));
|
194
|
-
|
195
|
-
function initialize(_x) {
|
196
|
-
return _ref.apply(this, arguments);
|
197
|
-
}
|
198
|
-
|
199
|
-
return initialize;
|
200
|
-
}(),
|
201
|
-
_readPreferences: function () {
|
202
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
|
203
|
-
var OVERRIDES, prefs, name;
|
204
|
-
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
205
|
-
while (1) {
|
206
|
-
switch (_context2.prev = _context2.next) {
|
207
|
-
case 0:
|
208
|
-
OVERRIDES = {
|
209
|
-
disableFontFace: true,
|
210
|
-
disableRange: true,
|
211
|
-
disableStream: true,
|
212
|
-
textLayerMode: _ui_utils.TextLayerMode.DISABLE
|
213
|
-
};
|
214
|
-
_context2.prev = 1;
|
215
|
-
_context2.next = 4;
|
216
|
-
return this.preferences.getAll();
|
217
|
-
|
218
|
-
case 4:
|
219
|
-
prefs = _context2.sent;
|
220
|
-
_context2.t0 = _regenerator2.default.keys(prefs);
|
221
|
-
|
222
|
-
case 6:
|
223
|
-
if ((_context2.t1 = _context2.t0()).done) {
|
224
|
-
_context2.next = 13;
|
225
|
-
break;
|
226
|
-
}
|
227
|
-
|
228
|
-
name = _context2.t1.value;
|
229
|
-
|
230
|
-
if (!(name in OVERRIDES && _app_options.AppOptions.get(name) === OVERRIDES[name])) {
|
231
|
-
_context2.next = 10;
|
232
|
-
break;
|
233
|
-
}
|
234
|
-
|
235
|
-
return _context2.abrupt('continue', 6);
|
236
|
-
|
237
|
-
case 10:
|
238
|
-
_app_options.AppOptions.set(name, prefs[name]);
|
239
|
-
_context2.next = 6;
|
240
|
-
break;
|
241
164
|
|
242
|
-
|
243
|
-
|
244
|
-
|
165
|
+
async initialize(appConfig) {
|
166
|
+
this.preferences = this.externalServices.createPreferences();
|
167
|
+
this.appConfig = appConfig;
|
168
|
+
await this._readPreferences();
|
169
|
+
await this._parseHashParameters();
|
170
|
+
await this._initializeL10n();
|
245
171
|
|
246
|
-
|
247
|
-
|
248
|
-
|
172
|
+
if (this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdf.LinkTarget.NONE) {
|
173
|
+
_app_options.AppOptions.set("externalLinkTarget", _pdf.LinkTarget.TOP);
|
174
|
+
}
|
249
175
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
return _ref2.apply(this, arguments);
|
260
|
-
}
|
261
|
-
|
262
|
-
return _readPreferences;
|
263
|
-
}(),
|
264
|
-
_parseHashParameters: function () {
|
265
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
|
266
|
-
var waitOn, hash, hashParams, viewer, enabled;
|
267
|
-
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
268
|
-
while (1) {
|
269
|
-
switch (_context3.prev = _context3.next) {
|
270
|
-
case 0:
|
271
|
-
if (_app_options.AppOptions.get('pdfBugEnabled')) {
|
272
|
-
_context3.next = 2;
|
273
|
-
break;
|
274
|
-
}
|
275
|
-
|
276
|
-
return _context3.abrupt('return');
|
277
|
-
|
278
|
-
case 2:
|
279
|
-
waitOn = [];
|
280
|
-
hash = document.location.hash.substring(1);
|
281
|
-
hashParams = (0, _ui_utils.parseQueryString)(hash);
|
282
|
-
|
283
|
-
if ('disableworker' in hashParams && hashParams['disableworker'] === 'true') {
|
284
|
-
waitOn.push(loadFakeWorker());
|
285
|
-
}
|
286
|
-
if ('disablerange' in hashParams) {
|
287
|
-
_app_options.AppOptions.set('disableRange', hashParams['disablerange'] === 'true');
|
288
|
-
}
|
289
|
-
if ('disablestream' in hashParams) {
|
290
|
-
_app_options.AppOptions.set('disableStream', hashParams['disablestream'] === 'true');
|
291
|
-
}
|
292
|
-
if ('disableautofetch' in hashParams) {
|
293
|
-
_app_options.AppOptions.set('disableAutoFetch', hashParams['disableautofetch'] === 'true');
|
294
|
-
}
|
295
|
-
if ('disablefontface' in hashParams) {
|
296
|
-
_app_options.AppOptions.set('disableFontFace', hashParams['disablefontface'] === 'true');
|
297
|
-
}
|
298
|
-
if ('disablehistory' in hashParams) {
|
299
|
-
_app_options.AppOptions.set('disableHistory', hashParams['disablehistory'] === 'true');
|
300
|
-
}
|
301
|
-
if ('webgl' in hashParams) {
|
302
|
-
_app_options.AppOptions.set('enableWebGL', hashParams['webgl'] === 'true');
|
303
|
-
}
|
304
|
-
if ('useonlycsszoom' in hashParams) {
|
305
|
-
_app_options.AppOptions.set('useOnlyCssZoom', hashParams['useonlycsszoom'] === 'true');
|
306
|
-
}
|
307
|
-
if ('verbosity' in hashParams) {
|
308
|
-
_app_options.AppOptions.set('verbosity', hashParams['verbosity'] | 0);
|
309
|
-
}
|
310
|
-
|
311
|
-
if (!('textlayer' in hashParams)) {
|
312
|
-
_context3.next = 23;
|
313
|
-
break;
|
314
|
-
}
|
315
|
-
|
316
|
-
_context3.t0 = hashParams['textlayer'];
|
317
|
-
_context3.next = _context3.t0 === 'off' ? 18 : _context3.t0 === 'visible' ? 20 : _context3.t0 === 'shadow' ? 20 : _context3.t0 === 'hover' ? 20 : 23;
|
318
|
-
break;
|
176
|
+
await this._initializeViewerComponents();
|
177
|
+
this.bindEvents();
|
178
|
+
this.bindWindowEvents();
|
179
|
+
const appContainer = appConfig.appContainer || document.documentElement;
|
180
|
+
this.l10n.translate(appContainer).then(() => {
|
181
|
+
this.eventBus.dispatch("localized", {
|
182
|
+
source: this
|
183
|
+
});
|
184
|
+
});
|
319
185
|
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
return _parseHashParameters;
|
357
|
-
}(),
|
358
|
-
_initializeL10n: function () {
|
359
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4() {
|
360
|
-
var dir;
|
361
|
-
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
362
|
-
while (1) {
|
363
|
-
switch (_context4.prev = _context4.next) {
|
364
|
-
case 0:
|
365
|
-
this.l10n = this.externalServices.createL10n({ locale: _app_options.AppOptions.get('locale') });
|
366
|
-
_context4.next = 3;
|
367
|
-
return this.l10n.getDirection();
|
368
|
-
|
369
|
-
case 3:
|
370
|
-
dir = _context4.sent;
|
371
|
-
|
372
|
-
document.getElementsByTagName('html')[0].dir = dir;
|
373
|
-
|
374
|
-
case 5:
|
375
|
-
case 'end':
|
376
|
-
return _context4.stop();
|
377
|
-
}
|
378
|
-
}
|
379
|
-
}, _callee4, this);
|
380
|
-
}));
|
381
|
-
|
382
|
-
function _initializeL10n() {
|
383
|
-
return _ref4.apply(this, arguments);
|
384
|
-
}
|
385
|
-
|
386
|
-
return _initializeL10n;
|
387
|
-
}(),
|
388
|
-
_initializeViewerComponents: function () {
|
389
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5() {
|
390
|
-
var appConfig, dispatchToDOM, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer, thumbnailContainer, sidebarConfig;
|
391
|
-
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
392
|
-
while (1) {
|
393
|
-
switch (_context5.prev = _context5.next) {
|
394
|
-
case 0:
|
395
|
-
appConfig = this.appConfig;
|
396
|
-
|
397
|
-
this.overlayManager = new _overlay_manager.OverlayManager();
|
398
|
-
dispatchToDOM = _app_options.AppOptions.get('eventBusDispatchToDOM');
|
399
|
-
eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)(dispatchToDOM);
|
400
|
-
|
401
|
-
this.eventBus = eventBus;
|
402
|
-
pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
|
403
|
-
|
404
|
-
pdfRenderingQueue.onIdle = this.cleanup.bind(this);
|
405
|
-
this.pdfRenderingQueue = pdfRenderingQueue;
|
406
|
-
pdfLinkService = new _pdf_link_service.PDFLinkService({
|
407
|
-
eventBus: eventBus,
|
408
|
-
externalLinkTarget: _app_options.AppOptions.get('externalLinkTarget'),
|
409
|
-
externalLinkRel: _app_options.AppOptions.get('externalLinkRel')
|
410
|
-
});
|
411
|
-
|
412
|
-
this.pdfLinkService = pdfLinkService;
|
413
|
-
downloadManager = this.externalServices.createDownloadManager({ disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL') });
|
414
|
-
|
415
|
-
this.downloadManager = downloadManager;
|
416
|
-
findController = new _pdf_find_controller.PDFFindController({
|
417
|
-
linkService: pdfLinkService,
|
418
|
-
eventBus: eventBus
|
419
|
-
});
|
420
|
-
|
421
|
-
this.findController = findController;
|
422
|
-
container = appConfig.mainContainer;
|
423
|
-
viewer = appConfig.viewerContainer;
|
424
|
-
|
425
|
-
this.pdfViewer = new _pdf_viewer.PDFViewer({
|
426
|
-
container: container,
|
427
|
-
viewer: viewer,
|
428
|
-
eventBus: eventBus,
|
429
|
-
renderingQueue: pdfRenderingQueue,
|
430
|
-
linkService: pdfLinkService,
|
431
|
-
downloadManager: downloadManager,
|
432
|
-
findController: findController,
|
433
|
-
renderer: _app_options.AppOptions.get('renderer'),
|
434
|
-
enableWebGL: _app_options.AppOptions.get('enableWebGL'),
|
435
|
-
l10n: this.l10n,
|
436
|
-
textLayerMode: _app_options.AppOptions.get('textLayerMode'),
|
437
|
-
imageResourcesPath: _app_options.AppOptions.get('imageResourcesPath'),
|
438
|
-
renderInteractiveForms: _app_options.AppOptions.get('renderInteractiveForms'),
|
439
|
-
enablePrintAutoRotate: _app_options.AppOptions.get('enablePrintAutoRotate'),
|
440
|
-
useOnlyCssZoom: _app_options.AppOptions.get('useOnlyCssZoom'),
|
441
|
-
maxCanvasPixels: _app_options.AppOptions.get('maxCanvasPixels')
|
442
|
-
});
|
443
|
-
pdfRenderingQueue.setViewer(this.pdfViewer);
|
444
|
-
pdfLinkService.setViewer(this.pdfViewer);
|
445
|
-
thumbnailContainer = appConfig.sidebar.thumbnailView;
|
446
|
-
|
447
|
-
this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
|
448
|
-
container: thumbnailContainer,
|
449
|
-
renderingQueue: pdfRenderingQueue,
|
450
|
-
linkService: pdfLinkService,
|
451
|
-
l10n: this.l10n
|
452
|
-
});
|
453
|
-
pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
|
454
|
-
this.pdfHistory = new _pdf_history.PDFHistory({
|
455
|
-
linkService: pdfLinkService,
|
456
|
-
eventBus: eventBus
|
457
|
-
});
|
458
|
-
pdfLinkService.setHistory(this.pdfHistory);
|
459
|
-
this.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, this.l10n);
|
460
|
-
this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n);
|
461
|
-
this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
|
462
|
-
container: container,
|
463
|
-
eventBus: eventBus,
|
464
|
-
cursorToolOnLoad: _app_options.AppOptions.get('cursorToolOnLoad')
|
465
|
-
});
|
466
|
-
this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n);
|
467
|
-
this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
|
468
|
-
if (this.supportsFullscreen) {
|
469
|
-
this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
|
470
|
-
container: container,
|
471
|
-
viewer: viewer,
|
472
|
-
pdfViewer: this.pdfViewer,
|
473
|
-
eventBus: eventBus,
|
474
|
-
contextMenuItems: appConfig.fullscreen
|
475
|
-
});
|
476
|
-
}
|
477
|
-
this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n);
|
478
|
-
this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
|
479
|
-
container: appConfig.sidebar.outlineView,
|
480
|
-
eventBus: eventBus,
|
481
|
-
linkService: pdfLinkService
|
482
|
-
});
|
483
|
-
this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
|
484
|
-
container: appConfig.sidebar.attachmentsView,
|
485
|
-
eventBus: eventBus,
|
486
|
-
downloadManager: downloadManager
|
487
|
-
});
|
488
|
-
sidebarConfig = Object.create(appConfig.sidebar);
|
489
|
-
|
490
|
-
sidebarConfig.pdfViewer = this.pdfViewer;
|
491
|
-
sidebarConfig.pdfThumbnailViewer = this.pdfThumbnailViewer;
|
492
|
-
this.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, eventBus, this.l10n);
|
493
|
-
this.pdfSidebar.onToggled = this.forceRendering.bind(this);
|
494
|
-
this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
|
495
|
-
|
496
|
-
case 39:
|
497
|
-
case 'end':
|
498
|
-
return _context5.stop();
|
499
|
-
}
|
500
|
-
}
|
501
|
-
}, _callee5, this);
|
502
|
-
}));
|
186
|
+
this._initializedCapability.resolve();
|
187
|
+
},
|
188
|
+
|
189
|
+
async _readPreferences() {
|
190
|
+
if (_app_options.AppOptions.get("disablePreferences") === true) {
|
191
|
+
return;
|
192
|
+
}
|
193
|
+
|
194
|
+
try {
|
195
|
+
const prefs = await this.preferences.getAll();
|
196
|
+
|
197
|
+
for (const name in prefs) {
|
198
|
+
_app_options.AppOptions.set(name, prefs[name]);
|
199
|
+
}
|
200
|
+
} catch (reason) {
|
201
|
+
console.error(`_readPreferences: "${reason.message}".`);
|
202
|
+
}
|
203
|
+
},
|
204
|
+
|
205
|
+
async _parseHashParameters() {
|
206
|
+
if (!_app_options.AppOptions.get("pdfBugEnabled")) {
|
207
|
+
return undefined;
|
208
|
+
}
|
209
|
+
|
210
|
+
const hash = document.location.hash.substring(1);
|
211
|
+
|
212
|
+
if (!hash) {
|
213
|
+
return undefined;
|
214
|
+
}
|
215
|
+
|
216
|
+
const hashParams = (0, _ui_utils.parseQueryString)(hash),
|
217
|
+
waitOn = [];
|
218
|
+
|
219
|
+
if ("disableworker" in hashParams && hashParams["disableworker"] === "true") {
|
220
|
+
waitOn.push(loadFakeWorker());
|
221
|
+
}
|
503
222
|
|
504
|
-
|
505
|
-
|
223
|
+
if ("disablerange" in hashParams) {
|
224
|
+
_app_options.AppOptions.set("disableRange", hashParams["disablerange"] === "true");
|
506
225
|
}
|
507
226
|
|
508
|
-
|
509
|
-
|
510
|
-
|
227
|
+
if ("disablestream" in hashParams) {
|
228
|
+
_app_options.AppOptions.set("disableStream", hashParams["disablestream"] === "true");
|
229
|
+
}
|
230
|
+
|
231
|
+
if ("disableautofetch" in hashParams) {
|
232
|
+
_app_options.AppOptions.set("disableAutoFetch", hashParams["disableautofetch"] === "true");
|
233
|
+
}
|
234
|
+
|
235
|
+
if ("disablefontface" in hashParams) {
|
236
|
+
_app_options.AppOptions.set("disableFontFace", hashParams["disablefontface"] === "true");
|
237
|
+
}
|
238
|
+
|
239
|
+
if ("disablehistory" in hashParams) {
|
240
|
+
_app_options.AppOptions.set("disableHistory", hashParams["disablehistory"] === "true");
|
241
|
+
}
|
242
|
+
|
243
|
+
if ("webgl" in hashParams) {
|
244
|
+
_app_options.AppOptions.set("enableWebGL", hashParams["webgl"] === "true");
|
245
|
+
}
|
246
|
+
|
247
|
+
if ("verbosity" in hashParams) {
|
248
|
+
_app_options.AppOptions.set("verbosity", hashParams["verbosity"] | 0);
|
249
|
+
}
|
250
|
+
|
251
|
+
if ("textlayer" in hashParams) {
|
252
|
+
switch (hashParams["textlayer"]) {
|
253
|
+
case "off":
|
254
|
+
_app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
|
255
|
+
|
256
|
+
break;
|
257
|
+
|
258
|
+
case "visible":
|
259
|
+
case "shadow":
|
260
|
+
case "hover":
|
261
|
+
const viewer = this.appConfig.viewerContainer;
|
262
|
+
viewer.classList.add("textLayer-" + hashParams["textlayer"]);
|
263
|
+
break;
|
264
|
+
}
|
265
|
+
}
|
266
|
+
|
267
|
+
if ("pdfbug" in hashParams) {
|
268
|
+
_app_options.AppOptions.set("pdfBug", true);
|
269
|
+
|
270
|
+
const enabled = hashParams["pdfbug"].split(",");
|
271
|
+
waitOn.push(loadAndEnablePDFBug(enabled));
|
272
|
+
}
|
273
|
+
|
274
|
+
if ("locale" in hashParams) {
|
275
|
+
_app_options.AppOptions.set("locale", hashParams["locale"]);
|
276
|
+
}
|
277
|
+
|
278
|
+
return Promise.all(waitOn).catch(reason => {
|
279
|
+
console.error(`_parseHashParameters: "${reason.message}".`);
|
280
|
+
});
|
281
|
+
},
|
282
|
+
|
283
|
+
async _initializeL10n() {
|
284
|
+
this.l10n = this.externalServices.createL10n({
|
285
|
+
locale: _app_options.AppOptions.get("locale")
|
286
|
+
});
|
287
|
+
const dir = await this.l10n.getDirection();
|
288
|
+
document.getElementsByTagName("html")[0].dir = dir;
|
289
|
+
},
|
290
|
+
|
291
|
+
async _initializeViewerComponents() {
|
292
|
+
const appConfig = this.appConfig;
|
293
|
+
this.overlayManager = new _overlay_manager.OverlayManager();
|
294
|
+
const eventBus = appConfig.eventBus || new _ui_utils.EventBus({
|
295
|
+
dispatchToDOM: _app_options.AppOptions.get("eventBusDispatchToDOM")
|
296
|
+
});
|
297
|
+
this.eventBus = eventBus;
|
298
|
+
const pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
|
299
|
+
pdfRenderingQueue.onIdle = this.cleanup.bind(this);
|
300
|
+
this.pdfRenderingQueue = pdfRenderingQueue;
|
301
|
+
const pdfLinkService = new _pdf_link_service.PDFLinkService({
|
302
|
+
eventBus,
|
303
|
+
externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
|
304
|
+
externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
|
305
|
+
ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
|
306
|
+
});
|
307
|
+
this.pdfLinkService = pdfLinkService;
|
308
|
+
const downloadManager = this.externalServices.createDownloadManager({
|
309
|
+
disableCreateObjectURL: _app_options.AppOptions.get("disableCreateObjectURL")
|
310
|
+
});
|
311
|
+
this.downloadManager = downloadManager;
|
312
|
+
const findController = new _pdf_find_controller.PDFFindController({
|
313
|
+
linkService: pdfLinkService,
|
314
|
+
eventBus
|
315
|
+
});
|
316
|
+
this.findController = findController;
|
317
|
+
const container = appConfig.mainContainer;
|
318
|
+
const viewer = appConfig.viewerContainer;
|
319
|
+
this.pdfViewer = new _pdf_viewer.PDFViewer({
|
320
|
+
container,
|
321
|
+
viewer,
|
322
|
+
eventBus,
|
323
|
+
renderingQueue: pdfRenderingQueue,
|
324
|
+
linkService: pdfLinkService,
|
325
|
+
downloadManager,
|
326
|
+
findController,
|
327
|
+
renderer: _app_options.AppOptions.get("renderer"),
|
328
|
+
enableWebGL: _app_options.AppOptions.get("enableWebGL"),
|
329
|
+
l10n: this.l10n,
|
330
|
+
textLayerMode: _app_options.AppOptions.get("textLayerMode"),
|
331
|
+
imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
|
332
|
+
renderInteractiveForms: _app_options.AppOptions.get("renderInteractiveForms"),
|
333
|
+
enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
|
334
|
+
useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"),
|
335
|
+
maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels")
|
336
|
+
});
|
337
|
+
pdfRenderingQueue.setViewer(this.pdfViewer);
|
338
|
+
pdfLinkService.setViewer(this.pdfViewer);
|
339
|
+
this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
|
340
|
+
container: appConfig.sidebar.thumbnailView,
|
341
|
+
renderingQueue: pdfRenderingQueue,
|
342
|
+
linkService: pdfLinkService,
|
343
|
+
l10n: this.l10n
|
344
|
+
});
|
345
|
+
pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
|
346
|
+
this.pdfHistory = new _pdf_history.PDFHistory({
|
347
|
+
linkService: pdfLinkService,
|
348
|
+
eventBus
|
349
|
+
});
|
350
|
+
pdfLinkService.setHistory(this.pdfHistory);
|
351
|
+
|
352
|
+
if (!this.supportsIntegratedFind) {
|
353
|
+
this.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, this.l10n);
|
354
|
+
}
|
355
|
+
|
356
|
+
this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n);
|
357
|
+
this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
|
358
|
+
container,
|
359
|
+
eventBus,
|
360
|
+
cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
|
361
|
+
});
|
362
|
+
this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n);
|
363
|
+
this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
|
364
|
+
|
365
|
+
if (this.supportsFullscreen) {
|
366
|
+
this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
|
367
|
+
container,
|
368
|
+
pdfViewer: this.pdfViewer,
|
369
|
+
eventBus,
|
370
|
+
contextMenuItems: appConfig.fullscreen
|
371
|
+
});
|
372
|
+
}
|
373
|
+
|
374
|
+
this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n);
|
375
|
+
this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
|
376
|
+
container: appConfig.sidebar.outlineView,
|
377
|
+
eventBus,
|
378
|
+
linkService: pdfLinkService
|
379
|
+
});
|
380
|
+
this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
|
381
|
+
container: appConfig.sidebar.attachmentsView,
|
382
|
+
eventBus,
|
383
|
+
downloadManager
|
384
|
+
});
|
385
|
+
this.pdfSidebar = new _pdf_sidebar.PDFSidebar({
|
386
|
+
elements: appConfig.sidebar,
|
387
|
+
pdfViewer: this.pdfViewer,
|
388
|
+
pdfThumbnailViewer: this.pdfThumbnailViewer,
|
389
|
+
eventBus,
|
390
|
+
l10n: this.l10n
|
391
|
+
});
|
392
|
+
this.pdfSidebar.onToggled = this.forceRendering.bind(this);
|
393
|
+
this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
|
394
|
+
},
|
395
|
+
|
396
|
+
run(config) {
|
511
397
|
this.initialize(config).then(webViewerInitialized);
|
512
398
|
},
|
513
|
-
|
514
|
-
|
399
|
+
|
400
|
+
get initialized() {
|
401
|
+
return this._initializedCapability.settled;
|
402
|
+
},
|
403
|
+
|
404
|
+
get initializedPromise() {
|
405
|
+
return this._initializedCapability.promise;
|
406
|
+
},
|
407
|
+
|
408
|
+
zoomIn(ticks) {
|
409
|
+
if (this.pdfViewer.isInPresentationMode) {
|
410
|
+
return;
|
411
|
+
}
|
412
|
+
|
413
|
+
let newScale = this.pdfViewer.currentScale;
|
414
|
+
|
515
415
|
do {
|
516
416
|
newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
|
517
417
|
newScale = Math.ceil(newScale * 10) / 10;
|
518
418
|
newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
|
519
419
|
} while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
|
420
|
+
|
520
421
|
this.pdfViewer.currentScaleValue = newScale;
|
521
422
|
},
|
522
|
-
|
523
|
-
|
423
|
+
|
424
|
+
zoomOut(ticks) {
|
425
|
+
if (this.pdfViewer.isInPresentationMode) {
|
426
|
+
return;
|
427
|
+
}
|
428
|
+
|
429
|
+
let newScale = this.pdfViewer.currentScale;
|
430
|
+
|
524
431
|
do {
|
525
432
|
newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
|
526
433
|
newScale = Math.floor(newScale * 10) / 10;
|
527
434
|
newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
|
528
435
|
} while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
|
436
|
+
|
529
437
|
this.pdfViewer.currentScaleValue = newScale;
|
530
438
|
},
|
531
439
|
|
440
|
+
zoomReset() {
|
441
|
+
if (this.pdfViewer.isInPresentationMode) {
|
442
|
+
return;
|
443
|
+
}
|
444
|
+
|
445
|
+
this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
|
446
|
+
},
|
447
|
+
|
532
448
|
get pagesCount() {
|
533
449
|
return this.pdfDocument ? this.pdfDocument.numPages : 0;
|
534
450
|
},
|
451
|
+
|
535
452
|
set page(val) {
|
536
453
|
this.pdfViewer.currentPageNumber = val;
|
537
454
|
},
|
455
|
+
|
538
456
|
get page() {
|
539
457
|
return this.pdfViewer.currentPageNumber;
|
540
458
|
},
|
459
|
+
|
541
460
|
get printing() {
|
542
461
|
return !!this.printService;
|
543
462
|
},
|
463
|
+
|
544
464
|
get supportsPrinting() {
|
545
465
|
return PDFPrintServiceFactory.instance.supportsPrinting;
|
546
466
|
},
|
467
|
+
|
547
468
|
get supportsFullscreen() {
|
548
|
-
|
549
|
-
|
469
|
+
let support;
|
470
|
+
const doc = document.documentElement;
|
550
471
|
support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
|
472
|
+
|
551
473
|
if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
|
552
474
|
support = false;
|
553
475
|
}
|
554
|
-
|
476
|
+
|
477
|
+
return (0, _pdf.shadow)(this, "supportsFullscreen", support);
|
555
478
|
},
|
479
|
+
|
556
480
|
get supportsIntegratedFind() {
|
557
481
|
return this.externalServices.supportsIntegratedFind;
|
558
482
|
},
|
483
|
+
|
559
484
|
get supportsDocumentFonts() {
|
560
485
|
return this.externalServices.supportsDocumentFonts;
|
561
486
|
},
|
562
|
-
|
563
|
-
return this.externalServices.supportsDocumentColors;
|
564
|
-
},
|
487
|
+
|
565
488
|
get loadingBar() {
|
566
|
-
|
567
|
-
return (0, _pdf.shadow)(this,
|
489
|
+
const bar = new _ui_utils.ProgressBar("#loadingBar");
|
490
|
+
return (0, _pdf.shadow)(this, "loadingBar", bar);
|
568
491
|
},
|
492
|
+
|
569
493
|
get supportedMouseWheelZoomModifierKeys() {
|
570
494
|
return this.externalServices.supportedMouseWheelZoomModifierKeys;
|
571
495
|
},
|
572
|
-
|
573
|
-
|
496
|
+
|
497
|
+
initPassiveLoading() {
|
498
|
+
throw new Error("Not implemented: initPassiveLoading");
|
574
499
|
},
|
575
|
-
setTitleUsingUrl: function setTitleUsingUrl() {
|
576
|
-
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
577
500
|
|
501
|
+
setTitleUsingUrl(url = "") {
|
578
502
|
this.url = url;
|
579
|
-
this.baseUrl = url.split(
|
580
|
-
|
503
|
+
this.baseUrl = url.split("#")[0];
|
504
|
+
let title = (0, _ui_utils.getPDFFileNameFromURL)(url, "");
|
505
|
+
|
581
506
|
if (!title) {
|
582
507
|
try {
|
583
508
|
title = decodeURIComponent((0, _pdf.getFilenameFromUrl)(url)) || url;
|
@@ -585,508 +510,623 @@ var PDFViewerApplication = {
|
|
585
510
|
title = url;
|
586
511
|
}
|
587
512
|
}
|
513
|
+
|
588
514
|
this.setTitle(title);
|
589
515
|
},
|
590
|
-
|
516
|
+
|
517
|
+
setTitle(title) {
|
591
518
|
if (this.isViewerEmbedded) {
|
592
519
|
return;
|
593
520
|
}
|
521
|
+
|
594
522
|
document.title = title;
|
595
523
|
},
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
this.setTitleUsingUrl(file);
|
684
|
-
parameters.url = file;
|
685
|
-
} else if (file && 'byteLength' in file) {
|
686
|
-
parameters.data = file;
|
687
|
-
} else if (file.url && file.originalUrl) {
|
688
|
-
this.setTitleUsingUrl(file.originalUrl);
|
689
|
-
parameters.url = file.url;
|
690
|
-
}
|
691
|
-
apiParameters = _app_options.AppOptions.getAll('api');
|
692
|
-
|
693
|
-
for (_key in apiParameters) {
|
694
|
-
parameters[_key] = apiParameters[_key];
|
695
|
-
}
|
696
|
-
if (args) {
|
697
|
-
for (prop in args) {
|
698
|
-
if (prop === 'length') {
|
699
|
-
this.pdfDocumentProperties.setFileSize(args[prop]);
|
700
|
-
}
|
701
|
-
parameters[prop] = args[prop];
|
702
|
-
}
|
703
|
-
}
|
704
|
-
loadingTask = (0, _pdf.getDocument)(parameters);
|
705
|
-
|
706
|
-
this.pdfLoadingTask = loadingTask;
|
707
|
-
loadingTask.onPassword = function (updateCallback, reason) {
|
708
|
-
_this2.passwordPrompt.setUpdateCallback(updateCallback, reason);
|
709
|
-
_this2.passwordPrompt.open();
|
710
|
-
};
|
711
|
-
loadingTask.onProgress = function (_ref8) {
|
712
|
-
var loaded = _ref8.loaded,
|
713
|
-
total = _ref8.total;
|
714
|
-
|
715
|
-
_this2.progress(loaded / total);
|
716
|
-
};
|
717
|
-
loadingTask.onUnsupportedFeature = this.fallback.bind(this);
|
718
|
-
return _context7.abrupt('return', loadingTask.promise.then(function (pdfDocument) {
|
719
|
-
_this2.load(pdfDocument);
|
720
|
-
}, function (exception) {
|
721
|
-
if (loadingTask !== _this2.pdfLoadingTask) {
|
722
|
-
return;
|
723
|
-
}
|
724
|
-
var message = exception && exception.message;
|
725
|
-
var loadingErrorMessage = void 0;
|
726
|
-
if (exception instanceof _pdf.InvalidPDFException) {
|
727
|
-
loadingErrorMessage = _this2.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
|
728
|
-
} else if (exception instanceof _pdf.MissingPDFException) {
|
729
|
-
loadingErrorMessage = _this2.l10n.get('missing_file_error', null, 'Missing PDF file.');
|
730
|
-
} else if (exception instanceof _pdf.UnexpectedResponseException) {
|
731
|
-
loadingErrorMessage = _this2.l10n.get('unexpected_response_error', null, 'Unexpected server response.');
|
732
|
-
} else {
|
733
|
-
loadingErrorMessage = _this2.l10n.get('loading_error', null, 'An error occurred while loading the PDF.');
|
734
|
-
}
|
735
|
-
return loadingErrorMessage.then(function (msg) {
|
736
|
-
_this2.error(msg, { message: message });
|
737
|
-
throw new Error(msg);
|
738
|
-
});
|
739
|
-
}));
|
740
|
-
|
741
|
-
case 16:
|
742
|
-
case 'end':
|
743
|
-
return _context7.stop();
|
744
|
-
}
|
524
|
+
|
525
|
+
async close() {
|
526
|
+
const errorWrapper = this.appConfig.errorWrapper.container;
|
527
|
+
errorWrapper.setAttribute("hidden", "true");
|
528
|
+
|
529
|
+
if (!this.pdfLoadingTask) {
|
530
|
+
return undefined;
|
531
|
+
}
|
532
|
+
|
533
|
+
const promise = this.pdfLoadingTask.destroy();
|
534
|
+
this.pdfLoadingTask = null;
|
535
|
+
|
536
|
+
if (this.pdfDocument) {
|
537
|
+
this.pdfDocument = null;
|
538
|
+
this.pdfThumbnailViewer.setDocument(null);
|
539
|
+
this.pdfViewer.setDocument(null);
|
540
|
+
this.pdfLinkService.setDocument(null);
|
541
|
+
this.pdfDocumentProperties.setDocument(null);
|
542
|
+
}
|
543
|
+
|
544
|
+
this.store = null;
|
545
|
+
this.isInitialViewSet = false;
|
546
|
+
this.downloadComplete = false;
|
547
|
+
this.url = "";
|
548
|
+
this.baseUrl = "";
|
549
|
+
this.contentDispositionFilename = null;
|
550
|
+
this.pdfSidebar.reset();
|
551
|
+
this.pdfOutlineViewer.reset();
|
552
|
+
this.pdfAttachmentViewer.reset();
|
553
|
+
|
554
|
+
if (this.pdfHistory) {
|
555
|
+
this.pdfHistory.reset();
|
556
|
+
}
|
557
|
+
|
558
|
+
if (this.findBar) {
|
559
|
+
this.findBar.reset();
|
560
|
+
}
|
561
|
+
|
562
|
+
this.toolbar.reset();
|
563
|
+
this.secondaryToolbar.reset();
|
564
|
+
|
565
|
+
if (typeof PDFBug !== "undefined") {
|
566
|
+
PDFBug.cleanup();
|
567
|
+
}
|
568
|
+
|
569
|
+
return promise;
|
570
|
+
},
|
571
|
+
|
572
|
+
async open(file, args) {
|
573
|
+
if (this.pdfLoadingTask) {
|
574
|
+
await this.close();
|
575
|
+
}
|
576
|
+
|
577
|
+
const workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
|
578
|
+
|
579
|
+
for (const key in workerParameters) {
|
580
|
+
_pdf.GlobalWorkerOptions[key] = workerParameters[key];
|
581
|
+
}
|
582
|
+
|
583
|
+
const parameters = Object.create(null);
|
584
|
+
|
585
|
+
if (typeof file === "string") {
|
586
|
+
this.setTitleUsingUrl(file);
|
587
|
+
parameters.url = file;
|
588
|
+
} else if (file && "byteLength" in file) {
|
589
|
+
parameters.data = file;
|
590
|
+
} else if (file.url && file.originalUrl) {
|
591
|
+
this.setTitleUsingUrl(file.originalUrl);
|
592
|
+
parameters.url = file.url;
|
593
|
+
}
|
594
|
+
|
595
|
+
const apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
|
596
|
+
|
597
|
+
for (const key in apiParameters) {
|
598
|
+
let value = apiParameters[key];
|
599
|
+
|
600
|
+
if (key === "docBaseUrl" && !value) {}
|
601
|
+
|
602
|
+
parameters[key] = value;
|
603
|
+
}
|
604
|
+
|
605
|
+
if (args) {
|
606
|
+
for (const key in args) {
|
607
|
+
const value = args[key];
|
608
|
+
|
609
|
+
if (key === "length") {
|
610
|
+
this.pdfDocumentProperties.setFileSize(value);
|
745
611
|
}
|
746
|
-
}, _callee7, this);
|
747
|
-
}));
|
748
612
|
|
749
|
-
|
750
|
-
|
613
|
+
parameters[key] = value;
|
614
|
+
}
|
751
615
|
}
|
752
616
|
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
617
|
+
const loadingTask = (0, _pdf.getDocument)(parameters);
|
618
|
+
this.pdfLoadingTask = loadingTask;
|
619
|
+
|
620
|
+
loadingTask.onPassword = (updateCallback, reason) => {
|
621
|
+
this.pdfLinkService.externalLinkEnabled = false;
|
622
|
+
this.passwordPrompt.setUpdateCallback(updateCallback, reason);
|
623
|
+
this.passwordPrompt.open();
|
624
|
+
};
|
625
|
+
|
626
|
+
loadingTask.onProgress = ({
|
627
|
+
loaded,
|
628
|
+
total
|
629
|
+
}) => {
|
630
|
+
this.progress(loaded / total);
|
631
|
+
};
|
632
|
+
|
633
|
+
loadingTask.onUnsupportedFeature = this.fallback.bind(this);
|
634
|
+
return loadingTask.promise.then(pdfDocument => {
|
635
|
+
this.load(pdfDocument);
|
636
|
+
}, exception => {
|
637
|
+
if (loadingTask !== this.pdfLoadingTask) {
|
638
|
+
return undefined;
|
639
|
+
}
|
640
|
+
|
641
|
+
const message = exception && exception.message;
|
642
|
+
let loadingErrorMessage;
|
643
|
+
|
644
|
+
if (exception instanceof _pdf.InvalidPDFException) {
|
645
|
+
loadingErrorMessage = this.l10n.get("invalid_file_error", null, "Invalid or corrupted PDF file.");
|
646
|
+
} else if (exception instanceof _pdf.MissingPDFException) {
|
647
|
+
loadingErrorMessage = this.l10n.get("missing_file_error", null, "Missing PDF file.");
|
648
|
+
} else if (exception instanceof _pdf.UnexpectedResponseException) {
|
649
|
+
loadingErrorMessage = this.l10n.get("unexpected_response_error", null, "Unexpected server response.");
|
650
|
+
} else {
|
651
|
+
loadingErrorMessage = this.l10n.get("loading_error", null, "An error occurred while loading the PDF.");
|
652
|
+
}
|
653
|
+
|
654
|
+
return loadingErrorMessage.then(msg => {
|
655
|
+
this.error(msg, {
|
656
|
+
message
|
657
|
+
});
|
658
|
+
throw new Error(msg);
|
659
|
+
});
|
660
|
+
});
|
661
|
+
},
|
757
662
|
|
663
|
+
download() {
|
758
664
|
function downloadByUrl() {
|
759
665
|
downloadManager.downloadUrl(url, filename);
|
760
666
|
}
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
downloadManager
|
765
|
-
|
667
|
+
|
668
|
+
const url = this.baseUrl;
|
669
|
+
const filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
|
670
|
+
const downloadManager = this.downloadManager;
|
671
|
+
|
672
|
+
downloadManager.onerror = err => {
|
673
|
+
this.error(`PDF failed to download: ${err}`);
|
766
674
|
};
|
675
|
+
|
767
676
|
if (!this.pdfDocument || !this.downloadComplete) {
|
768
677
|
downloadByUrl();
|
769
678
|
return;
|
770
679
|
}
|
680
|
+
|
771
681
|
this.pdfDocument.getData().then(function (data) {
|
772
|
-
|
682
|
+
const blob = new Blob([data], {
|
683
|
+
type: "application/pdf"
|
684
|
+
});
|
773
685
|
downloadManager.download(blob, url, filename);
|
774
686
|
}).catch(downloadByUrl);
|
775
687
|
},
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
688
|
+
|
689
|
+
fallback(featureId) {
|
690
|
+
if (this.fellback) {
|
691
|
+
return;
|
692
|
+
}
|
693
|
+
|
694
|
+
this.fellback = true;
|
695
|
+
this.externalServices.fallback({
|
696
|
+
featureId,
|
697
|
+
url: this.baseUrl
|
698
|
+
}, function response(download) {
|
699
|
+
if (!download) {
|
700
|
+
return;
|
701
|
+
}
|
702
|
+
|
703
|
+
PDFViewerApplication.download();
|
704
|
+
});
|
705
|
+
},
|
706
|
+
|
707
|
+
error(message, moreInfo) {
|
708
|
+
const moreInfoText = [this.l10n.get("error_version_info", {
|
709
|
+
version: _pdf.version || "?",
|
710
|
+
build: _pdf.build || "?"
|
711
|
+
}, "PDF.js v{{version}} (build: {{build}})")];
|
712
|
+
|
782
713
|
if (moreInfo) {
|
783
|
-
moreInfoText.push(this.l10n.get(
|
714
|
+
moreInfoText.push(this.l10n.get("error_message", {
|
715
|
+
message: moreInfo.message
|
716
|
+
}, "Message: {{message}}"));
|
717
|
+
|
784
718
|
if (moreInfo.stack) {
|
785
|
-
moreInfoText.push(this.l10n.get(
|
719
|
+
moreInfoText.push(this.l10n.get("error_stack", {
|
720
|
+
stack: moreInfo.stack
|
721
|
+
}, "Stack: {{stack}}"));
|
786
722
|
} else {
|
787
723
|
if (moreInfo.filename) {
|
788
|
-
moreInfoText.push(this.l10n.get(
|
724
|
+
moreInfoText.push(this.l10n.get("error_file", {
|
725
|
+
file: moreInfo.filename
|
726
|
+
}, "File: {{file}}"));
|
789
727
|
}
|
728
|
+
|
790
729
|
if (moreInfo.lineNumber) {
|
791
|
-
moreInfoText.push(this.l10n.get(
|
730
|
+
moreInfoText.push(this.l10n.get("error_line", {
|
731
|
+
line: moreInfo.lineNumber
|
732
|
+
}, "Line: {{line}}"));
|
792
733
|
}
|
793
734
|
}
|
794
735
|
}
|
795
|
-
|
796
|
-
|
797
|
-
errorWrapper.
|
798
|
-
|
736
|
+
|
737
|
+
const errorWrapperConfig = this.appConfig.errorWrapper;
|
738
|
+
const errorWrapper = errorWrapperConfig.container;
|
739
|
+
errorWrapper.removeAttribute("hidden");
|
740
|
+
const errorMessage = errorWrapperConfig.errorMessage;
|
799
741
|
errorMessage.textContent = message;
|
800
|
-
|
742
|
+
const closeButton = errorWrapperConfig.closeButton;
|
743
|
+
|
801
744
|
closeButton.onclick = function () {
|
802
|
-
errorWrapper.setAttribute(
|
745
|
+
errorWrapper.setAttribute("hidden", "true");
|
803
746
|
};
|
804
|
-
|
805
|
-
|
806
|
-
|
747
|
+
|
748
|
+
const errorMoreInfo = errorWrapperConfig.errorMoreInfo;
|
749
|
+
const moreInfoButton = errorWrapperConfig.moreInfoButton;
|
750
|
+
const lessInfoButton = errorWrapperConfig.lessInfoButton;
|
751
|
+
|
807
752
|
moreInfoButton.onclick = function () {
|
808
|
-
errorMoreInfo.removeAttribute(
|
809
|
-
moreInfoButton.setAttribute(
|
810
|
-
lessInfoButton.removeAttribute(
|
811
|
-
errorMoreInfo.style.height = errorMoreInfo.scrollHeight +
|
753
|
+
errorMoreInfo.removeAttribute("hidden");
|
754
|
+
moreInfoButton.setAttribute("hidden", "true");
|
755
|
+
lessInfoButton.removeAttribute("hidden");
|
756
|
+
errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
|
812
757
|
};
|
758
|
+
|
813
759
|
lessInfoButton.onclick = function () {
|
814
|
-
errorMoreInfo.setAttribute(
|
815
|
-
moreInfoButton.removeAttribute(
|
816
|
-
lessInfoButton.setAttribute(
|
760
|
+
errorMoreInfo.setAttribute("hidden", "true");
|
761
|
+
moreInfoButton.removeAttribute("hidden");
|
762
|
+
lessInfoButton.setAttribute("hidden", "true");
|
817
763
|
};
|
764
|
+
|
818
765
|
moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
|
819
766
|
lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
|
820
767
|
closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
|
821
|
-
moreInfoButton.removeAttribute(
|
822
|
-
lessInfoButton.setAttribute(
|
823
|
-
Promise.all(moreInfoText).then(
|
824
|
-
errorMoreInfo.value = parts.join(
|
768
|
+
moreInfoButton.removeAttribute("hidden");
|
769
|
+
lessInfoButton.setAttribute("hidden", "true");
|
770
|
+
Promise.all(moreInfoText).then(parts => {
|
771
|
+
errorMoreInfo.value = parts.join("\n");
|
825
772
|
});
|
826
773
|
},
|
827
|
-
progress: function progress(level) {
|
828
|
-
var _this4 = this;
|
829
774
|
|
775
|
+
progress(level) {
|
830
776
|
if (this.downloadComplete) {
|
831
777
|
return;
|
832
778
|
}
|
833
|
-
|
779
|
+
|
780
|
+
const percent = Math.round(level * 100);
|
781
|
+
|
834
782
|
if (percent > this.loadingBar.percent || isNaN(percent)) {
|
835
783
|
this.loadingBar.percent = percent;
|
836
|
-
|
784
|
+
const disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams["disableAutoFetch"] : _app_options.AppOptions.get("disableAutoFetch");
|
785
|
+
|
837
786
|
if (disableAutoFetch && percent) {
|
838
787
|
if (this.disableAutoFetchLoadingBarTimeout) {
|
839
788
|
clearTimeout(this.disableAutoFetchLoadingBarTimeout);
|
840
789
|
this.disableAutoFetchLoadingBarTimeout = null;
|
841
790
|
}
|
791
|
+
|
842
792
|
this.loadingBar.show();
|
843
|
-
this.disableAutoFetchLoadingBarTimeout = setTimeout(
|
844
|
-
|
845
|
-
|
793
|
+
this.disableAutoFetchLoadingBarTimeout = setTimeout(() => {
|
794
|
+
this.loadingBar.hide();
|
795
|
+
this.disableAutoFetchLoadingBarTimeout = null;
|
846
796
|
}, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
|
847
797
|
}
|
848
798
|
}
|
849
799
|
},
|
850
|
-
load: function load(pdfDocument) {
|
851
|
-
var _this5 = this;
|
852
800
|
|
801
|
+
load(pdfDocument) {
|
853
802
|
this.pdfDocument = pdfDocument;
|
854
|
-
pdfDocument.getDownloadInfo().then(
|
855
|
-
|
856
|
-
|
857
|
-
firstPagePromise.then(
|
858
|
-
|
859
|
-
|
803
|
+
pdfDocument.getDownloadInfo().then(() => {
|
804
|
+
this.downloadComplete = true;
|
805
|
+
this.loadingBar.hide();
|
806
|
+
firstPagePromise.then(() => {
|
807
|
+
this.eventBus.dispatch("documentloaded", {
|
808
|
+
source: this
|
809
|
+
});
|
860
810
|
});
|
861
811
|
});
|
862
|
-
|
812
|
+
const pageLayoutPromise = pdfDocument.getPageLayout().catch(function () {});
|
813
|
+
const pageModePromise = pdfDocument.getPageMode().catch(function () {});
|
814
|
+
const openActionPromise = pdfDocument.getOpenAction().catch(function () {});
|
863
815
|
this.toolbar.setPagesCount(pdfDocument.numPages, false);
|
864
816
|
this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
|
865
|
-
|
866
|
-
|
817
|
+
const store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
|
818
|
+
let baseDocumentUrl;
|
867
819
|
baseDocumentUrl = null;
|
868
820
|
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
|
869
821
|
this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
|
870
|
-
|
822
|
+
const pdfViewer = this.pdfViewer;
|
871
823
|
pdfViewer.setDocument(pdfDocument);
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
824
|
+
const {
|
825
|
+
firstPagePromise,
|
826
|
+
onePageRendered,
|
827
|
+
pagesPromise
|
828
|
+
} = pdfViewer;
|
829
|
+
const pdfThumbnailViewer = this.pdfThumbnailViewer;
|
876
830
|
pdfThumbnailViewer.setDocument(pdfDocument);
|
877
|
-
firstPagePromise.then(
|
878
|
-
|
879
|
-
|
880
|
-
var resetHistory = !_app_options.AppOptions.get('showPreviousViewOnLoad');
|
881
|
-
_this5.pdfHistory.initialize(pdfDocument.fingerprint, resetHistory);
|
882
|
-
if (_this5.pdfHistory.initialBookmark) {
|
883
|
-
_this5.initialBookmark = _this5.pdfHistory.initialBookmark;
|
884
|
-
_this5.initialRotation = _this5.pdfHistory.initialRotation;
|
885
|
-
}
|
886
|
-
}
|
887
|
-
var storePromise = store.getMultiple({
|
831
|
+
firstPagePromise.then(pdfPage => {
|
832
|
+
this.loadingBar.setWidth(this.appConfig.viewerContainer);
|
833
|
+
const storePromise = store.getMultiple({
|
888
834
|
page: null,
|
889
835
|
zoom: _ui_utils.DEFAULT_SCALE_VALUE,
|
890
|
-
scrollLeft:
|
891
|
-
scrollTop:
|
836
|
+
scrollLeft: "0",
|
837
|
+
scrollTop: "0",
|
892
838
|
rotation: null,
|
893
|
-
sidebarView: _pdf_sidebar.SidebarView.
|
894
|
-
scrollMode:
|
895
|
-
spreadMode:
|
896
|
-
}).catch(
|
897
|
-
Promise.all([storePromise, pageModePromise]).then(
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
return _regenerator2.default.wrap(function _callee8$(_context8) {
|
906
|
-
while (1) {
|
907
|
-
switch (_context8.prev = _context8.next) {
|
908
|
-
case 0:
|
909
|
-
initialBookmark = _this5.initialBookmark;
|
910
|
-
zoom = _app_options.AppOptions.get('defaultZoomValue');
|
911
|
-
hash = zoom ? 'zoom=' + zoom : null;
|
912
|
-
rotation = null;
|
913
|
-
sidebarView = _app_options.AppOptions.get('sidebarViewOnLoad');
|
914
|
-
scrollMode = _app_options.AppOptions.get('scrollModeOnLoad');
|
915
|
-
spreadMode = _app_options.AppOptions.get('spreadModeOnLoad');
|
916
|
-
|
917
|
-
if (values.page && _app_options.AppOptions.get('showPreviousViewOnLoad')) {
|
918
|
-
hash = 'page=' + values.page + '&zoom=' + (zoom || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop;
|
919
|
-
rotation = parseInt(values.rotation, 10);
|
920
|
-
sidebarView = sidebarView || values.sidebarView | 0;
|
921
|
-
scrollMode = scrollMode || values.scrollMode | 0;
|
922
|
-
spreadMode = spreadMode || values.spreadMode | 0;
|
923
|
-
}
|
924
|
-
if (pageMode && !_app_options.AppOptions.get('disablePageMode')) {
|
925
|
-
sidebarView = sidebarView || apiPageModeToSidebarView(pageMode);
|
926
|
-
}
|
927
|
-
_this5.setInitialView(hash, {
|
928
|
-
rotation: rotation,
|
929
|
-
sidebarView: sidebarView,
|
930
|
-
scrollMode: scrollMode,
|
931
|
-
spreadMode: spreadMode
|
932
|
-
});
|
933
|
-
_this5.eventBus.dispatch('documentinit', { source: _this5 });
|
934
|
-
if (!_this5.isViewerEmbedded) {
|
935
|
-
pdfViewer.focus();
|
936
|
-
}
|
937
|
-
_context8.next = 14;
|
938
|
-
return Promise.race([pagesPromise, new Promise(function (resolve) {
|
939
|
-
setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
|
940
|
-
})]);
|
941
|
-
|
942
|
-
case 14:
|
943
|
-
if (!(!initialBookmark && !hash)) {
|
944
|
-
_context8.next = 16;
|
945
|
-
break;
|
946
|
-
}
|
947
|
-
|
948
|
-
return _context8.abrupt('return');
|
949
|
-
|
950
|
-
case 16:
|
951
|
-
if (!pdfViewer.hasEqualPageSizes) {
|
952
|
-
_context8.next = 18;
|
953
|
-
break;
|
954
|
-
}
|
955
|
-
|
956
|
-
return _context8.abrupt('return');
|
957
|
-
|
958
|
-
case 18:
|
959
|
-
_this5.initialBookmark = initialBookmark;
|
960
|
-
pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
|
961
|
-
_this5.setInitialView(hash);
|
962
|
-
|
963
|
-
case 21:
|
964
|
-
case 'end':
|
965
|
-
return _context8.stop();
|
966
|
-
}
|
967
|
-
}
|
968
|
-
}, _callee8, _this5);
|
969
|
-
}));
|
839
|
+
sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
|
840
|
+
scrollMode: _ui_utils.ScrollMode.UNKNOWN,
|
841
|
+
spreadMode: _ui_utils.SpreadMode.UNKNOWN
|
842
|
+
}).catch(() => {});
|
843
|
+
Promise.all([_ui_utils.animationStarted, storePromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async ([timeStamp, values = {}, pageLayout, pageMode, openAction]) => {
|
844
|
+
const viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
|
845
|
+
|
846
|
+
this._initializePdfHistory({
|
847
|
+
fingerprint: pdfDocument.fingerprint,
|
848
|
+
viewOnLoad,
|
849
|
+
initialDest: openAction && openAction.dest
|
850
|
+
});
|
970
851
|
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
852
|
+
const initialBookmark = this.initialBookmark;
|
853
|
+
|
854
|
+
const zoom = _app_options.AppOptions.get("defaultZoomValue");
|
855
|
+
|
856
|
+
let hash = zoom ? `zoom=${zoom}` : null;
|
857
|
+
let rotation = null;
|
858
|
+
|
859
|
+
let sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
|
860
|
+
|
861
|
+
let scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
|
862
|
+
|
863
|
+
let spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
|
864
|
+
|
865
|
+
if (values.page && viewOnLoad !== ViewOnLoad.INITIAL) {
|
866
|
+
hash = `page=${values.page}&zoom=${zoom || values.zoom},` + `${values.scrollLeft},${values.scrollTop}`;
|
867
|
+
rotation = parseInt(values.rotation, 10);
|
868
|
+
|
869
|
+
if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
|
870
|
+
sidebarView = values.sidebarView | 0;
|
871
|
+
}
|
872
|
+
|
873
|
+
if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
|
874
|
+
scrollMode = values.scrollMode | 0;
|
875
|
+
}
|
876
|
+
|
877
|
+
if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
|
878
|
+
spreadMode = values.spreadMode | 0;
|
879
|
+
}
|
880
|
+
}
|
881
|
+
|
882
|
+
if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
|
883
|
+
sidebarView = apiPageModeToSidebarView(pageMode);
|
884
|
+
}
|
885
|
+
|
886
|
+
if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
|
887
|
+
spreadMode = apiPageLayoutToSpreadMode(pageLayout);
|
888
|
+
}
|
889
|
+
|
890
|
+
this.setInitialView(hash, {
|
891
|
+
rotation,
|
892
|
+
sidebarView,
|
893
|
+
scrollMode,
|
894
|
+
spreadMode
|
895
|
+
});
|
896
|
+
this.eventBus.dispatch("documentinit", {
|
897
|
+
source: this
|
898
|
+
});
|
899
|
+
|
900
|
+
if (!this.isViewerEmbedded) {
|
901
|
+
pdfViewer.focus();
|
902
|
+
}
|
903
|
+
|
904
|
+
await Promise.race([pagesPromise, new Promise(resolve => {
|
905
|
+
setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
|
906
|
+
})]);
|
907
|
+
|
908
|
+
if (!initialBookmark && !hash) {
|
909
|
+
return;
|
910
|
+
}
|
911
|
+
|
912
|
+
if (pdfViewer.hasEqualPageSizes) {
|
913
|
+
return;
|
914
|
+
}
|
915
|
+
|
916
|
+
this.initialBookmark = initialBookmark;
|
917
|
+
pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
|
918
|
+
this.setInitialView(hash);
|
919
|
+
}).catch(() => {
|
920
|
+
this.setInitialView();
|
921
|
+
}).then(function () {
|
975
922
|
pdfViewer.update();
|
976
923
|
});
|
977
924
|
});
|
978
|
-
pdfDocument.getPageLabels().then(
|
979
|
-
if (!labels || _app_options.AppOptions.get(
|
925
|
+
pdfDocument.getPageLabels().then(labels => {
|
926
|
+
if (!labels || _app_options.AppOptions.get("disablePageLabels")) {
|
980
927
|
return;
|
981
928
|
}
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
929
|
+
|
930
|
+
const numLabels = labels.length;
|
931
|
+
|
932
|
+
if (numLabels !== this.pagesCount) {
|
933
|
+
console.error("The number of Page Labels does not match " + "the number of pages in the document.");
|
986
934
|
return;
|
987
935
|
}
|
936
|
+
|
937
|
+
let i = 0;
|
938
|
+
|
988
939
|
while (i < numLabels && labels[i] === (i + 1).toString()) {
|
989
940
|
i++;
|
990
941
|
}
|
942
|
+
|
991
943
|
if (i === numLabels) {
|
992
944
|
return;
|
993
945
|
}
|
946
|
+
|
994
947
|
pdfViewer.setPageLabels(labels);
|
995
948
|
pdfThumbnailViewer.setPageLabels(labels);
|
996
|
-
|
997
|
-
|
949
|
+
this.toolbar.setPagesCount(pdfDocument.numPages, true);
|
950
|
+
this.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
|
998
951
|
});
|
999
|
-
pagesPromise.then(
|
1000
|
-
|
1001
|
-
|
952
|
+
pagesPromise.then(async () => {
|
953
|
+
const [openAction, javaScript] = await Promise.all([openActionPromise, pdfDocument.getJavaScript()]);
|
954
|
+
let triggerAutoPrint = false;
|
955
|
+
|
956
|
+
if (openAction && openAction.action === "Print") {
|
957
|
+
triggerAutoPrint = true;
|
1002
958
|
}
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
}
|
1007
|
-
javaScript.some(function (js) {
|
959
|
+
|
960
|
+
if (javaScript) {
|
961
|
+
javaScript.some(js => {
|
1008
962
|
if (!js) {
|
1009
963
|
return false;
|
1010
964
|
}
|
1011
|
-
|
1012
|
-
|
965
|
+
|
966
|
+
console.warn("Warning: JavaScript is not supported");
|
967
|
+
this.fallback(_pdf.UNSUPPORTED_FEATURES.javaScript);
|
1013
968
|
return true;
|
1014
969
|
});
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
}
|
1022
|
-
return;
|
970
|
+
|
971
|
+
if (!triggerAutoPrint) {
|
972
|
+
for (const js of javaScript) {
|
973
|
+
if (js && _ui_utils.AutoPrintRegExp.test(js)) {
|
974
|
+
triggerAutoPrint = true;
|
975
|
+
break;
|
976
|
+
}
|
1023
977
|
}
|
1024
978
|
}
|
1025
|
-
}
|
979
|
+
}
|
980
|
+
|
981
|
+
if (!this.supportsPrinting) {
|
982
|
+
return;
|
983
|
+
}
|
984
|
+
|
985
|
+
if (triggerAutoPrint) {
|
986
|
+
setTimeout(function () {
|
987
|
+
window.print();
|
988
|
+
});
|
989
|
+
}
|
1026
990
|
});
|
1027
|
-
|
1028
|
-
pdfDocument.getOutline().then(
|
1029
|
-
|
991
|
+
onePageRendered.then(() => {
|
992
|
+
pdfDocument.getOutline().then(outline => {
|
993
|
+
this.pdfOutlineViewer.render({
|
994
|
+
outline
|
995
|
+
});
|
1030
996
|
});
|
1031
|
-
pdfDocument.getAttachments().then(
|
1032
|
-
|
997
|
+
pdfDocument.getAttachments().then(attachments => {
|
998
|
+
this.pdfAttachmentViewer.render({
|
999
|
+
attachments
|
1000
|
+
});
|
1033
1001
|
});
|
1034
1002
|
});
|
1035
|
-
pdfDocument.getMetadata().then(
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
console.log(
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
}
|
1003
|
+
pdfDocument.getMetadata().then(({
|
1004
|
+
info,
|
1005
|
+
metadata,
|
1006
|
+
contentDispositionFilename
|
1007
|
+
}) => {
|
1008
|
+
this.documentInfo = info;
|
1009
|
+
this.metadata = metadata;
|
1010
|
+
this.contentDispositionFilename = contentDispositionFilename;
|
1011
|
+
console.log("PDF " + pdfDocument.fingerprint + " [" + info.PDFFormatVersion + " " + (info.Producer || "-").trim() + " / " + (info.Creator || "-").trim() + "]" + " (PDF.js: " + (_pdf.version || "-") + (_app_options.AppOptions.get("enableWebGL") ? " [WebGL]" : "") + ")");
|
1012
|
+
let pdfTitle;
|
1013
|
+
const infoTitle = info && info["Title"];
|
1014
|
+
|
1015
|
+
if (infoTitle) {
|
1016
|
+
pdfTitle = infoTitle;
|
1050
1017
|
}
|
1051
|
-
|
1052
|
-
|
1018
|
+
|
1019
|
+
const metadataTitle = metadata && metadata.get("dc:title");
|
1020
|
+
|
1021
|
+
if (metadataTitle) {
|
1022
|
+
if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
|
1023
|
+
pdfTitle = metadataTitle;
|
1024
|
+
}
|
1053
1025
|
}
|
1026
|
+
|
1054
1027
|
if (pdfTitle) {
|
1055
|
-
|
1028
|
+
this.setTitle(`${pdfTitle} - ${contentDispositionFilename || document.title}`);
|
1056
1029
|
} else if (contentDispositionFilename) {
|
1057
|
-
|
1030
|
+
this.setTitle(contentDispositionFilename);
|
1031
|
+
}
|
1032
|
+
|
1033
|
+
if (info.IsAcroFormPresent) {
|
1034
|
+
console.warn("Warning: AcroForm/XFA is not supported");
|
1035
|
+
this.fallback(_pdf.UNSUPPORTED_FEATURES.forms);
|
1036
|
+
}
|
1037
|
+
|
1038
|
+
let versionId = "other";
|
1039
|
+
const KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2.0", "2.1", "2.2", "2.3"];
|
1040
|
+
|
1041
|
+
if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
|
1042
|
+
versionId = `v${info.PDFFormatVersion.replace(".", "_")}`;
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
let generatorId = "other";
|
1046
|
+
const KNOWN_GENERATORS = ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle", "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm", "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x", "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house", "aspose.cells", "fpdf"];
|
1047
|
+
|
1048
|
+
if (info.Producer) {
|
1049
|
+
const producer = info.Producer.toLowerCase();
|
1050
|
+
KNOWN_GENERATORS.some(function (generator) {
|
1051
|
+
if (!producer.includes(generator)) {
|
1052
|
+
return false;
|
1053
|
+
}
|
1054
|
+
|
1055
|
+
generatorId = generator.replace(/[ .\-]/g, "_");
|
1056
|
+
return true;
|
1057
|
+
});
|
1058
1058
|
}
|
1059
|
+
|
1060
|
+
let formType = null;
|
1061
|
+
|
1059
1062
|
if (info.IsAcroFormPresent) {
|
1060
|
-
|
1061
|
-
_this5.fallback(_pdf.UNSUPPORTED_FEATURES.forms);
|
1063
|
+
formType = info.IsXFAPresent ? "xfa" : "acroform";
|
1062
1064
|
}
|
1065
|
+
|
1066
|
+
this.externalServices.reportTelemetry({
|
1067
|
+
type: "documentInfo",
|
1068
|
+
version: versionId,
|
1069
|
+
generator: generatorId,
|
1070
|
+
formType
|
1071
|
+
});
|
1063
1072
|
});
|
1064
1073
|
},
|
1065
|
-
setInitialView: function setInitialView(storedHash) {
|
1066
|
-
var _this6 = this;
|
1067
1074
|
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1075
|
+
_initializePdfHistory({
|
1076
|
+
fingerprint,
|
1077
|
+
viewOnLoad,
|
1078
|
+
initialDest = null
|
1079
|
+
}) {
|
1080
|
+
if (_app_options.AppOptions.get("disableHistory") || this.isViewerEmbedded) {
|
1081
|
+
return;
|
1082
|
+
}
|
1083
|
+
|
1084
|
+
this.pdfHistory.initialize({
|
1085
|
+
fingerprint,
|
1086
|
+
resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
|
1087
|
+
updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
|
1088
|
+
});
|
1089
|
+
|
1090
|
+
if (this.pdfHistory.initialBookmark) {
|
1091
|
+
this.initialBookmark = this.pdfHistory.initialBookmark;
|
1092
|
+
this.initialRotation = this.pdfHistory.initialRotation;
|
1093
|
+
}
|
1073
1094
|
|
1074
|
-
|
1095
|
+
if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
|
1096
|
+
this.initialBookmark = JSON.stringify(initialDest);
|
1097
|
+
this.pdfHistory.push({
|
1098
|
+
explicitDest: initialDest,
|
1099
|
+
pageNumber: null
|
1100
|
+
});
|
1101
|
+
}
|
1102
|
+
},
|
1103
|
+
|
1104
|
+
setInitialView(storedHash, {
|
1105
|
+
rotation,
|
1106
|
+
sidebarView,
|
1107
|
+
scrollMode,
|
1108
|
+
spreadMode
|
1109
|
+
} = {}) {
|
1110
|
+
const setRotation = angle => {
|
1075
1111
|
if ((0, _ui_utils.isValidRotation)(angle)) {
|
1076
|
-
|
1112
|
+
this.pdfViewer.pagesRotation = angle;
|
1077
1113
|
}
|
1078
1114
|
};
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1115
|
+
|
1116
|
+
const setViewerModes = (scroll, spread) => {
|
1117
|
+
if ((0, _ui_utils.isValidScrollMode)(scroll)) {
|
1118
|
+
this.pdfViewer.scrollMode = scroll;
|
1082
1119
|
}
|
1083
|
-
|
1084
|
-
|
1120
|
+
|
1121
|
+
if ((0, _ui_utils.isValidSpreadMode)(spread)) {
|
1122
|
+
this.pdfViewer.spreadMode = spread;
|
1085
1123
|
}
|
1086
1124
|
};
|
1087
|
-
|
1125
|
+
|
1088
1126
|
this.isInitialViewSet = true;
|
1089
1127
|
this.pdfSidebar.setInitialView(sidebarView);
|
1128
|
+
setViewerModes(scrollMode, spreadMode);
|
1129
|
+
|
1090
1130
|
if (this.initialBookmark) {
|
1091
1131
|
setRotation(this.initialRotation);
|
1092
1132
|
delete this.initialRotation;
|
@@ -1096,567 +1136,801 @@ var PDFViewerApplication = {
|
|
1096
1136
|
setRotation(rotation);
|
1097
1137
|
this.pdfLinkService.setHash(storedHash);
|
1098
1138
|
}
|
1139
|
+
|
1099
1140
|
this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
|
1100
1141
|
this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
|
1142
|
+
|
1101
1143
|
if (!this.pdfViewer.currentScaleValue) {
|
1102
1144
|
this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
|
1103
1145
|
}
|
1104
1146
|
},
|
1105
|
-
|
1147
|
+
|
1148
|
+
cleanup() {
|
1106
1149
|
if (!this.pdfDocument) {
|
1107
1150
|
return;
|
1108
1151
|
}
|
1152
|
+
|
1109
1153
|
this.pdfViewer.cleanup();
|
1110
1154
|
this.pdfThumbnailViewer.cleanup();
|
1155
|
+
|
1111
1156
|
if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
|
1112
1157
|
this.pdfDocument.cleanup();
|
1113
1158
|
}
|
1114
1159
|
},
|
1115
|
-
|
1160
|
+
|
1161
|
+
forceRendering() {
|
1116
1162
|
this.pdfRenderingQueue.printing = this.printing;
|
1117
1163
|
this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
|
1118
1164
|
this.pdfRenderingQueue.renderHighestPriority();
|
1119
1165
|
},
|
1120
|
-
beforePrint: function beforePrint() {
|
1121
|
-
var _this7 = this;
|
1122
1166
|
|
1167
|
+
beforePrint() {
|
1123
1168
|
if (this.printService) {
|
1124
1169
|
return;
|
1125
1170
|
}
|
1171
|
+
|
1126
1172
|
if (!this.supportsPrinting) {
|
1127
|
-
this.l10n.get(
|
1128
|
-
|
1173
|
+
this.l10n.get("printing_not_supported", null, "Warning: Printing is not fully supported by this browser.").then(printMessage => {
|
1174
|
+
this.error(printMessage);
|
1129
1175
|
});
|
1130
1176
|
return;
|
1131
1177
|
}
|
1178
|
+
|
1132
1179
|
if (!this.pdfViewer.pageViewsReady) {
|
1133
|
-
this.l10n.get(
|
1180
|
+
this.l10n.get("printing_not_ready", null, "Warning: The PDF is not fully loaded for printing.").then(notReadyMessage => {
|
1134
1181
|
window.alert(notReadyMessage);
|
1135
1182
|
});
|
1136
1183
|
return;
|
1137
1184
|
}
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1185
|
+
|
1186
|
+
const pagesOverview = this.pdfViewer.getPagesOverview();
|
1187
|
+
const printContainer = this.appConfig.printContainer;
|
1188
|
+
const printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
|
1141
1189
|
this.printService = printService;
|
1142
1190
|
this.forceRendering();
|
1143
1191
|
printService.layout();
|
1192
|
+
this.externalServices.reportTelemetry({
|
1193
|
+
type: "print"
|
1194
|
+
});
|
1195
|
+
},
|
1196
|
+
|
1197
|
+
afterPrint() {
|
1198
|
+
if (this.printService) {
|
1199
|
+
this.printService.destroy();
|
1200
|
+
this.printService = null;
|
1201
|
+
}
|
1202
|
+
|
1203
|
+
this.forceRendering();
|
1204
|
+
},
|
1205
|
+
|
1206
|
+
rotatePages(delta) {
|
1207
|
+
if (!this.pdfDocument) {
|
1208
|
+
return;
|
1209
|
+
}
|
1210
|
+
|
1211
|
+
const newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
|
1212
|
+
this.pdfViewer.pagesRotation = newRotation;
|
1213
|
+
},
|
1214
|
+
|
1215
|
+
requestPresentationMode() {
|
1216
|
+
if (!this.pdfPresentationMode) {
|
1217
|
+
return;
|
1218
|
+
}
|
1219
|
+
|
1220
|
+
this.pdfPresentationMode.request();
|
1221
|
+
},
|
1222
|
+
|
1223
|
+
bindEvents() {
|
1224
|
+
const {
|
1225
|
+
eventBus,
|
1226
|
+
_boundEvents
|
1227
|
+
} = this;
|
1228
|
+
_boundEvents.beforePrint = this.beforePrint.bind(this);
|
1229
|
+
_boundEvents.afterPrint = this.afterPrint.bind(this);
|
1230
|
+
|
1231
|
+
eventBus._on("resize", webViewerResize);
|
1232
|
+
|
1233
|
+
eventBus._on("hashchange", webViewerHashchange);
|
1234
|
+
|
1235
|
+
eventBus._on("beforeprint", _boundEvents.beforePrint);
|
1236
|
+
|
1237
|
+
eventBus._on("afterprint", _boundEvents.afterPrint);
|
1238
|
+
|
1239
|
+
eventBus._on("pagerendered", webViewerPageRendered);
|
1240
|
+
|
1241
|
+
eventBus._on("updateviewarea", webViewerUpdateViewarea);
|
1242
|
+
|
1243
|
+
eventBus._on("pagechanging", webViewerPageChanging);
|
1244
|
+
|
1245
|
+
eventBus._on("scalechanging", webViewerScaleChanging);
|
1246
|
+
|
1247
|
+
eventBus._on("rotationchanging", webViewerRotationChanging);
|
1248
|
+
|
1249
|
+
eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
|
1250
|
+
|
1251
|
+
eventBus._on("pagemode", webViewerPageMode);
|
1252
|
+
|
1253
|
+
eventBus._on("namedaction", webViewerNamedAction);
|
1254
|
+
|
1255
|
+
eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
|
1256
|
+
|
1257
|
+
eventBus._on("presentationmode", webViewerPresentationMode);
|
1258
|
+
|
1259
|
+
eventBus._on("print", webViewerPrint);
|
1260
|
+
|
1261
|
+
eventBus._on("download", webViewerDownload);
|
1262
|
+
|
1263
|
+
eventBus._on("firstpage", webViewerFirstPage);
|
1264
|
+
|
1265
|
+
eventBus._on("lastpage", webViewerLastPage);
|
1266
|
+
|
1267
|
+
eventBus._on("nextpage", webViewerNextPage);
|
1268
|
+
|
1269
|
+
eventBus._on("previouspage", webViewerPreviousPage);
|
1270
|
+
|
1271
|
+
eventBus._on("zoomin", webViewerZoomIn);
|
1272
|
+
|
1273
|
+
eventBus._on("zoomout", webViewerZoomOut);
|
1274
|
+
|
1275
|
+
eventBus._on("zoomreset", webViewerZoomReset);
|
1276
|
+
|
1277
|
+
eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
|
1278
|
+
|
1279
|
+
eventBus._on("scalechanged", webViewerScaleChanged);
|
1280
|
+
|
1281
|
+
eventBus._on("rotatecw", webViewerRotateCw);
|
1282
|
+
|
1283
|
+
eventBus._on("rotateccw", webViewerRotateCcw);
|
1284
|
+
|
1285
|
+
eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
|
1286
|
+
|
1287
|
+
eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
|
1288
|
+
|
1289
|
+
eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
|
1290
|
+
|
1291
|
+
eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
|
1292
|
+
|
1293
|
+
eventBus._on("documentproperties", webViewerDocumentProperties);
|
1294
|
+
|
1295
|
+
eventBus._on("find", webViewerFind);
|
1296
|
+
|
1297
|
+
eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
|
1298
|
+
|
1299
|
+
eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
|
1300
|
+
|
1301
|
+
eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
|
1302
|
+
|
1303
|
+
eventBus._on("fileinputchange", webViewerFileInputChange);
|
1304
|
+
|
1305
|
+
eventBus._on("openfile", webViewerOpenFile);
|
1306
|
+
},
|
1307
|
+
|
1308
|
+
bindWindowEvents() {
|
1309
|
+
const {
|
1310
|
+
eventBus,
|
1311
|
+
_boundEvents
|
1312
|
+
} = this;
|
1313
|
+
|
1314
|
+
_boundEvents.windowResize = () => {
|
1315
|
+
eventBus.dispatch("resize", {
|
1316
|
+
source: window
|
1317
|
+
});
|
1318
|
+
};
|
1319
|
+
|
1320
|
+
_boundEvents.windowHashChange = () => {
|
1321
|
+
eventBus.dispatch("hashchange", {
|
1322
|
+
source: window,
|
1323
|
+
hash: document.location.hash.substring(1)
|
1324
|
+
});
|
1325
|
+
};
|
1326
|
+
|
1327
|
+
_boundEvents.windowBeforePrint = () => {
|
1328
|
+
eventBus.dispatch("beforeprint", {
|
1329
|
+
source: window
|
1330
|
+
});
|
1331
|
+
};
|
1332
|
+
|
1333
|
+
_boundEvents.windowAfterPrint = () => {
|
1334
|
+
eventBus.dispatch("afterprint", {
|
1335
|
+
source: window
|
1336
|
+
});
|
1337
|
+
};
|
1338
|
+
|
1339
|
+
window.addEventListener("visibilitychange", webViewerVisibilityChange);
|
1340
|
+
window.addEventListener("wheel", webViewerWheel, {
|
1341
|
+
passive: false
|
1342
|
+
});
|
1343
|
+
window.addEventListener("click", webViewerClick);
|
1344
|
+
window.addEventListener("keydown", webViewerKeyDown);
|
1345
|
+
window.addEventListener("resize", _boundEvents.windowResize);
|
1346
|
+
window.addEventListener("hashchange", _boundEvents.windowHashChange);
|
1347
|
+
window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
|
1348
|
+
window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
|
1144
1349
|
},
|
1145
1350
|
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
}
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1351
|
+
unbindEvents() {
|
1352
|
+
const {
|
1353
|
+
eventBus,
|
1354
|
+
_boundEvents
|
1355
|
+
} = this;
|
1356
|
+
|
1357
|
+
eventBus._off("resize", webViewerResize);
|
1358
|
+
|
1359
|
+
eventBus._off("hashchange", webViewerHashchange);
|
1360
|
+
|
1361
|
+
eventBus._off("beforeprint", _boundEvents.beforePrint);
|
1362
|
+
|
1363
|
+
eventBus._off("afterprint", _boundEvents.afterPrint);
|
1364
|
+
|
1365
|
+
eventBus._off("pagerendered", webViewerPageRendered);
|
1366
|
+
|
1367
|
+
eventBus._off("updateviewarea", webViewerUpdateViewarea);
|
1368
|
+
|
1369
|
+
eventBus._off("pagechanging", webViewerPageChanging);
|
1370
|
+
|
1371
|
+
eventBus._off("scalechanging", webViewerScaleChanging);
|
1372
|
+
|
1373
|
+
eventBus._off("rotationchanging", webViewerRotationChanging);
|
1374
|
+
|
1375
|
+
eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
|
1376
|
+
|
1377
|
+
eventBus._off("pagemode", webViewerPageMode);
|
1378
|
+
|
1379
|
+
eventBus._off("namedaction", webViewerNamedAction);
|
1380
|
+
|
1381
|
+
eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
|
1382
|
+
|
1383
|
+
eventBus._off("presentationmode", webViewerPresentationMode);
|
1384
|
+
|
1385
|
+
eventBus._off("print", webViewerPrint);
|
1386
|
+
|
1387
|
+
eventBus._off("download", webViewerDownload);
|
1388
|
+
|
1389
|
+
eventBus._off("firstpage", webViewerFirstPage);
|
1390
|
+
|
1391
|
+
eventBus._off("lastpage", webViewerLastPage);
|
1392
|
+
|
1393
|
+
eventBus._off("nextpage", webViewerNextPage);
|
1394
|
+
|
1395
|
+
eventBus._off("previouspage", webViewerPreviousPage);
|
1396
|
+
|
1397
|
+
eventBus._off("zoomin", webViewerZoomIn);
|
1398
|
+
|
1399
|
+
eventBus._off("zoomout", webViewerZoomOut);
|
1169
1400
|
|
1170
|
-
|
1171
|
-
|
1172
|
-
eventBus.
|
1173
|
-
|
1174
|
-
eventBus.
|
1175
|
-
|
1176
|
-
eventBus.
|
1177
|
-
|
1178
|
-
eventBus.
|
1179
|
-
|
1180
|
-
eventBus.
|
1181
|
-
|
1182
|
-
eventBus.
|
1183
|
-
|
1184
|
-
eventBus.
|
1185
|
-
|
1186
|
-
eventBus.
|
1187
|
-
|
1188
|
-
eventBus.
|
1189
|
-
|
1190
|
-
eventBus.
|
1191
|
-
|
1192
|
-
eventBus.
|
1193
|
-
|
1194
|
-
eventBus.
|
1195
|
-
|
1196
|
-
eventBus.
|
1197
|
-
|
1198
|
-
eventBus.
|
1199
|
-
|
1200
|
-
eventBus.
|
1201
|
-
eventBus.on('scrollmodechanged', webViewerScrollModeChanged);
|
1202
|
-
eventBus.on('switchspreadmode', webViewerSwitchSpreadMode);
|
1203
|
-
eventBus.on('spreadmodechanged', webViewerSpreadModeChanged);
|
1204
|
-
eventBus.on('documentproperties', webViewerDocumentProperties);
|
1205
|
-
eventBus.on('find', webViewerFind);
|
1206
|
-
eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
|
1207
|
-
eventBus.on('updatefindmatchescount', webViewerUpdateFindMatchesCount);
|
1208
|
-
eventBus.on('updatefindcontrolstate', webViewerUpdateFindControlState);
|
1209
|
-
eventBus.on('fileinputchange', webViewerFileInputChange);
|
1210
|
-
},
|
1211
|
-
bindWindowEvents: function bindWindowEvents() {
|
1212
|
-
var eventBus = this.eventBus,
|
1213
|
-
_boundEvents = this._boundEvents;
|
1401
|
+
eventBus._off("zoomreset", webViewerZoomReset);
|
1402
|
+
|
1403
|
+
eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
|
1404
|
+
|
1405
|
+
eventBus._off("scalechanged", webViewerScaleChanged);
|
1406
|
+
|
1407
|
+
eventBus._off("rotatecw", webViewerRotateCw);
|
1408
|
+
|
1409
|
+
eventBus._off("rotateccw", webViewerRotateCcw);
|
1410
|
+
|
1411
|
+
eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
|
1412
|
+
|
1413
|
+
eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
|
1414
|
+
|
1415
|
+
eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
|
1416
|
+
|
1417
|
+
eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
|
1418
|
+
|
1419
|
+
eventBus._off("documentproperties", webViewerDocumentProperties);
|
1420
|
+
|
1421
|
+
eventBus._off("find", webViewerFind);
|
1422
|
+
|
1423
|
+
eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
|
1424
|
+
|
1425
|
+
eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
|
1426
|
+
|
1427
|
+
eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
|
1428
|
+
|
1429
|
+
eventBus._off("fileinputchange", webViewerFileInputChange);
|
1430
|
+
|
1431
|
+
eventBus._off("openfile", webViewerOpenFile);
|
1214
1432
|
|
1215
|
-
_boundEvents.windowResize = function () {
|
1216
|
-
eventBus.dispatch('resize', { source: window });
|
1217
|
-
};
|
1218
|
-
_boundEvents.windowHashChange = function () {
|
1219
|
-
eventBus.dispatch('hashchange', {
|
1220
|
-
source: window,
|
1221
|
-
hash: document.location.hash.substring(1)
|
1222
|
-
});
|
1223
|
-
};
|
1224
|
-
_boundEvents.windowBeforePrint = function () {
|
1225
|
-
eventBus.dispatch('beforeprint', { source: window });
|
1226
|
-
};
|
1227
|
-
_boundEvents.windowAfterPrint = function () {
|
1228
|
-
eventBus.dispatch('afterprint', { source: window });
|
1229
|
-
};
|
1230
|
-
window.addEventListener('wheel', webViewerWheel);
|
1231
|
-
window.addEventListener('click', webViewerClick);
|
1232
|
-
window.addEventListener('keydown', webViewerKeyDown);
|
1233
|
-
window.addEventListener('resize', _boundEvents.windowResize);
|
1234
|
-
window.addEventListener('hashchange', _boundEvents.windowHashChange);
|
1235
|
-
window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
|
1236
|
-
window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
|
1237
|
-
},
|
1238
|
-
unbindEvents: function unbindEvents() {
|
1239
|
-
var eventBus = this.eventBus,
|
1240
|
-
_boundEvents = this._boundEvents;
|
1241
|
-
|
1242
|
-
eventBus.off('resize', webViewerResize);
|
1243
|
-
eventBus.off('hashchange', webViewerHashchange);
|
1244
|
-
eventBus.off('beforeprint', _boundEvents.beforePrint);
|
1245
|
-
eventBus.off('afterprint', _boundEvents.afterPrint);
|
1246
|
-
eventBus.off('pagerendered', webViewerPageRendered);
|
1247
|
-
eventBus.off('textlayerrendered', webViewerTextLayerRendered);
|
1248
|
-
eventBus.off('updateviewarea', webViewerUpdateViewarea);
|
1249
|
-
eventBus.off('pagechanging', webViewerPageChanging);
|
1250
|
-
eventBus.off('scalechanging', webViewerScaleChanging);
|
1251
|
-
eventBus.off('rotationchanging', webViewerRotationChanging);
|
1252
|
-
eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
|
1253
|
-
eventBus.off('pagemode', webViewerPageMode);
|
1254
|
-
eventBus.off('namedaction', webViewerNamedAction);
|
1255
|
-
eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
|
1256
|
-
eventBus.off('presentationmode', webViewerPresentationMode);
|
1257
|
-
eventBus.off('openfile', webViewerOpenFile);
|
1258
|
-
eventBus.off('print', webViewerPrint);
|
1259
|
-
eventBus.off('download', webViewerDownload);
|
1260
|
-
eventBus.off('firstpage', webViewerFirstPage);
|
1261
|
-
eventBus.off('lastpage', webViewerLastPage);
|
1262
|
-
eventBus.off('nextpage', webViewerNextPage);
|
1263
|
-
eventBus.off('previouspage', webViewerPreviousPage);
|
1264
|
-
eventBus.off('zoomin', webViewerZoomIn);
|
1265
|
-
eventBus.off('zoomout', webViewerZoomOut);
|
1266
|
-
eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
|
1267
|
-
eventBus.off('scalechanged', webViewerScaleChanged);
|
1268
|
-
eventBus.off('rotatecw', webViewerRotateCw);
|
1269
|
-
eventBus.off('rotateccw', webViewerRotateCcw);
|
1270
|
-
eventBus.off('switchscrollmode', webViewerSwitchScrollMode);
|
1271
|
-
eventBus.off('scrollmodechanged', webViewerScrollModeChanged);
|
1272
|
-
eventBus.off('switchspreadmode', webViewerSwitchSpreadMode);
|
1273
|
-
eventBus.off('spreadmodechanged', webViewerSpreadModeChanged);
|
1274
|
-
eventBus.off('documentproperties', webViewerDocumentProperties);
|
1275
|
-
eventBus.off('find', webViewerFind);
|
1276
|
-
eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
|
1277
|
-
eventBus.off('updatefindmatchescount', webViewerUpdateFindMatchesCount);
|
1278
|
-
eventBus.off('updatefindcontrolstate', webViewerUpdateFindControlState);
|
1279
|
-
eventBus.off('fileinputchange', webViewerFileInputChange);
|
1280
1433
|
_boundEvents.beforePrint = null;
|
1281
1434
|
_boundEvents.afterPrint = null;
|
1282
1435
|
},
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
window.removeEventListener(
|
1289
|
-
window.removeEventListener(
|
1290
|
-
window.removeEventListener(
|
1291
|
-
window.removeEventListener(
|
1292
|
-
window.removeEventListener(
|
1436
|
+
|
1437
|
+
unbindWindowEvents() {
|
1438
|
+
const {
|
1439
|
+
_boundEvents
|
1440
|
+
} = this;
|
1441
|
+
window.removeEventListener("visibilitychange", webViewerVisibilityChange);
|
1442
|
+
window.removeEventListener("wheel", webViewerWheel);
|
1443
|
+
window.removeEventListener("click", webViewerClick);
|
1444
|
+
window.removeEventListener("keydown", webViewerKeyDown);
|
1445
|
+
window.removeEventListener("resize", _boundEvents.windowResize);
|
1446
|
+
window.removeEventListener("hashchange", _boundEvents.windowHashChange);
|
1447
|
+
window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
|
1448
|
+
window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
|
1293
1449
|
_boundEvents.windowResize = null;
|
1294
1450
|
_boundEvents.windowHashChange = null;
|
1295
1451
|
_boundEvents.windowBeforePrint = null;
|
1296
1452
|
_boundEvents.windowAfterPrint = null;
|
1297
1453
|
}
|
1454
|
+
|
1298
1455
|
};
|
1299
|
-
|
1456
|
+
exports.PDFViewerApplication = PDFViewerApplication;
|
1457
|
+
let validateFileURL;
|
1300
1458
|
{
|
1301
|
-
|
1302
|
-
|
1459
|
+
const HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
|
1460
|
+
|
1461
|
+
validateFileURL = function (file) {
|
1303
1462
|
if (file === undefined) {
|
1304
1463
|
return;
|
1305
1464
|
}
|
1465
|
+
|
1306
1466
|
try {
|
1307
|
-
|
1467
|
+
const viewerOrigin = new URL(window.location.href).origin || "null";
|
1468
|
+
|
1308
1469
|
if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
|
1309
1470
|
return;
|
1310
1471
|
}
|
1311
1472
|
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1473
|
+
const {
|
1474
|
+
origin,
|
1475
|
+
protocol
|
1476
|
+
} = new URL(file, window.location.href);
|
1315
1477
|
|
1316
|
-
if (origin !== viewerOrigin && protocol !==
|
1317
|
-
throw new Error(
|
1478
|
+
if (origin !== viewerOrigin && protocol !== "blob:") {
|
1479
|
+
throw new Error("file origin does not match viewer's");
|
1318
1480
|
}
|
1319
1481
|
} catch (ex) {
|
1320
|
-
|
1321
|
-
PDFViewerApplication.l10n.get(
|
1322
|
-
PDFViewerApplication.error(loadingErrorMessage, {
|
1482
|
+
const message = ex && ex.message;
|
1483
|
+
PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(loadingErrorMessage => {
|
1484
|
+
PDFViewerApplication.error(loadingErrorMessage, {
|
1485
|
+
message
|
1486
|
+
});
|
1323
1487
|
});
|
1324
1488
|
throw ex;
|
1325
1489
|
}
|
1326
1490
|
};
|
1327
1491
|
}
|
1328
|
-
|
1492
|
+
|
1493
|
+
async function loadFakeWorker() {
|
1329
1494
|
if (!_pdf.GlobalWorkerOptions.workerSrc) {
|
1330
|
-
_pdf.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get(
|
1495
|
+
_pdf.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get("workerSrc");
|
1331
1496
|
}
|
1497
|
+
|
1332
1498
|
return (0, _pdf.loadScript)(_pdf.PDFWorker.getWorkerSrc());
|
1333
1499
|
}
|
1500
|
+
|
1334
1501
|
function loadAndEnablePDFBug(enabledTabs) {
|
1335
|
-
|
1502
|
+
const appConfig = PDFViewerApplication.appConfig;
|
1336
1503
|
return (0, _pdf.loadScript)(appConfig.debuggerScriptPath).then(function () {
|
1337
1504
|
PDFBug.enable(enabledTabs);
|
1338
1505
|
PDFBug.init({
|
1339
|
-
OPS: _pdf.OPS
|
1340
|
-
createObjectURL: _pdf.createObjectURL
|
1506
|
+
OPS: _pdf.OPS
|
1341
1507
|
}, appConfig.mainContainer);
|
1342
1508
|
});
|
1343
1509
|
}
|
1510
|
+
|
1344
1511
|
function webViewerInitialized() {
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
file =
|
1512
|
+
const appConfig = PDFViewerApplication.appConfig;
|
1513
|
+
let file;
|
1514
|
+
const queryString = document.location.search.substring(1);
|
1515
|
+
const params = (0, _ui_utils.parseQueryString)(queryString);
|
1516
|
+
file = "file" in params ? params.file : _app_options.AppOptions.get("defaultUrl");
|
1350
1517
|
validateFileURL(file);
|
1351
|
-
|
1518
|
+
const fileInput = document.createElement("input");
|
1352
1519
|
fileInput.id = appConfig.openFileInputName;
|
1353
|
-
fileInput.className =
|
1354
|
-
fileInput.setAttribute(
|
1520
|
+
fileInput.className = "fileInput";
|
1521
|
+
fileInput.setAttribute("type", "file");
|
1355
1522
|
fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
|
1356
1523
|
document.body.appendChild(fileInput);
|
1524
|
+
|
1357
1525
|
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
|
1358
|
-
appConfig.toolbar.openFile.setAttribute(
|
1359
|
-
appConfig.secondaryToolbar.openFileButton.setAttribute(
|
1526
|
+
appConfig.toolbar.openFile.setAttribute("hidden", "true");
|
1527
|
+
appConfig.secondaryToolbar.openFileButton.setAttribute("hidden", "true");
|
1360
1528
|
} else {
|
1361
1529
|
fileInput.value = null;
|
1362
1530
|
}
|
1363
|
-
|
1364
|
-
|
1531
|
+
|
1532
|
+
fileInput.addEventListener("change", function (evt) {
|
1533
|
+
const files = evt.target.files;
|
1534
|
+
|
1365
1535
|
if (!files || files.length === 0) {
|
1366
1536
|
return;
|
1367
1537
|
}
|
1368
|
-
|
1538
|
+
|
1539
|
+
PDFViewerApplication.eventBus.dispatch("fileinputchange", {
|
1369
1540
|
source: this,
|
1370
1541
|
fileInput: evt.target
|
1371
1542
|
});
|
1372
1543
|
});
|
1373
|
-
appConfig.mainContainer.addEventListener(
|
1544
|
+
appConfig.mainContainer.addEventListener("dragover", function (evt) {
|
1374
1545
|
evt.preventDefault();
|
1375
|
-
evt.dataTransfer.dropEffect =
|
1546
|
+
evt.dataTransfer.dropEffect = "move";
|
1376
1547
|
});
|
1377
|
-
appConfig.mainContainer.addEventListener(
|
1548
|
+
appConfig.mainContainer.addEventListener("drop", function (evt) {
|
1378
1549
|
evt.preventDefault();
|
1379
|
-
|
1550
|
+
const files = evt.dataTransfer.files;
|
1551
|
+
|
1380
1552
|
if (!files || files.length === 0) {
|
1381
1553
|
return;
|
1382
1554
|
}
|
1383
|
-
|
1555
|
+
|
1556
|
+
PDFViewerApplication.eventBus.dispatch("fileinputchange", {
|
1384
1557
|
source: this,
|
1385
1558
|
fileInput: evt.dataTransfer
|
1386
1559
|
});
|
1387
1560
|
});
|
1561
|
+
|
1562
|
+
if (!PDFViewerApplication.supportsDocumentFonts) {
|
1563
|
+
_app_options.AppOptions.set("disableFontFace", true);
|
1564
|
+
|
1565
|
+
PDFViewerApplication.l10n.get("web_fonts_disabled", null, "Web fonts are disabled: unable to use embedded PDF fonts.").then(msg => {
|
1566
|
+
console.warn(msg);
|
1567
|
+
});
|
1568
|
+
}
|
1569
|
+
|
1388
1570
|
if (!PDFViewerApplication.supportsPrinting) {
|
1389
|
-
appConfig.toolbar.print.classList.add(
|
1390
|
-
appConfig.secondaryToolbar.printButton.classList.add(
|
1571
|
+
appConfig.toolbar.print.classList.add("hidden");
|
1572
|
+
appConfig.secondaryToolbar.printButton.classList.add("hidden");
|
1391
1573
|
}
|
1574
|
+
|
1392
1575
|
if (!PDFViewerApplication.supportsFullscreen) {
|
1393
|
-
appConfig.toolbar.presentationModeButton.classList.add(
|
1394
|
-
appConfig.secondaryToolbar.presentationModeButton.classList.add(
|
1576
|
+
appConfig.toolbar.presentationModeButton.classList.add("hidden");
|
1577
|
+
appConfig.secondaryToolbar.presentationModeButton.classList.add("hidden");
|
1395
1578
|
}
|
1579
|
+
|
1396
1580
|
if (PDFViewerApplication.supportsIntegratedFind) {
|
1397
|
-
appConfig.toolbar.viewFind.classList.add(
|
1581
|
+
appConfig.toolbar.viewFind.classList.add("hidden");
|
1398
1582
|
}
|
1399
|
-
|
1583
|
+
|
1584
|
+
appConfig.mainContainer.addEventListener("transitionend", function (evt) {
|
1400
1585
|
if (evt.target === this) {
|
1401
|
-
PDFViewerApplication.eventBus.dispatch(
|
1586
|
+
PDFViewerApplication.eventBus.dispatch("resize", {
|
1587
|
+
source: this
|
1588
|
+
});
|
1402
1589
|
}
|
1403
1590
|
}, true);
|
1404
|
-
|
1405
|
-
PDFViewerApplication.pdfSidebar.toggle();
|
1406
|
-
});
|
1591
|
+
|
1407
1592
|
try {
|
1408
1593
|
webViewerOpenFileViaURL(file);
|
1409
1594
|
} catch (reason) {
|
1410
|
-
PDFViewerApplication.l10n.get(
|
1595
|
+
PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(msg => {
|
1411
1596
|
PDFViewerApplication.error(msg, reason);
|
1412
1597
|
});
|
1413
1598
|
}
|
1414
1599
|
}
|
1415
|
-
|
1600
|
+
|
1601
|
+
let webViewerOpenFileViaURL;
|
1416
1602
|
{
|
1417
|
-
webViewerOpenFileViaURL = function
|
1418
|
-
if (file && file.lastIndexOf(
|
1603
|
+
webViewerOpenFileViaURL = function (file) {
|
1604
|
+
if (file && file.lastIndexOf("file:", 0) === 0) {
|
1419
1605
|
PDFViewerApplication.setTitleUsingUrl(file);
|
1420
|
-
|
1606
|
+
const xhr = new XMLHttpRequest();
|
1607
|
+
|
1421
1608
|
xhr.onload = function () {
|
1422
1609
|
PDFViewerApplication.open(new Uint8Array(xhr.response));
|
1423
1610
|
};
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
} catch (ex) {
|
1429
|
-
throw ex;
|
1430
|
-
}
|
1611
|
+
|
1612
|
+
xhr.open("GET", file);
|
1613
|
+
xhr.responseType = "arraybuffer";
|
1614
|
+
xhr.send();
|
1431
1615
|
return;
|
1432
1616
|
}
|
1617
|
+
|
1433
1618
|
if (file) {
|
1434
1619
|
PDFViewerApplication.open(file);
|
1435
1620
|
}
|
1436
1621
|
};
|
1437
1622
|
}
|
1623
|
+
|
1438
1624
|
function webViewerPageRendered(evt) {
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1625
|
+
const pageNumber = evt.pageNumber;
|
1626
|
+
const pageIndex = pageNumber - 1;
|
1627
|
+
const pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
|
1628
|
+
|
1442
1629
|
if (pageNumber === PDFViewerApplication.page) {
|
1443
1630
|
PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
|
1444
1631
|
}
|
1632
|
+
|
1445
1633
|
if (!pageView) {
|
1446
1634
|
return;
|
1447
1635
|
}
|
1636
|
+
|
1448
1637
|
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
|
1449
|
-
|
1638
|
+
const thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
|
1450
1639
|
thumbnailView.setImage(pageView);
|
1451
1640
|
}
|
1452
|
-
|
1641
|
+
|
1642
|
+
if (typeof Stats !== "undefined" && Stats.enabled && pageView.stats) {
|
1453
1643
|
Stats.add(pageNumber, pageView.stats);
|
1454
1644
|
}
|
1645
|
+
|
1455
1646
|
if (pageView.error) {
|
1456
|
-
PDFViewerApplication.l10n.get(
|
1647
|
+
PDFViewerApplication.l10n.get("rendering_error", null, "An error occurred while rendering the page.").then(msg => {
|
1457
1648
|
PDFViewerApplication.error(msg, pageView.error);
|
1458
1649
|
});
|
1459
1650
|
}
|
1651
|
+
|
1652
|
+
PDFViewerApplication.externalServices.reportTelemetry({
|
1653
|
+
type: "pageInfo",
|
1654
|
+
timestamp: evt.timestamp
|
1655
|
+
});
|
1656
|
+
PDFViewerApplication.pdfDocument.getStats().then(function (stats) {
|
1657
|
+
PDFViewerApplication.externalServices.reportTelemetry({
|
1658
|
+
type: "documentStats",
|
1659
|
+
stats
|
1660
|
+
});
|
1661
|
+
});
|
1460
1662
|
}
|
1461
|
-
|
1462
|
-
function webViewerPageMode(
|
1463
|
-
|
1464
|
-
|
1663
|
+
|
1664
|
+
function webViewerPageMode({
|
1665
|
+
mode
|
1666
|
+
}) {
|
1667
|
+
let view;
|
1668
|
+
|
1465
1669
|
switch (mode) {
|
1466
|
-
case
|
1670
|
+
case "thumbs":
|
1467
1671
|
view = _pdf_sidebar.SidebarView.THUMBS;
|
1468
1672
|
break;
|
1469
|
-
|
1470
|
-
case
|
1673
|
+
|
1674
|
+
case "bookmarks":
|
1675
|
+
case "outline":
|
1471
1676
|
view = _pdf_sidebar.SidebarView.OUTLINE;
|
1472
1677
|
break;
|
1473
|
-
|
1678
|
+
|
1679
|
+
case "attachments":
|
1474
1680
|
view = _pdf_sidebar.SidebarView.ATTACHMENTS;
|
1475
1681
|
break;
|
1476
|
-
|
1682
|
+
|
1683
|
+
case "none":
|
1477
1684
|
view = _pdf_sidebar.SidebarView.NONE;
|
1478
1685
|
break;
|
1686
|
+
|
1479
1687
|
default:
|
1480
1688
|
console.error('Invalid "pagemode" hash parameter: ' + mode);
|
1481
1689
|
return;
|
1482
1690
|
}
|
1691
|
+
|
1483
1692
|
PDFViewerApplication.pdfSidebar.switchView(view, true);
|
1484
1693
|
}
|
1694
|
+
|
1485
1695
|
function webViewerNamedAction(evt) {
|
1486
|
-
|
1696
|
+
const action = evt.action;
|
1697
|
+
|
1487
1698
|
switch (action) {
|
1488
|
-
case
|
1699
|
+
case "GoToPage":
|
1489
1700
|
PDFViewerApplication.appConfig.toolbar.pageNumber.select();
|
1490
1701
|
break;
|
1491
|
-
|
1702
|
+
|
1703
|
+
case "Find":
|
1492
1704
|
if (!PDFViewerApplication.supportsIntegratedFind) {
|
1493
1705
|
PDFViewerApplication.findBar.toggle();
|
1494
1706
|
}
|
1707
|
+
|
1495
1708
|
break;
|
1496
1709
|
}
|
1497
1710
|
}
|
1498
|
-
function webViewerPresentationModeChanged(evt) {
|
1499
|
-
var active = evt.active,
|
1500
|
-
switchInProgress = evt.switchInProgress;
|
1501
1711
|
|
1502
|
-
|
1712
|
+
function webViewerPresentationModeChanged({
|
1713
|
+
active,
|
1714
|
+
switchInProgress
|
1715
|
+
}) {
|
1716
|
+
let state = _ui_utils.PresentationModeState.NORMAL;
|
1717
|
+
|
1718
|
+
if (switchInProgress) {
|
1719
|
+
state = _ui_utils.PresentationModeState.CHANGING;
|
1720
|
+
} else if (active) {
|
1721
|
+
state = _ui_utils.PresentationModeState.FULLSCREEN;
|
1722
|
+
}
|
1723
|
+
|
1724
|
+
PDFViewerApplication.pdfViewer.presentationModeState = state;
|
1503
1725
|
}
|
1726
|
+
|
1504
1727
|
function webViewerSidebarViewChanged(evt) {
|
1505
1728
|
PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
|
1506
|
-
|
1729
|
+
const store = PDFViewerApplication.store;
|
1730
|
+
|
1507
1731
|
if (store && PDFViewerApplication.isInitialViewSet) {
|
1508
|
-
store.set(
|
1732
|
+
store.set("sidebarView", evt.view).catch(function () {});
|
1509
1733
|
}
|
1510
1734
|
}
|
1735
|
+
|
1511
1736
|
function webViewerUpdateViewarea(evt) {
|
1512
|
-
|
1513
|
-
|
1737
|
+
const location = evt.location,
|
1738
|
+
store = PDFViewerApplication.store;
|
1739
|
+
|
1514
1740
|
if (store && PDFViewerApplication.isInitialViewSet) {
|
1515
1741
|
store.setMultiple({
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1742
|
+
page: location.pageNumber,
|
1743
|
+
zoom: location.scale,
|
1744
|
+
scrollLeft: location.left,
|
1745
|
+
scrollTop: location.top,
|
1746
|
+
rotation: location.rotation
|
1521
1747
|
}).catch(function () {});
|
1522
1748
|
}
|
1523
|
-
|
1749
|
+
|
1750
|
+
const href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
|
1524
1751
|
PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
|
1525
1752
|
PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
|
1526
|
-
|
1527
|
-
|
1753
|
+
const currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
|
1754
|
+
const loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
|
1528
1755
|
PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
|
1529
1756
|
}
|
1757
|
+
|
1530
1758
|
function webViewerScrollModeChanged(evt) {
|
1531
|
-
|
1759
|
+
const store = PDFViewerApplication.store;
|
1760
|
+
|
1532
1761
|
if (store && PDFViewerApplication.isInitialViewSet) {
|
1533
|
-
store.set(
|
1762
|
+
store.set("scrollMode", evt.mode).catch(function () {});
|
1534
1763
|
}
|
1535
1764
|
}
|
1765
|
+
|
1536
1766
|
function webViewerSpreadModeChanged(evt) {
|
1537
|
-
|
1767
|
+
const store = PDFViewerApplication.store;
|
1768
|
+
|
1538
1769
|
if (store && PDFViewerApplication.isInitialViewSet) {
|
1539
|
-
store.set(
|
1770
|
+
store.set("spreadMode", evt.mode).catch(function () {});
|
1540
1771
|
}
|
1541
1772
|
}
|
1773
|
+
|
1542
1774
|
function webViewerResize() {
|
1543
|
-
|
1544
|
-
|
1775
|
+
const {
|
1776
|
+
pdfDocument,
|
1777
|
+
pdfViewer
|
1778
|
+
} = PDFViewerApplication;
|
1545
1779
|
|
1546
1780
|
if (!pdfDocument) {
|
1547
1781
|
return;
|
1548
1782
|
}
|
1549
|
-
|
1550
|
-
|
1783
|
+
|
1784
|
+
const currentScaleValue = pdfViewer.currentScaleValue;
|
1785
|
+
|
1786
|
+
if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
|
1551
1787
|
pdfViewer.currentScaleValue = currentScaleValue;
|
1552
1788
|
}
|
1789
|
+
|
1553
1790
|
pdfViewer.update();
|
1554
1791
|
}
|
1792
|
+
|
1555
1793
|
function webViewerHashchange(evt) {
|
1556
|
-
|
1794
|
+
const hash = evt.hash;
|
1795
|
+
|
1557
1796
|
if (!hash) {
|
1558
1797
|
return;
|
1559
1798
|
}
|
1799
|
+
|
1560
1800
|
if (!PDFViewerApplication.isInitialViewSet) {
|
1561
1801
|
PDFViewerApplication.initialBookmark = hash;
|
1562
1802
|
} else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
|
1563
1803
|
PDFViewerApplication.pdfLinkService.setHash(hash);
|
1564
1804
|
}
|
1565
1805
|
}
|
1566
|
-
|
1806
|
+
|
1807
|
+
let webViewerFileInputChange, webViewerOpenFile;
|
1567
1808
|
{
|
1568
|
-
webViewerFileInputChange = function
|
1809
|
+
webViewerFileInputChange = function (evt) {
|
1569
1810
|
if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
|
1570
1811
|
return;
|
1571
1812
|
}
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1813
|
+
|
1814
|
+
const file = evt.fileInput.files[0];
|
1815
|
+
|
1816
|
+
if (URL.createObjectURL && !_app_options.AppOptions.get("disableCreateObjectURL")) {
|
1817
|
+
let url = URL.createObjectURL(file);
|
1818
|
+
|
1575
1819
|
if (file.name) {
|
1576
|
-
|
1577
|
-
url
|
1820
|
+
url = {
|
1821
|
+
url,
|
1578
1822
|
originalUrl: file.name
|
1579
1823
|
};
|
1580
1824
|
}
|
1581
|
-
|
1825
|
+
|
1826
|
+
PDFViewerApplication.open(url);
|
1582
1827
|
} else {
|
1583
1828
|
PDFViewerApplication.setTitleUsingUrl(file.name);
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1829
|
+
const fileReader = new FileReader();
|
1830
|
+
|
1831
|
+
fileReader.onload = function webViewerChangeFileReaderOnload(event) {
|
1832
|
+
const buffer = event.target.result;
|
1587
1833
|
PDFViewerApplication.open(new Uint8Array(buffer));
|
1588
1834
|
};
|
1835
|
+
|
1589
1836
|
fileReader.readAsArrayBuffer(file);
|
1590
1837
|
}
|
1591
|
-
|
1592
|
-
appConfig.
|
1593
|
-
appConfig.
|
1594
|
-
appConfig.
|
1595
|
-
appConfig.
|
1838
|
+
|
1839
|
+
const appConfig = PDFViewerApplication.appConfig;
|
1840
|
+
appConfig.toolbar.viewBookmark.setAttribute("hidden", "true");
|
1841
|
+
appConfig.secondaryToolbar.viewBookmarkButton.setAttribute("hidden", "true");
|
1842
|
+
appConfig.toolbar.download.setAttribute("hidden", "true");
|
1843
|
+
appConfig.secondaryToolbar.downloadButton.setAttribute("hidden", "true");
|
1844
|
+
};
|
1845
|
+
|
1846
|
+
webViewerOpenFile = function (evt) {
|
1847
|
+
const openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
|
1848
|
+
document.getElementById(openFileInputName).click();
|
1596
1849
|
};
|
1597
1850
|
}
|
1851
|
+
|
1598
1852
|
function webViewerPresentationMode() {
|
1599
1853
|
PDFViewerApplication.requestPresentationMode();
|
1600
1854
|
}
|
1601
|
-
|
1602
|
-
var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
|
1603
|
-
document.getElementById(openFileInputName).click();
|
1604
|
-
}
|
1855
|
+
|
1605
1856
|
function webViewerPrint() {
|
1606
1857
|
window.print();
|
1607
1858
|
}
|
1859
|
+
|
1608
1860
|
function webViewerDownload() {
|
1609
1861
|
PDFViewerApplication.download();
|
1610
1862
|
}
|
1863
|
+
|
1611
1864
|
function webViewerFirstPage() {
|
1612
1865
|
if (PDFViewerApplication.pdfDocument) {
|
1613
1866
|
PDFViewerApplication.page = 1;
|
1614
1867
|
}
|
1615
1868
|
}
|
1869
|
+
|
1616
1870
|
function webViewerLastPage() {
|
1617
1871
|
if (PDFViewerApplication.pdfDocument) {
|
1618
1872
|
PDFViewerApplication.page = PDFViewerApplication.pagesCount;
|
1619
1873
|
}
|
1620
1874
|
}
|
1875
|
+
|
1621
1876
|
function webViewerNextPage() {
|
1622
1877
|
PDFViewerApplication.page++;
|
1623
1878
|
}
|
1879
|
+
|
1624
1880
|
function webViewerPreviousPage() {
|
1625
1881
|
PDFViewerApplication.page--;
|
1626
1882
|
}
|
1883
|
+
|
1627
1884
|
function webViewerZoomIn() {
|
1628
1885
|
PDFViewerApplication.zoomIn();
|
1629
1886
|
}
|
1887
|
+
|
1630
1888
|
function webViewerZoomOut() {
|
1631
1889
|
PDFViewerApplication.zoomOut();
|
1632
1890
|
}
|
1891
|
+
|
1892
|
+
function webViewerZoomReset() {
|
1893
|
+
PDFViewerApplication.zoomReset();
|
1894
|
+
}
|
1895
|
+
|
1633
1896
|
function webViewerPageNumberChanged(evt) {
|
1634
|
-
|
1635
|
-
|
1897
|
+
const pdfViewer = PDFViewerApplication.pdfViewer;
|
1898
|
+
|
1899
|
+
if (evt.value !== "") {
|
1900
|
+
pdfViewer.currentPageLabel = evt.value;
|
1901
|
+
}
|
1902
|
+
|
1636
1903
|
if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
|
1637
1904
|
PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
|
1638
1905
|
}
|
1639
1906
|
}
|
1907
|
+
|
1640
1908
|
function webViewerScaleChanged(evt) {
|
1641
1909
|
PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
|
1642
1910
|
}
|
1911
|
+
|
1643
1912
|
function webViewerRotateCw() {
|
1644
1913
|
PDFViewerApplication.rotatePages(90);
|
1645
1914
|
}
|
1915
|
+
|
1646
1916
|
function webViewerRotateCcw() {
|
1647
1917
|
PDFViewerApplication.rotatePages(-90);
|
1648
1918
|
}
|
1919
|
+
|
1649
1920
|
function webViewerSwitchScrollMode(evt) {
|
1650
1921
|
PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
|
1651
1922
|
}
|
1923
|
+
|
1652
1924
|
function webViewerSwitchSpreadMode(evt) {
|
1653
1925
|
PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
|
1654
1926
|
}
|
1927
|
+
|
1655
1928
|
function webViewerDocumentProperties() {
|
1656
1929
|
PDFViewerApplication.pdfDocumentProperties.open();
|
1657
1930
|
}
|
1931
|
+
|
1658
1932
|
function webViewerFind(evt) {
|
1659
|
-
PDFViewerApplication.findController.executeCommand(
|
1933
|
+
PDFViewerApplication.findController.executeCommand("find" + evt.type, {
|
1660
1934
|
query: evt.query,
|
1661
1935
|
phraseSearch: evt.phraseSearch,
|
1662
1936
|
caseSensitive: evt.caseSensitive,
|
@@ -1665,8 +1939,9 @@ function webViewerFind(evt) {
|
|
1665
1939
|
findPrevious: evt.findPrevious
|
1666
1940
|
});
|
1667
1941
|
}
|
1942
|
+
|
1668
1943
|
function webViewerFindFromUrlHash(evt) {
|
1669
|
-
PDFViewerApplication.findController.executeCommand(
|
1944
|
+
PDFViewerApplication.findController.executeCommand("find", {
|
1670
1945
|
query: evt.query,
|
1671
1946
|
phraseSearch: evt.phraseSearch,
|
1672
1947
|
caseSensitive: false,
|
@@ -1675,113 +1950,146 @@ function webViewerFindFromUrlHash(evt) {
|
|
1675
1950
|
findPrevious: false
|
1676
1951
|
});
|
1677
1952
|
}
|
1678
|
-
function webViewerUpdateFindMatchesCount(_ref15) {
|
1679
|
-
var matchesCount = _ref15.matchesCount;
|
1680
1953
|
|
1954
|
+
function webViewerUpdateFindMatchesCount({
|
1955
|
+
matchesCount
|
1956
|
+
}) {
|
1681
1957
|
if (PDFViewerApplication.supportsIntegratedFind) {
|
1682
1958
|
PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
|
1683
1959
|
} else {
|
1684
1960
|
PDFViewerApplication.findBar.updateResultsCount(matchesCount);
|
1685
1961
|
}
|
1686
1962
|
}
|
1687
|
-
function webViewerUpdateFindControlState(_ref16) {
|
1688
|
-
var state = _ref16.state,
|
1689
|
-
previous = _ref16.previous,
|
1690
|
-
matchesCount = _ref16.matchesCount;
|
1691
1963
|
|
1964
|
+
function webViewerUpdateFindControlState({
|
1965
|
+
state,
|
1966
|
+
previous,
|
1967
|
+
matchesCount
|
1968
|
+
}) {
|
1692
1969
|
if (PDFViewerApplication.supportsIntegratedFind) {
|
1693
1970
|
PDFViewerApplication.externalServices.updateFindControlState({
|
1694
1971
|
result: state,
|
1695
1972
|
findPrevious: previous,
|
1696
|
-
matchesCount
|
1973
|
+
matchesCount
|
1697
1974
|
});
|
1698
1975
|
} else {
|
1699
1976
|
PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
|
1700
1977
|
}
|
1701
1978
|
}
|
1979
|
+
|
1702
1980
|
function webViewerScaleChanging(evt) {
|
1703
1981
|
PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
|
1704
1982
|
PDFViewerApplication.pdfViewer.update();
|
1705
1983
|
}
|
1984
|
+
|
1706
1985
|
function webViewerRotationChanging(evt) {
|
1707
1986
|
PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
|
1708
1987
|
PDFViewerApplication.forceRendering();
|
1709
1988
|
PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
|
1710
1989
|
}
|
1990
|
+
|
1711
1991
|
function webViewerPageChanging(evt) {
|
1712
|
-
|
1992
|
+
const page = evt.pageNumber;
|
1713
1993
|
PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
|
1714
1994
|
PDFViewerApplication.secondaryToolbar.setPageNumber(page);
|
1995
|
+
|
1715
1996
|
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
|
1716
1997
|
PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
|
1717
1998
|
}
|
1718
|
-
|
1719
|
-
|
1999
|
+
|
2000
|
+
if (typeof Stats !== "undefined" && Stats.enabled) {
|
2001
|
+
const pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
|
2002
|
+
|
1720
2003
|
if (pageView && pageView.stats) {
|
1721
2004
|
Stats.add(page, pageView.stats);
|
1722
2005
|
}
|
1723
2006
|
}
|
1724
2007
|
}
|
1725
|
-
|
1726
|
-
|
2008
|
+
|
2009
|
+
function webViewerVisibilityChange(evt) {
|
2010
|
+
if (document.visibilityState === "visible") {
|
2011
|
+
setZoomDisabledTimeout();
|
2012
|
+
}
|
2013
|
+
}
|
2014
|
+
|
2015
|
+
let zoomDisabledTimeout = null;
|
2016
|
+
|
2017
|
+
function setZoomDisabledTimeout() {
|
2018
|
+
if (zoomDisabledTimeout) {
|
2019
|
+
clearTimeout(zoomDisabledTimeout);
|
2020
|
+
}
|
2021
|
+
|
2022
|
+
zoomDisabledTimeout = setTimeout(function () {
|
2023
|
+
zoomDisabledTimeout = null;
|
2024
|
+
}, WHEEL_ZOOM_DISABLED_TIMEOUT);
|
2025
|
+
}
|
2026
|
+
|
1727
2027
|
function webViewerWheel(evt) {
|
1728
|
-
|
2028
|
+
const {
|
2029
|
+
pdfViewer,
|
2030
|
+
supportedMouseWheelZoomModifierKeys
|
2031
|
+
} = PDFViewerApplication;
|
2032
|
+
|
1729
2033
|
if (pdfViewer.isInPresentationMode) {
|
1730
2034
|
return;
|
1731
2035
|
}
|
1732
|
-
|
1733
|
-
|
1734
|
-
if (evt.ctrlKey && !support.ctrlKey || evt.metaKey && !support.metaKey) {
|
1735
|
-
return;
|
1736
|
-
}
|
2036
|
+
|
2037
|
+
if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
|
1737
2038
|
evt.preventDefault();
|
1738
|
-
|
2039
|
+
|
2040
|
+
if (zoomDisabledTimeout || document.visibilityState === "hidden") {
|
1739
2041
|
return;
|
1740
2042
|
}
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
2043
|
+
|
2044
|
+
const previousScale = pdfViewer.currentScale;
|
2045
|
+
const delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
|
2046
|
+
const MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
|
2047
|
+
const ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
|
2048
|
+
|
1745
2049
|
if (ticks < 0) {
|
1746
2050
|
PDFViewerApplication.zoomOut(-ticks);
|
1747
2051
|
} else {
|
1748
2052
|
PDFViewerApplication.zoomIn(ticks);
|
1749
2053
|
}
|
1750
|
-
|
2054
|
+
|
2055
|
+
const currentScale = pdfViewer.currentScale;
|
2056
|
+
|
1751
2057
|
if (previousScale !== currentScale) {
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
2058
|
+
const scaleCorrectionFactor = currentScale / previousScale - 1;
|
2059
|
+
const rect = pdfViewer.container.getBoundingClientRect();
|
2060
|
+
const dx = evt.clientX - rect.left;
|
2061
|
+
const dy = evt.clientY - rect.top;
|
1756
2062
|
pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
|
1757
2063
|
pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
|
1758
2064
|
}
|
1759
2065
|
} else {
|
1760
|
-
|
1761
|
-
clearTimeout(zoomDisabledTimeout);
|
1762
|
-
zoomDisabledTimeout = setTimeout(function () {
|
1763
|
-
zoomDisabled = false;
|
1764
|
-
}, 1000);
|
2066
|
+
setZoomDisabledTimeout();
|
1765
2067
|
}
|
1766
2068
|
}
|
2069
|
+
|
1767
2070
|
function webViewerClick(evt) {
|
1768
2071
|
if (!PDFViewerApplication.secondaryToolbar.isOpen) {
|
1769
2072
|
return;
|
1770
2073
|
}
|
1771
|
-
|
2074
|
+
|
2075
|
+
const appConfig = PDFViewerApplication.appConfig;
|
2076
|
+
|
1772
2077
|
if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
|
1773
2078
|
PDFViewerApplication.secondaryToolbar.close();
|
1774
2079
|
}
|
1775
2080
|
}
|
2081
|
+
|
1776
2082
|
function webViewerKeyDown(evt) {
|
1777
2083
|
if (PDFViewerApplication.overlayManager.active) {
|
1778
2084
|
return;
|
1779
2085
|
}
|
1780
|
-
|
2086
|
+
|
2087
|
+
let handled = false,
|
1781
2088
|
ensureViewerFocused = false;
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
2089
|
+
const cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
|
2090
|
+
const pdfViewer = PDFViewerApplication.pdfViewer;
|
2091
|
+
const isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
|
2092
|
+
|
1785
2093
|
if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
|
1786
2094
|
switch (evt.keyCode) {
|
1787
2095
|
case 70:
|
@@ -1789,12 +2097,15 @@ function webViewerKeyDown(evt) {
|
|
1789
2097
|
PDFViewerApplication.findBar.open();
|
1790
2098
|
handled = true;
|
1791
2099
|
}
|
2100
|
+
|
1792
2101
|
break;
|
2102
|
+
|
1793
2103
|
case 71:
|
1794
2104
|
if (!PDFViewerApplication.supportsIntegratedFind) {
|
1795
|
-
|
2105
|
+
const findState = PDFViewerApplication.findController.state;
|
2106
|
+
|
1796
2107
|
if (findState) {
|
1797
|
-
PDFViewerApplication.findController.executeCommand(
|
2108
|
+
PDFViewerApplication.findController.executeCommand("findagain", {
|
1798
2109
|
query: findState.query,
|
1799
2110
|
phraseSearch: findState.phraseSearch,
|
1800
2111
|
caseSensitive: findState.caseSensitive,
|
@@ -1803,9 +2114,12 @@ function webViewerKeyDown(evt) {
|
|
1803
2114
|
findPrevious: cmd === 5 || cmd === 12
|
1804
2115
|
});
|
1805
2116
|
}
|
2117
|
+
|
1806
2118
|
handled = true;
|
1807
2119
|
}
|
2120
|
+
|
1808
2121
|
break;
|
2122
|
+
|
1809
2123
|
case 61:
|
1810
2124
|
case 107:
|
1811
2125
|
case 187:
|
@@ -1813,41 +2127,51 @@ function webViewerKeyDown(evt) {
|
|
1813
2127
|
if (!isViewerInPresentationMode) {
|
1814
2128
|
PDFViewerApplication.zoomIn();
|
1815
2129
|
}
|
2130
|
+
|
1816
2131
|
handled = true;
|
1817
2132
|
break;
|
2133
|
+
|
1818
2134
|
case 173:
|
1819
2135
|
case 109:
|
1820
2136
|
case 189:
|
1821
2137
|
if (!isViewerInPresentationMode) {
|
1822
2138
|
PDFViewerApplication.zoomOut();
|
1823
2139
|
}
|
2140
|
+
|
1824
2141
|
handled = true;
|
1825
2142
|
break;
|
2143
|
+
|
1826
2144
|
case 48:
|
1827
2145
|
case 96:
|
1828
2146
|
if (!isViewerInPresentationMode) {
|
1829
2147
|
setTimeout(function () {
|
1830
|
-
|
2148
|
+
PDFViewerApplication.zoomReset();
|
1831
2149
|
});
|
1832
2150
|
handled = false;
|
1833
2151
|
}
|
2152
|
+
|
1834
2153
|
break;
|
2154
|
+
|
1835
2155
|
case 38:
|
1836
2156
|
if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
|
1837
2157
|
PDFViewerApplication.page = 1;
|
1838
2158
|
handled = true;
|
1839
2159
|
ensureViewerFocused = true;
|
1840
2160
|
}
|
2161
|
+
|
1841
2162
|
break;
|
2163
|
+
|
1842
2164
|
case 40:
|
1843
2165
|
if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
|
1844
2166
|
PDFViewerApplication.page = PDFViewerApplication.pagesCount;
|
1845
2167
|
handled = true;
|
1846
2168
|
ensureViewerFocused = true;
|
1847
2169
|
}
|
2170
|
+
|
1848
2171
|
break;
|
1849
2172
|
}
|
1850
2173
|
}
|
2174
|
+
|
1851
2175
|
if (cmd === 1 || cmd === 8) {
|
1852
2176
|
switch (evt.keyCode) {
|
1853
2177
|
case 83:
|
@@ -1856,114 +2180,148 @@ function webViewerKeyDown(evt) {
|
|
1856
2180
|
break;
|
1857
2181
|
}
|
1858
2182
|
}
|
2183
|
+
|
1859
2184
|
if (cmd === 3 || cmd === 10) {
|
1860
2185
|
switch (evt.keyCode) {
|
1861
2186
|
case 80:
|
1862
2187
|
PDFViewerApplication.requestPresentationMode();
|
1863
2188
|
handled = true;
|
1864
2189
|
break;
|
2190
|
+
|
1865
2191
|
case 71:
|
1866
2192
|
PDFViewerApplication.appConfig.toolbar.pageNumber.select();
|
1867
2193
|
handled = true;
|
1868
2194
|
break;
|
1869
2195
|
}
|
1870
2196
|
}
|
2197
|
+
|
1871
2198
|
if (handled) {
|
1872
2199
|
if (ensureViewerFocused && !isViewerInPresentationMode) {
|
1873
2200
|
pdfViewer.focus();
|
1874
2201
|
}
|
2202
|
+
|
1875
2203
|
evt.preventDefault();
|
1876
2204
|
return;
|
1877
2205
|
}
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
2206
|
+
|
2207
|
+
const curElement = document.activeElement || document.querySelector(":focus");
|
2208
|
+
const curElementTagName = curElement && curElement.tagName.toUpperCase();
|
2209
|
+
|
2210
|
+
if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement && curElement.isContentEditable) {
|
1881
2211
|
if (evt.keyCode !== 27) {
|
1882
2212
|
return;
|
1883
2213
|
}
|
1884
2214
|
}
|
2215
|
+
|
1885
2216
|
if (cmd === 0) {
|
1886
|
-
|
2217
|
+
let turnPage = 0,
|
1887
2218
|
turnOnlyIfPageFit = false;
|
2219
|
+
|
1888
2220
|
switch (evt.keyCode) {
|
1889
2221
|
case 38:
|
1890
2222
|
case 33:
|
1891
2223
|
if (pdfViewer.isVerticalScrollbarEnabled) {
|
1892
2224
|
turnOnlyIfPageFit = true;
|
1893
2225
|
}
|
2226
|
+
|
1894
2227
|
turnPage = -1;
|
1895
2228
|
break;
|
2229
|
+
|
1896
2230
|
case 8:
|
1897
2231
|
if (!isViewerInPresentationMode) {
|
1898
2232
|
turnOnlyIfPageFit = true;
|
1899
2233
|
}
|
2234
|
+
|
1900
2235
|
turnPage = -1;
|
1901
2236
|
break;
|
2237
|
+
|
1902
2238
|
case 37:
|
1903
2239
|
if (pdfViewer.isHorizontalScrollbarEnabled) {
|
1904
2240
|
turnOnlyIfPageFit = true;
|
1905
2241
|
}
|
2242
|
+
|
1906
2243
|
case 75:
|
1907
2244
|
case 80:
|
1908
2245
|
turnPage = -1;
|
1909
2246
|
break;
|
2247
|
+
|
1910
2248
|
case 27:
|
1911
2249
|
if (PDFViewerApplication.secondaryToolbar.isOpen) {
|
1912
2250
|
PDFViewerApplication.secondaryToolbar.close();
|
1913
2251
|
handled = true;
|
1914
2252
|
}
|
2253
|
+
|
1915
2254
|
if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
|
1916
2255
|
PDFViewerApplication.findBar.close();
|
1917
2256
|
handled = true;
|
1918
2257
|
}
|
2258
|
+
|
1919
2259
|
break;
|
2260
|
+
|
1920
2261
|
case 40:
|
1921
2262
|
case 34:
|
1922
2263
|
if (pdfViewer.isVerticalScrollbarEnabled) {
|
1923
2264
|
turnOnlyIfPageFit = true;
|
1924
2265
|
}
|
2266
|
+
|
1925
2267
|
turnPage = 1;
|
1926
2268
|
break;
|
2269
|
+
|
1927
2270
|
case 13:
|
1928
2271
|
case 32:
|
1929
2272
|
if (!isViewerInPresentationMode) {
|
1930
2273
|
turnOnlyIfPageFit = true;
|
1931
2274
|
}
|
2275
|
+
|
1932
2276
|
turnPage = 1;
|
1933
2277
|
break;
|
2278
|
+
|
1934
2279
|
case 39:
|
1935
2280
|
if (pdfViewer.isHorizontalScrollbarEnabled) {
|
1936
2281
|
turnOnlyIfPageFit = true;
|
1937
2282
|
}
|
2283
|
+
|
1938
2284
|
case 74:
|
1939
2285
|
case 78:
|
1940
2286
|
turnPage = 1;
|
1941
2287
|
break;
|
2288
|
+
|
1942
2289
|
case 36:
|
1943
2290
|
if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
|
1944
2291
|
PDFViewerApplication.page = 1;
|
1945
2292
|
handled = true;
|
1946
2293
|
ensureViewerFocused = true;
|
1947
2294
|
}
|
2295
|
+
|
1948
2296
|
break;
|
2297
|
+
|
1949
2298
|
case 35:
|
1950
2299
|
if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
|
1951
2300
|
PDFViewerApplication.page = PDFViewerApplication.pagesCount;
|
1952
2301
|
handled = true;
|
1953
2302
|
ensureViewerFocused = true;
|
1954
2303
|
}
|
2304
|
+
|
1955
2305
|
break;
|
2306
|
+
|
1956
2307
|
case 83:
|
1957
2308
|
PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
|
1958
2309
|
break;
|
2310
|
+
|
1959
2311
|
case 72:
|
1960
2312
|
PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
|
1961
2313
|
break;
|
2314
|
+
|
1962
2315
|
case 82:
|
1963
2316
|
PDFViewerApplication.rotatePages(90);
|
1964
2317
|
break;
|
2318
|
+
|
2319
|
+
case 115:
|
2320
|
+
PDFViewerApplication.pdfSidebar.toggle();
|
2321
|
+
break;
|
1965
2322
|
}
|
1966
|
-
|
2323
|
+
|
2324
|
+
if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
|
1967
2325
|
if (turnPage > 0) {
|
1968
2326
|
if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
|
1969
2327
|
PDFViewerApplication.page++;
|
@@ -1973,60 +2331,93 @@ function webViewerKeyDown(evt) {
|
|
1973
2331
|
PDFViewerApplication.page--;
|
1974
2332
|
}
|
1975
2333
|
}
|
2334
|
+
|
1976
2335
|
handled = true;
|
1977
2336
|
}
|
1978
2337
|
}
|
2338
|
+
|
1979
2339
|
if (cmd === 4) {
|
1980
2340
|
switch (evt.keyCode) {
|
1981
2341
|
case 13:
|
1982
2342
|
case 32:
|
1983
|
-
if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !==
|
2343
|
+
if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
|
1984
2344
|
break;
|
1985
2345
|
}
|
2346
|
+
|
1986
2347
|
if (PDFViewerApplication.page > 1) {
|
1987
2348
|
PDFViewerApplication.page--;
|
1988
2349
|
}
|
2350
|
+
|
1989
2351
|
handled = true;
|
1990
2352
|
break;
|
2353
|
+
|
1991
2354
|
case 82:
|
1992
2355
|
PDFViewerApplication.rotatePages(-90);
|
1993
2356
|
break;
|
1994
2357
|
}
|
1995
2358
|
}
|
2359
|
+
|
1996
2360
|
if (!handled && !isViewerInPresentationMode) {
|
1997
|
-
if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !==
|
2361
|
+
if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
|
1998
2362
|
ensureViewerFocused = true;
|
1999
2363
|
}
|
2000
2364
|
}
|
2365
|
+
|
2001
2366
|
if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
|
2002
2367
|
pdfViewer.focus();
|
2003
2368
|
}
|
2369
|
+
|
2004
2370
|
if (handled) {
|
2005
2371
|
evt.preventDefault();
|
2006
2372
|
}
|
2007
2373
|
}
|
2374
|
+
|
2375
|
+
function apiPageLayoutToSpreadMode(layout) {
|
2376
|
+
switch (layout) {
|
2377
|
+
case "SinglePage":
|
2378
|
+
case "OneColumn":
|
2379
|
+
return _ui_utils.SpreadMode.NONE;
|
2380
|
+
|
2381
|
+
case "TwoColumnLeft":
|
2382
|
+
case "TwoPageLeft":
|
2383
|
+
return _ui_utils.SpreadMode.ODD;
|
2384
|
+
|
2385
|
+
case "TwoColumnRight":
|
2386
|
+
case "TwoPageRight":
|
2387
|
+
return _ui_utils.SpreadMode.EVEN;
|
2388
|
+
}
|
2389
|
+
|
2390
|
+
return _ui_utils.SpreadMode.NONE;
|
2391
|
+
}
|
2392
|
+
|
2008
2393
|
function apiPageModeToSidebarView(mode) {
|
2009
2394
|
switch (mode) {
|
2010
|
-
case
|
2395
|
+
case "UseNone":
|
2011
2396
|
return _pdf_sidebar.SidebarView.NONE;
|
2012
|
-
|
2397
|
+
|
2398
|
+
case "UseThumbs":
|
2013
2399
|
return _pdf_sidebar.SidebarView.THUMBS;
|
2014
|
-
|
2400
|
+
|
2401
|
+
case "UseOutlines":
|
2015
2402
|
return _pdf_sidebar.SidebarView.OUTLINE;
|
2016
|
-
|
2403
|
+
|
2404
|
+
case "UseAttachments":
|
2017
2405
|
return _pdf_sidebar.SidebarView.ATTACHMENTS;
|
2018
|
-
|
2406
|
+
|
2407
|
+
case "UseOC":
|
2019
2408
|
}
|
2409
|
+
|
2020
2410
|
return _pdf_sidebar.SidebarView.NONE;
|
2021
2411
|
}
|
2022
|
-
|
2412
|
+
|
2413
|
+
const PDFPrintServiceFactory = {
|
2023
2414
|
instance: {
|
2024
2415
|
supportsPrinting: false,
|
2025
|
-
|
2026
|
-
|
2416
|
+
|
2417
|
+
createPrintService() {
|
2418
|
+
throw new Error("Not implemented: createPrintService");
|
2027
2419
|
}
|
2420
|
+
|
2028
2421
|
}
|
2029
2422
|
};
|
2030
|
-
exports.PDFViewerApplication = PDFViewerApplication;
|
2031
|
-
exports.DefaultExternalServices = DefaultExternalServices;
|
2032
2423
|
exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
|