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