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