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