pdfjs-dist 2.1.266 → 2.5.207
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8382 -18492
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +20417 -29816
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25688 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +58239 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +403 -0
- package/es5/web/pdf_viewer.js +7742 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1475 -4897
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +750 -899
- package/lib/core/arithmetic_decoder.js +81 -97
- package/lib/core/bidi.js +54 -46
- package/lib/core/ccitt.js +88 -81
- package/lib/core/ccitt_stream.js +15 -14
- package/lib/core/cff_parser.js +235 -183
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +447 -542
- package/lib/core/cmap.js +222 -264
- package/lib/core/colorspace.js +699 -863
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +379 -437
- package/lib/core/document.js +573 -660
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +1103 -868
- package/lib/core/font_renderer.js +135 -178
- package/lib/core/fonts.js +570 -491
- package/lib/core/function.js +291 -288
- package/lib/core/glyphlist.js +4527 -4526
- package/lib/core/image.js +145 -149
- package/lib/core/image_utils.js +170 -0
- package/lib/core/jbig2.js +325 -316
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +21 -26
- package/lib/core/jpg.js +284 -232
- package/lib/core/jpx.js +161 -143
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2929 -2929
- package/lib/core/murmurhash3.js +90 -101
- package/lib/core/obj.js +1183 -1157
- package/lib/core/operator_list.js +99 -67
- package/lib/core/parser.js +972 -911
- package/lib/core/pattern.js +87 -70
- package/lib/core/pdf_manager.js +150 -315
- package/lib/core/primitives.js +83 -56
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +94 -74
- package/lib/core/type1_parser.js +87 -69
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +193 -390
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +741 -972
- package/lib/display/api.js +1500 -1791
- package/lib/display/api_compatibility.js +12 -17
- package/lib/display/canvas.js +165 -165
- package/lib/display/content_disposition.js +40 -59
- package/lib/display/display_utils.js +515 -0
- package/lib/display/fetch_stream.js +183 -298
- package/lib/display/font_loader.js +273 -413
- package/lib/display/metadata.js +86 -98
- package/lib/display/network.js +266 -359
- package/lib/display/network_utils.js +25 -18
- package/lib/display/node_stream.js +285 -458
- package/lib/display/pattern_helper.js +113 -65
- package/lib/display/svg.js +1166 -901
- package/lib/display/text_layer.js +156 -132
- package/lib/display/transport_stream.js +262 -278
- package/lib/display/webgl.js +70 -83
- package/lib/display/worker_options.js +3 -3
- package/lib/display/xml_parser.js +303 -392
- package/lib/examples/node/domstubs.js +40 -37
- package/lib/pdf.js +226 -59
- package/lib/pdf.worker.js +14 -6
- package/lib/shared/compatibility.js +3 -246
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +327 -332
- package/lib/shared/util.js +266 -416
- package/lib/test/unit/annotation_spec.js +1555 -701
- package/lib/test/unit/api_spec.js +802 -604
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +84 -69
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +74 -76
- package/lib/test/unit/colorspace_spec.js +166 -161
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +181 -181
- package/lib/test/unit/custom_spec.js +20 -22
- package/lib/test/unit/display_svg_spec.js +34 -39
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +16 -21
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +83 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +46 -30
- package/lib/test/unit/message_handler_spec.js +173 -159
- package/lib/test/unit/metadata_spec.js +69 -69
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +13 -61
- package/lib/test/unit/network_utils_spec.js +183 -119
- package/lib/test/unit/node_stream_spec.js +78 -92
- package/lib/test/unit/parser_spec.js +172 -114
- package/lib/test/unit/pdf_find_controller_spec.js +55 -86
- package/lib/test/unit/pdf_find_utils_spec.js +32 -32
- package/lib/test/unit/pdf_history_spec.js +32 -32
- package/lib/test/unit/primitives_spec.js +140 -125
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +131 -143
- package/lib/test/unit/testreporter.js +19 -19
- package/lib/test/unit/type1_parser_spec.js +42 -42
- package/lib/test/unit/ui_utils_spec.js +297 -459
- package/lib/test/unit/unicode_spec.js +38 -38
- package/lib/test/unit/util_spec.js +121 -305
- package/lib/web/annotation_layer_builder.js +66 -103
- package/lib/web/app.js +1328 -1214
- package/lib/web/app_options.js +105 -107
- package/lib/web/base_viewer.js +824 -838
- package/lib/web/chromecom.js +165 -252
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +39 -55
- package/lib/web/firefox_print_service.js +37 -27
- package/lib/web/firefoxcom.js +212 -363
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +32 -30
- package/lib/web/interfaces.js +80 -254
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +113 -131
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +221 -306
- package/lib/web/pdf_find_bar.js +136 -170
- package/lib/web/pdf_find_controller.js +491 -548
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +397 -406
- package/lib/web/pdf_link_service.js +304 -348
- package/lib/web/pdf_outline_viewer.js +140 -175
- package/lib/web/pdf_page_view.js +452 -523
- package/lib/web/pdf_presentation_mode.js +308 -357
- package/lib/web/pdf_print_service.js +90 -104
- package/lib/web/pdf_rendering_queue.js +84 -108
- package/lib/web/pdf_sidebar.js +276 -306
- package/lib/web/pdf_sidebar_resizer.js +92 -119
- package/lib/web/pdf_single_page_viewer.js +77 -126
- package/lib/web/pdf_thumbnail_view.js +276 -297
- package/lib/web/pdf_thumbnail_viewer.js +186 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +82 -286
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +282 -339
- package/lib/web/toolbar.js +217 -210
- package/lib/web/ui_utils.js +267 -420
- package/lib/web/view_history.js +52 -226
- package/lib/web/viewer_compatibility.js +21 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +35 -25
- package/web/pdf_viewer.js +3489 -4855
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -494
- package/lib/shared/streams_polyfill.js +0 -43
- package/lib/shared/url_polyfill.js +0 -56
- package/lib/test/unit/dom_utils_spec.js +0 -89
@@ -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,32 +26,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
26
26
|
});
|
27
27
|
exports.SimpleLinkService = exports.PDFLinkService = void 0;
|
28
28
|
|
29
|
-
var _ui_utils = require("./ui_utils");
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
/*#__PURE__*/
|
41
|
-
function () {
|
42
|
-
function PDFLinkService() {
|
43
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
44
|
-
eventBus = _ref.eventBus,
|
45
|
-
_ref$externalLinkTarg = _ref.externalLinkTarget,
|
46
|
-
externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
|
47
|
-
_ref$externalLinkRel = _ref.externalLinkRel,
|
48
|
-
externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel;
|
49
|
-
|
50
|
-
_classCallCheck(this, PDFLinkService);
|
51
|
-
|
52
|
-
this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
|
29
|
+
var _ui_utils = require("./ui_utils.js");
|
30
|
+
|
31
|
+
class PDFLinkService {
|
32
|
+
constructor({
|
33
|
+
eventBus,
|
34
|
+
externalLinkTarget = null,
|
35
|
+
externalLinkRel = null,
|
36
|
+
externalLinkEnabled = true,
|
37
|
+
ignoreDestinationZoom = false
|
38
|
+
} = {}) {
|
39
|
+
this.eventBus = eventBus;
|
53
40
|
this.externalLinkTarget = externalLinkTarget;
|
54
41
|
this.externalLinkRel = externalLinkRel;
|
42
|
+
this.externalLinkEnabled = externalLinkEnabled;
|
43
|
+
this._ignoreDestinationZoom = ignoreDestinationZoom;
|
55
44
|
this.baseUrl = null;
|
56
45
|
this.pdfDocument = null;
|
57
46
|
this.pdfViewer = null;
|
@@ -59,311 +48,290 @@ function () {
|
|
59
48
|
this._pagesRefCache = null;
|
60
49
|
}
|
61
50
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
this.pdfDocument = pdfDocument;
|
68
|
-
this._pagesRefCache = Object.create(null);
|
69
|
-
}
|
70
|
-
}, {
|
71
|
-
key: "setViewer",
|
72
|
-
value: function setViewer(pdfViewer) {
|
73
|
-
this.pdfViewer = pdfViewer;
|
74
|
-
}
|
75
|
-
}, {
|
76
|
-
key: "setHistory",
|
77
|
-
value: function setHistory(pdfHistory) {
|
78
|
-
this.pdfHistory = pdfHistory;
|
79
|
-
}
|
80
|
-
}, {
|
81
|
-
key: "navigateTo",
|
82
|
-
value: function navigateTo(dest) {
|
83
|
-
var _this = this;
|
84
|
-
|
85
|
-
var goToDestination = function goToDestination(_ref2) {
|
86
|
-
var namedDest = _ref2.namedDest,
|
87
|
-
explicitDest = _ref2.explicitDest;
|
88
|
-
var destRef = explicitDest[0],
|
89
|
-
pageNumber;
|
90
|
-
|
91
|
-
if (destRef instanceof Object) {
|
92
|
-
pageNumber = _this._cachedPageNumber(destRef);
|
93
|
-
|
94
|
-
if (pageNumber === null) {
|
95
|
-
_this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
|
96
|
-
_this.cachePageRef(pageIndex + 1, destRef);
|
97
|
-
|
98
|
-
goToDestination({
|
99
|
-
namedDest: namedDest,
|
100
|
-
explicitDest: explicitDest
|
101
|
-
});
|
102
|
-
}).catch(function () {
|
103
|
-
console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
|
104
|
-
});
|
51
|
+
setDocument(pdfDocument, baseUrl = null) {
|
52
|
+
this.baseUrl = baseUrl;
|
53
|
+
this.pdfDocument = pdfDocument;
|
54
|
+
this._pagesRefCache = Object.create(null);
|
55
|
+
}
|
105
56
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
pageNumber = destRef + 1;
|
110
|
-
} else {
|
111
|
-
console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
|
112
|
-
return;
|
113
|
-
}
|
57
|
+
setViewer(pdfViewer) {
|
58
|
+
this.pdfViewer = pdfViewer;
|
59
|
+
}
|
114
60
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
}
|
61
|
+
setHistory(pdfHistory) {
|
62
|
+
this.pdfHistory = pdfHistory;
|
63
|
+
}
|
119
64
|
|
120
|
-
|
121
|
-
|
65
|
+
get pagesCount() {
|
66
|
+
return this.pdfDocument ? this.pdfDocument.numPages : 0;
|
67
|
+
}
|
122
68
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
pageNumber: pageNumber
|
127
|
-
});
|
128
|
-
}
|
69
|
+
get page() {
|
70
|
+
return this.pdfViewer.currentPageNumber;
|
71
|
+
}
|
129
72
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
73
|
+
set page(value) {
|
74
|
+
this.pdfViewer.currentPageNumber = value;
|
75
|
+
}
|
76
|
+
|
77
|
+
get rotation() {
|
78
|
+
return this.pdfViewer.pagesRotation;
|
79
|
+
}
|
80
|
+
|
81
|
+
set rotation(value) {
|
82
|
+
this.pdfViewer.pagesRotation = value;
|
83
|
+
}
|
84
|
+
|
85
|
+
navigateTo(dest) {
|
86
|
+
const goToDestination = ({
|
87
|
+
namedDest,
|
88
|
+
explicitDest
|
89
|
+
}) => {
|
90
|
+
const destRef = explicitDest[0];
|
91
|
+
let pageNumber;
|
92
|
+
|
93
|
+
if (destRef instanceof Object) {
|
94
|
+
pageNumber = this._cachedPageNumber(destRef);
|
95
|
+
|
96
|
+
if (pageNumber === null) {
|
97
|
+
this.pdfDocument.getPageIndex(destRef).then(pageIndex => {
|
98
|
+
this.cachePageRef(pageIndex + 1, destRef);
|
99
|
+
goToDestination({
|
100
|
+
namedDest,
|
101
|
+
explicitDest
|
142
102
|
});
|
103
|
+
}).catch(() => {
|
104
|
+
console.error(`PDFLinkService.navigateTo: "${destRef}" is not ` + `a valid page reference, for dest="${dest}".`);
|
143
105
|
});
|
144
|
-
|
145
106
|
return;
|
146
107
|
}
|
108
|
+
} else if (Number.isInteger(destRef)) {
|
109
|
+
pageNumber = destRef + 1;
|
110
|
+
} else {
|
111
|
+
console.error(`PDFLinkService.navigateTo: "${destRef}" is not ` + `a valid destination reference, for dest="${dest}".`);
|
112
|
+
return;
|
113
|
+
}
|
147
114
|
|
148
|
-
|
149
|
-
|
150
|
-
|
115
|
+
if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
|
116
|
+
console.error(`PDFLinkService.navigateTo: "${pageNumber}" is not ` + `a valid page number, for dest="${dest}".`);
|
117
|
+
return;
|
118
|
+
}
|
119
|
+
|
120
|
+
if (this.pdfHistory) {
|
121
|
+
this.pdfHistory.pushCurrentPosition();
|
122
|
+
this.pdfHistory.push({
|
123
|
+
namedDest,
|
124
|
+
explicitDest,
|
125
|
+
pageNumber
|
151
126
|
});
|
152
|
-
}
|
153
|
-
if (!Array.isArray(data.explicitDest)) {
|
154
|
-
console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
|
155
|
-
return;
|
156
|
-
}
|
127
|
+
}
|
157
128
|
|
158
|
-
|
129
|
+
this.pdfViewer.scrollPageIntoView({
|
130
|
+
pageNumber,
|
131
|
+
destArray: explicitDest,
|
132
|
+
ignoreDestinationZoom: this._ignoreDestinationZoom
|
159
133
|
});
|
160
|
-
}
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
134
|
+
};
|
135
|
+
|
136
|
+
new Promise((resolve, reject) => {
|
137
|
+
if (typeof dest === "string") {
|
138
|
+
this.pdfDocument.getDestination(dest).then(destArray => {
|
139
|
+
resolve({
|
140
|
+
namedDest: dest,
|
141
|
+
explicitDest: destArray
|
142
|
+
});
|
143
|
+
});
|
144
|
+
return;
|
166
145
|
}
|
167
146
|
|
168
|
-
|
169
|
-
|
170
|
-
|
147
|
+
resolve({
|
148
|
+
namedDest: "",
|
149
|
+
explicitDest: dest
|
150
|
+
});
|
151
|
+
}).then(data => {
|
152
|
+
if (!Array.isArray(data.explicitDest)) {
|
153
|
+
console.error(`PDFLinkService.navigateTo: "${data.explicitDest}" is` + ` not a valid destination array, for dest="${dest}".`);
|
154
|
+
return;
|
171
155
|
}
|
172
156
|
|
173
|
-
|
157
|
+
goToDestination(data);
|
158
|
+
});
|
159
|
+
}
|
160
|
+
|
161
|
+
getDestinationHash(dest) {
|
162
|
+
if (typeof dest === "string") {
|
163
|
+
return this.getAnchorUrl("#" + escape(dest));
|
174
164
|
}
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
return
|
165
|
+
|
166
|
+
if (Array.isArray(dest)) {
|
167
|
+
const str = JSON.stringify(dest);
|
168
|
+
return this.getAnchorUrl("#" + escape(str));
|
179
169
|
}
|
180
|
-
}, {
|
181
|
-
key: "setHash",
|
182
|
-
value: function setHash(hash) {
|
183
|
-
var pageNumber, dest;
|
184
|
-
|
185
|
-
if (hash.includes('=')) {
|
186
|
-
var params = (0, _ui_utils.parseQueryString)(hash);
|
187
|
-
|
188
|
-
if ('search' in params) {
|
189
|
-
this.eventBus.dispatch('findfromurlhash', {
|
190
|
-
source: this,
|
191
|
-
query: params['search'].replace(/"/g, ''),
|
192
|
-
phraseSearch: params['phrase'] === 'true'
|
193
|
-
});
|
194
|
-
}
|
195
170
|
|
196
|
-
|
197
|
-
|
198
|
-
return;
|
199
|
-
}
|
171
|
+
return this.getAnchorUrl("");
|
172
|
+
}
|
200
173
|
|
201
|
-
|
202
|
-
|
203
|
-
|
174
|
+
getAnchorUrl(anchor) {
|
175
|
+
return (this.baseUrl || "") + anchor;
|
176
|
+
}
|
177
|
+
|
178
|
+
setHash(hash) {
|
179
|
+
let pageNumber, dest;
|
204
180
|
|
205
|
-
|
206
|
-
|
207
|
-
var zoomArg = zoomArgs[0];
|
208
|
-
var zoomArgNumber = parseFloat(zoomArg);
|
181
|
+
if (hash.includes("=")) {
|
182
|
+
const params = (0, _ui_utils.parseQueryString)(hash);
|
209
183
|
|
210
|
-
|
184
|
+
if ("search" in params) {
|
185
|
+
this.eventBus.dispatch("findfromurlhash", {
|
186
|
+
source: this,
|
187
|
+
query: params.search.replace(/"/g, ""),
|
188
|
+
phraseSearch: params.phrase === "true"
|
189
|
+
});
|
190
|
+
}
|
191
|
+
|
192
|
+
if ("page" in params) {
|
193
|
+
pageNumber = params.page | 0 || 1;
|
194
|
+
}
|
195
|
+
|
196
|
+
if ("zoom" in params) {
|
197
|
+
const zoomArgs = params.zoom.split(",");
|
198
|
+
const zoomArg = zoomArgs[0];
|
199
|
+
const zoomArgNumber = parseFloat(zoomArg);
|
200
|
+
|
201
|
+
if (!zoomArg.includes("Fit")) {
|
202
|
+
dest = [null, {
|
203
|
+
name: "XYZ"
|
204
|
+
}, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
|
205
|
+
} else {
|
206
|
+
if (zoomArg === "Fit" || zoomArg === "FitB") {
|
211
207
|
dest = [null, {
|
212
|
-
name:
|
213
|
-
}
|
214
|
-
} else {
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
208
|
+
name: zoomArg
|
209
|
+
}];
|
210
|
+
} else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
|
211
|
+
dest = [null, {
|
212
|
+
name: zoomArg
|
213
|
+
}, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
|
214
|
+
} else if (zoomArg === "FitR") {
|
215
|
+
if (zoomArgs.length !== 5) {
|
216
|
+
console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
|
217
|
+
} else {
|
220
218
|
dest = [null, {
|
221
219
|
name: zoomArg
|
222
|
-
}, zoomArgs
|
223
|
-
} else if (zoomArg === 'FitR') {
|
224
|
-
if (zoomArgs.length !== 5) {
|
225
|
-
console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
|
226
|
-
} else {
|
227
|
-
dest = [null, {
|
228
|
-
name: zoomArg
|
229
|
-
}, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
|
230
|
-
}
|
231
|
-
} else {
|
232
|
-
console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + 'a valid zoom value.');
|
220
|
+
}, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
|
233
221
|
}
|
222
|
+
} else {
|
223
|
+
console.error(`PDFLinkService.setHash: "${zoomArg}" is not ` + "a valid zoom value.");
|
234
224
|
}
|
235
225
|
}
|
226
|
+
}
|
236
227
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
228
|
+
if (dest) {
|
229
|
+
this.pdfViewer.scrollPageIntoView({
|
230
|
+
pageNumber: pageNumber || this.page,
|
231
|
+
destArray: dest,
|
232
|
+
allowNegativeOffset: true
|
233
|
+
});
|
234
|
+
} else if (pageNumber) {
|
235
|
+
this.page = pageNumber;
|
236
|
+
}
|
246
237
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
} else {
|
254
|
-
dest = unescape(hash);
|
238
|
+
if ("pagemode" in params) {
|
239
|
+
this.eventBus.dispatch("pagemode", {
|
240
|
+
source: this,
|
241
|
+
mode: params.pagemode
|
242
|
+
});
|
243
|
+
}
|
255
244
|
|
256
|
-
|
257
|
-
|
245
|
+
if ("nameddest" in params) {
|
246
|
+
this.navigateTo(params.nameddest);
|
247
|
+
}
|
248
|
+
} else {
|
249
|
+
dest = unescape(hash);
|
258
250
|
|
259
|
-
|
260
|
-
|
261
|
-
}
|
262
|
-
} catch (ex) {}
|
251
|
+
try {
|
252
|
+
dest = JSON.parse(dest);
|
263
253
|
|
264
|
-
if (
|
265
|
-
|
266
|
-
return;
|
254
|
+
if (!Array.isArray(dest)) {
|
255
|
+
dest = dest.toString();
|
267
256
|
}
|
257
|
+
} catch (ex) {}
|
268
258
|
|
269
|
-
|
259
|
+
if (typeof dest === "string" || isValidExplicitDestination(dest)) {
|
260
|
+
this.navigateTo(dest);
|
261
|
+
return;
|
270
262
|
}
|
263
|
+
|
264
|
+
console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not ` + "a valid destination.");
|
271
265
|
}
|
272
|
-
}
|
273
|
-
key: "executeNamedAction",
|
274
|
-
value: function executeNamedAction(action) {
|
275
|
-
switch (action) {
|
276
|
-
case 'GoBack':
|
277
|
-
if (this.pdfHistory) {
|
278
|
-
this.pdfHistory.back();
|
279
|
-
}
|
266
|
+
}
|
280
267
|
|
281
|
-
|
268
|
+
executeNamedAction(action) {
|
269
|
+
switch (action) {
|
270
|
+
case "GoBack":
|
271
|
+
if (this.pdfHistory) {
|
272
|
+
this.pdfHistory.back();
|
273
|
+
}
|
282
274
|
|
283
|
-
|
284
|
-
if (this.pdfHistory) {
|
285
|
-
this.pdfHistory.forward();
|
286
|
-
}
|
275
|
+
break;
|
287
276
|
|
288
|
-
|
277
|
+
case "GoForward":
|
278
|
+
if (this.pdfHistory) {
|
279
|
+
this.pdfHistory.forward();
|
280
|
+
}
|
289
281
|
|
290
|
-
|
291
|
-
if (this.page < this.pagesCount) {
|
292
|
-
this.page++;
|
293
|
-
}
|
282
|
+
break;
|
294
283
|
|
295
|
-
|
284
|
+
case "NextPage":
|
285
|
+
if (this.page < this.pagesCount) {
|
286
|
+
this.page++;
|
287
|
+
}
|
296
288
|
|
297
|
-
|
298
|
-
if (this.page > 1) {
|
299
|
-
this.page--;
|
300
|
-
}
|
289
|
+
break;
|
301
290
|
|
302
|
-
|
291
|
+
case "PrevPage":
|
292
|
+
if (this.page > 1) {
|
293
|
+
this.page--;
|
294
|
+
}
|
303
295
|
|
304
|
-
|
305
|
-
this.page = this.pagesCount;
|
306
|
-
break;
|
296
|
+
break;
|
307
297
|
|
308
|
-
|
309
|
-
|
310
|
-
|
298
|
+
case "LastPage":
|
299
|
+
this.page = this.pagesCount;
|
300
|
+
break;
|
311
301
|
|
312
|
-
|
313
|
-
|
314
|
-
|
302
|
+
case "FirstPage":
|
303
|
+
this.page = 1;
|
304
|
+
break;
|
315
305
|
|
316
|
-
|
317
|
-
|
318
|
-
action: action
|
319
|
-
});
|
306
|
+
default:
|
307
|
+
break;
|
320
308
|
}
|
321
|
-
}, {
|
322
|
-
key: "cachePageRef",
|
323
|
-
value: function cachePageRef(pageNum, pageRef) {
|
324
|
-
if (!pageRef) {
|
325
|
-
return;
|
326
|
-
}
|
327
309
|
|
328
|
-
|
329
|
-
this
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
}, {
|
338
|
-
key: "isPageVisible",
|
339
|
-
value: function isPageVisible(pageNumber) {
|
340
|
-
return this.pdfViewer.isPageVisible(pageNumber);
|
341
|
-
}
|
342
|
-
}, {
|
343
|
-
key: "pagesCount",
|
344
|
-
get: function get() {
|
345
|
-
return this.pdfDocument ? this.pdfDocument.numPages : 0;
|
346
|
-
}
|
347
|
-
}, {
|
348
|
-
key: "page",
|
349
|
-
get: function get() {
|
350
|
-
return this.pdfViewer.currentPageNumber;
|
351
|
-
},
|
352
|
-
set: function set(value) {
|
353
|
-
this.pdfViewer.currentPageNumber = value;
|
354
|
-
}
|
355
|
-
}, {
|
356
|
-
key: "rotation",
|
357
|
-
get: function get() {
|
358
|
-
return this.pdfViewer.pagesRotation;
|
359
|
-
},
|
360
|
-
set: function set(value) {
|
361
|
-
this.pdfViewer.pagesRotation = value;
|
310
|
+
this.eventBus.dispatch("namedaction", {
|
311
|
+
source: this,
|
312
|
+
action
|
313
|
+
});
|
314
|
+
}
|
315
|
+
|
316
|
+
cachePageRef(pageNum, pageRef) {
|
317
|
+
if (!pageRef) {
|
318
|
+
return;
|
362
319
|
}
|
363
|
-
}]);
|
364
320
|
|
365
|
-
|
366
|
-
|
321
|
+
const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
|
322
|
+
this._pagesRefCache[refStr] = pageNum;
|
323
|
+
}
|
324
|
+
|
325
|
+
_cachedPageNumber(pageRef) {
|
326
|
+
const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
|
327
|
+
return this._pagesRefCache && this._pagesRefCache[refStr] || null;
|
328
|
+
}
|
329
|
+
|
330
|
+
isPageVisible(pageNumber) {
|
331
|
+
return this.pdfViewer.isPageVisible(pageNumber);
|
332
|
+
}
|
333
|
+
|
334
|
+
}
|
367
335
|
|
368
336
|
exports.PDFLinkService = PDFLinkService;
|
369
337
|
|
@@ -372,48 +340,49 @@ function isValidExplicitDestination(dest) {
|
|
372
340
|
return false;
|
373
341
|
}
|
374
342
|
|
375
|
-
|
376
|
-
allowNull = true;
|
343
|
+
const destLength = dest.length;
|
377
344
|
|
378
345
|
if (destLength < 2) {
|
379
346
|
return false;
|
380
347
|
}
|
381
348
|
|
382
|
-
|
349
|
+
const page = dest[0];
|
383
350
|
|
384
|
-
if (!(
|
351
|
+
if (!(typeof page === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
|
385
352
|
return false;
|
386
353
|
}
|
387
354
|
|
388
|
-
|
355
|
+
const zoom = dest[1];
|
389
356
|
|
390
|
-
if (!(
|
357
|
+
if (!(typeof zoom === "object" && typeof zoom.name === "string")) {
|
391
358
|
return false;
|
392
359
|
}
|
393
360
|
|
361
|
+
let allowNull = true;
|
362
|
+
|
394
363
|
switch (zoom.name) {
|
395
|
-
case
|
364
|
+
case "XYZ":
|
396
365
|
if (destLength !== 5) {
|
397
366
|
return false;
|
398
367
|
}
|
399
368
|
|
400
369
|
break;
|
401
370
|
|
402
|
-
case
|
403
|
-
case
|
371
|
+
case "Fit":
|
372
|
+
case "FitB":
|
404
373
|
return destLength === 2;
|
405
374
|
|
406
|
-
case
|
407
|
-
case
|
408
|
-
case
|
409
|
-
case
|
375
|
+
case "FitH":
|
376
|
+
case "FitBH":
|
377
|
+
case "FitV":
|
378
|
+
case "FitBV":
|
410
379
|
if (destLength !== 3) {
|
411
380
|
return false;
|
412
381
|
}
|
413
382
|
|
414
383
|
break;
|
415
384
|
|
416
|
-
case
|
385
|
+
case "FitR":
|
417
386
|
if (destLength !== 6) {
|
418
387
|
return false;
|
419
388
|
}
|
@@ -425,10 +394,10 @@ function isValidExplicitDestination(dest) {
|
|
425
394
|
return false;
|
426
395
|
}
|
427
396
|
|
428
|
-
for (
|
429
|
-
|
397
|
+
for (let i = 2; i < destLength; i++) {
|
398
|
+
const param = dest[i];
|
430
399
|
|
431
|
-
if (!(typeof param ===
|
400
|
+
if (!(typeof param === "number" || allowNull && param === null)) {
|
432
401
|
return false;
|
433
402
|
}
|
434
403
|
}
|
@@ -436,63 +405,50 @@ function isValidExplicitDestination(dest) {
|
|
436
405
|
return true;
|
437
406
|
}
|
438
407
|
|
439
|
-
|
440
|
-
|
441
|
-
function () {
|
442
|
-
function SimpleLinkService() {
|
443
|
-
_classCallCheck(this, SimpleLinkService);
|
444
|
-
|
408
|
+
class SimpleLinkService {
|
409
|
+
constructor() {
|
445
410
|
this.externalLinkTarget = null;
|
446
411
|
this.externalLinkRel = null;
|
412
|
+
this.externalLinkEnabled = true;
|
413
|
+
this._ignoreDestinationZoom = false;
|
447
414
|
}
|
448
415
|
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
set: function set(value) {}
|
487
|
-
}, {
|
488
|
-
key: "rotation",
|
489
|
-
get: function get() {
|
490
|
-
return 0;
|
491
|
-
},
|
492
|
-
set: function set(value) {}
|
493
|
-
}]);
|
494
|
-
|
495
|
-
return SimpleLinkService;
|
496
|
-
}();
|
416
|
+
get pagesCount() {
|
417
|
+
return 0;
|
418
|
+
}
|
419
|
+
|
420
|
+
get page() {
|
421
|
+
return 0;
|
422
|
+
}
|
423
|
+
|
424
|
+
set page(value) {}
|
425
|
+
|
426
|
+
get rotation() {
|
427
|
+
return 0;
|
428
|
+
}
|
429
|
+
|
430
|
+
set rotation(value) {}
|
431
|
+
|
432
|
+
navigateTo(dest) {}
|
433
|
+
|
434
|
+
getDestinationHash(dest) {
|
435
|
+
return "#";
|
436
|
+
}
|
437
|
+
|
438
|
+
getAnchorUrl(hash) {
|
439
|
+
return "#";
|
440
|
+
}
|
441
|
+
|
442
|
+
setHash(hash) {}
|
443
|
+
|
444
|
+
executeNamedAction(action) {}
|
445
|
+
|
446
|
+
cachePageRef(pageNum, pageRef) {}
|
447
|
+
|
448
|
+
isPageVisible(pageNumber) {
|
449
|
+
return true;
|
450
|
+
}
|
451
|
+
|
452
|
+
}
|
497
453
|
|
498
454
|
exports.SimpleLinkService = SimpleLinkService;
|