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