pdfjs-dist 2.0.489 → 2.2.228
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/CODE_OF_CONDUCT.md +15 -0
- package/bower.json +1 -1
- package/build/pdf.js +18515 -11402
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +48266 -37137
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/external/url/url-lib.js +627 -0
- package/image_decoders/pdf.image_decoders.js +11350 -0
- package/image_decoders/pdf.image_decoders.js.map +1 -0
- package/image_decoders/pdf.image_decoders.min.js +1 -0
- package/lib/core/annotation.js +587 -242
- package/lib/core/arithmetic_decoder.js +275 -245
- package/lib/core/bidi.js +65 -6
- package/lib/core/ccitt.js +173 -18
- package/lib/core/ccitt_stream.js +15 -6
- package/lib/core/cff_parser.js +433 -61
- package/lib/core/charsets.js +5 -4
- package/lib/core/chunked_stream.js +400 -152
- package/lib/core/cmap.js +326 -87
- package/lib/core/colorspace.js +874 -594
- package/lib/core/core_utils.js +147 -0
- package/lib/core/crypto.js +290 -45
- package/lib/core/document.js +560 -268
- package/lib/core/encodings.js +19 -10
- package/lib/core/evaluator.js +1005 -360
- package/lib/core/font_renderer.js +331 -97
- package/lib/core/fonts.js +812 -195
- package/lib/core/function.js +284 -71
- package/lib/core/glyphlist.js +4 -3
- package/lib/core/image.js +169 -62
- package/lib/core/image_utils.js +111 -0
- package/lib/core/jbig2.js +479 -66
- package/lib/core/jbig2_stream.js +19 -8
- package/lib/core/jpeg_stream.js +38 -13
- package/lib/core/jpg.js +253 -29
- package/lib/core/jpx.js +396 -6
- package/lib/core/jpx_stream.js +18 -6
- package/lib/core/metrics.js +15 -15
- package/lib/core/murmurhash3.js +56 -34
- package/lib/core/obj.js +1354 -488
- package/lib/core/operator_list.js +144 -31
- package/lib/core/parser.js +539 -191
- package/lib/core/pattern.js +148 -14
- package/lib/core/pdf_manager.js +323 -133
- package/lib/core/primitives.js +111 -24
- package/lib/core/ps_parser.js +134 -45
- package/lib/core/standard_fonts.js +17 -17
- package/lib/core/stream.js +313 -34
- package/lib/core/type1_parser.js +143 -13
- package/lib/core/unicode.js +32 -5
- package/lib/core/worker.js +217 -190
- package/lib/core/worker_stream.js +277 -0
- package/lib/display/annotation_layer.js +450 -133
- package/lib/display/api.js +1597 -784
- package/lib/display/api_compatibility.js +11 -13
- package/lib/display/canvas.js +360 -44
- package/lib/display/content_disposition.js +83 -32
- package/lib/display/display_utils.js +747 -0
- package/lib/display/fetch_stream.js +221 -90
- package/lib/display/font_loader.js +468 -236
- package/lib/display/metadata.js +38 -16
- package/lib/display/network.js +635 -428
- package/lib/display/network_utils.js +32 -19
- package/lib/display/node_stream.js +367 -175
- package/lib/display/pattern_helper.js +81 -31
- package/lib/display/svg.js +1235 -519
- package/lib/display/text_layer.js +153 -29
- package/lib/display/transport_stream.js +345 -94
- package/lib/display/webgl.js +64 -18
- package/lib/display/worker_options.js +5 -4
- package/lib/display/xml_parser.js +166 -53
- package/lib/examples/node/domstubs.js +60 -4
- package/lib/pdf.js +36 -14
- package/lib/pdf.worker.js +5 -3
- package/lib/shared/compatibility.js +158 -564
- package/lib/shared/global_scope.js +2 -2
- package/lib/shared/is_node.js +4 -4
- package/lib/shared/message_handler.js +521 -0
- package/lib/shared/streams_polyfill.js +21 -17
- package/lib/shared/url_polyfill.js +56 -0
- package/lib/shared/util.js +243 -710
- package/lib/test/unit/annotation_spec.js +870 -401
- package/lib/test/unit/api_spec.js +657 -345
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +54 -11
- package/lib/test/unit/clitests_helper.js +10 -8
- package/lib/test/unit/cmap_spec.js +95 -41
- package/lib/test/unit/colorspace_spec.js +115 -63
- package/lib/test/unit/core_utils_spec.js +191 -0
- package/lib/test/unit/crypto_spec.js +17 -5
- package/lib/test/unit/custom_spec.js +43 -55
- package/lib/test/unit/display_svg_spec.js +34 -18
- package/lib/test/unit/display_utils_spec.js +273 -0
- package/lib/test/unit/document_spec.js +8 -13
- package/lib/test/unit/encodings_spec.js +25 -45
- package/lib/test/unit/evaluator_spec.js +38 -15
- package/lib/test/unit/fetch_stream_spec.js +109 -0
- package/lib/test/unit/function_spec.js +17 -5
- package/lib/test/unit/jasmine-boot.js +33 -20
- package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
- package/lib/test/unit/metadata_spec.js +71 -11
- package/lib/test/unit/murmurhash3_spec.js +3 -3
- package/lib/test/unit/network_spec.js +19 -54
- package/lib/test/unit/network_utils_spec.js +91 -14
- package/lib/test/unit/node_stream_spec.js +56 -32
- package/lib/test/unit/parser_spec.js +162 -71
- package/lib/test/unit/pdf_find_controller_spec.js +230 -0
- package/lib/test/unit/pdf_find_utils_spec.js +63 -0
- package/lib/test/unit/pdf_history_spec.js +21 -9
- package/lib/test/unit/primitives_spec.js +53 -20
- package/lib/test/unit/stream_spec.js +12 -4
- package/lib/test/unit/test_utils.js +273 -56
- package/lib/test/unit/testreporter.js +21 -3
- package/lib/test/unit/type1_parser_spec.js +8 -6
- package/lib/test/unit/ui_utils_spec.js +454 -16
- package/lib/test/unit/unicode_spec.js +18 -15
- package/lib/test/unit/util_spec.js +87 -128
- package/lib/web/annotation_layer_builder.js +39 -22
- package/lib/web/app.js +1290 -588
- package/lib/web/app_options.js +100 -62
- package/lib/web/base_viewer.js +511 -182
- package/lib/web/chromecom.js +261 -117
- package/lib/web/debugger.js +166 -22
- package/lib/web/download_manager.js +32 -13
- package/lib/web/firefox_print_service.js +20 -10
- package/lib/web/firefoxcom.js +315 -80
- package/lib/web/genericcom.js +89 -30
- package/lib/web/genericl10n.js +142 -30
- package/lib/web/grab_to_pan.js +28 -4
- package/lib/web/interfaces.js +170 -47
- package/lib/web/overlay_manager.js +235 -85
- package/lib/web/password_prompt.js +22 -14
- package/lib/web/pdf_attachment_viewer.js +38 -18
- package/lib/web/pdf_cursor_tools.js +39 -16
- package/lib/web/pdf_document_properties.js +255 -136
- package/lib/web/pdf_find_bar.js +84 -40
- package/lib/web/pdf_find_controller.js +495 -184
- package/lib/web/pdf_find_utils.js +111 -0
- package/lib/web/pdf_history.js +190 -53
- package/lib/web/pdf_link_service.js +138 -77
- package/lib/web/pdf_outline_viewer.js +122 -46
- package/lib/web/pdf_page_view.js +191 -67
- package/lib/web/pdf_presentation_mode.js +99 -34
- package/lib/web/pdf_print_service.js +61 -13
- package/lib/web/pdf_rendering_queue.js +28 -9
- package/lib/web/pdf_sidebar.js +141 -81
- package/lib/web/pdf_sidebar_resizer.js +42 -16
- package/lib/web/pdf_single_page_viewer.js +74 -66
- package/lib/web/pdf_thumbnail_view.js +104 -33
- package/lib/web/pdf_thumbnail_viewer.js +66 -26
- package/lib/web/pdf_viewer.component.js +112 -32
- package/lib/web/pdf_viewer.js +91 -52
- package/lib/web/preferences.js +284 -89
- package/lib/web/secondary_toolbar.js +165 -40
- package/lib/web/text_layer_builder.js +134 -59
- package/lib/web/toolbar.js +78 -43
- package/lib/web/ui_utils.js +462 -136
- package/lib/web/view_history.js +215 -67
- package/lib/web/viewer_compatibility.js +4 -13
- package/package.json +5 -4
- package/web/pdf_viewer.css +79 -11
- package/web/pdf_viewer.js +6107 -3748
- package/web/pdf_viewer.js.map +1 -1
- package/lib/display/dom_utils.js +0 -309
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/test/unit/fonts_spec.js +0 -81
- package/lib/web/dom_events.js +0 -137
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2019 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,31 +19,35 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.PDFThumbnailViewer =
|
27
|
+
exports.PDFThumbnailViewer = void 0;
|
28
28
|
|
29
|
-
var
|
29
|
+
var _ui_utils = require("./ui_utils");
|
30
30
|
|
31
|
-
var
|
32
|
-
|
33
|
-
var _pdf_thumbnail_view = require('./pdf_thumbnail_view');
|
31
|
+
var _pdf_thumbnail_view = require("./pdf_thumbnail_view");
|
34
32
|
|
35
33
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
36
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
|
+
|
37
39
|
var THUMBNAIL_SCROLL_MARGIN = -19;
|
38
40
|
var THUMBNAIL_SELECTED_CLASS = 'selected';
|
39
41
|
|
40
|
-
var PDFThumbnailViewer =
|
42
|
+
var PDFThumbnailViewer =
|
43
|
+
/*#__PURE__*/
|
44
|
+
function () {
|
41
45
|
function PDFThumbnailViewer(_ref) {
|
42
46
|
var container = _ref.container,
|
43
47
|
linkService = _ref.linkService,
|
44
48
|
renderingQueue = _ref.renderingQueue,
|
45
49
|
_ref$l10n = _ref.l10n,
|
46
|
-
l10n = _ref$l10n ===
|
50
|
+
l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
|
47
51
|
|
48
52
|
_classCallCheck(this, PDFThumbnailViewer);
|
49
53
|
|
@@ -52,46 +56,54 @@ var PDFThumbnailViewer = function () {
|
|
52
56
|
this.renderingQueue = renderingQueue;
|
53
57
|
this.l10n = l10n;
|
54
58
|
this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
|
59
|
+
|
55
60
|
this._resetView();
|
56
61
|
}
|
57
62
|
|
58
63
|
_createClass(PDFThumbnailViewer, [{
|
59
|
-
key:
|
64
|
+
key: "_scrollUpdated",
|
60
65
|
value: function _scrollUpdated() {
|
61
66
|
this.renderingQueue.renderHighestPriority();
|
62
67
|
}
|
63
68
|
}, {
|
64
|
-
key:
|
69
|
+
key: "getThumbnail",
|
65
70
|
value: function getThumbnail(index) {
|
66
71
|
return this._thumbnails[index];
|
67
72
|
}
|
68
73
|
}, {
|
69
|
-
key:
|
74
|
+
key: "_getVisibleThumbs",
|
70
75
|
value: function _getVisibleThumbs() {
|
71
76
|
return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
|
72
77
|
}
|
73
78
|
}, {
|
74
|
-
key:
|
79
|
+
key: "scrollThumbnailIntoView",
|
75
80
|
value: function scrollThumbnailIntoView(pageNumber) {
|
76
81
|
if (!this.pdfDocument) {
|
77
82
|
return;
|
78
83
|
}
|
84
|
+
|
79
85
|
var thumbnailView = this._thumbnails[pageNumber - 1];
|
86
|
+
|
80
87
|
if (!thumbnailView) {
|
81
88
|
console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
|
82
89
|
return;
|
83
90
|
}
|
91
|
+
|
84
92
|
if (pageNumber !== this._currentPageNumber) {
|
85
93
|
var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
|
86
94
|
prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
|
87
95
|
thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
|
88
96
|
}
|
97
|
+
|
89
98
|
var visibleThumbs = this._getVisibleThumbs();
|
99
|
+
|
90
100
|
var numVisibleThumbs = visibleThumbs.views.length;
|
101
|
+
|
91
102
|
if (numVisibleThumbs > 0) {
|
92
103
|
var first = visibleThumbs.first.id;
|
93
104
|
var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
|
94
105
|
var shouldScroll = false;
|
106
|
+
|
95
107
|
if (pageNumber <= first || pageNumber >= last) {
|
96
108
|
shouldScroll = true;
|
97
109
|
} else {
|
@@ -99,23 +111,28 @@ var PDFThumbnailViewer = function () {
|
|
99
111
|
if (view.id !== pageNumber) {
|
100
112
|
return false;
|
101
113
|
}
|
114
|
+
|
102
115
|
shouldScroll = view.percent < 100;
|
103
116
|
return true;
|
104
117
|
});
|
105
118
|
}
|
119
|
+
|
106
120
|
if (shouldScroll) {
|
107
|
-
(0, _ui_utils.scrollIntoView)(thumbnailView.div, {
|
121
|
+
(0, _ui_utils.scrollIntoView)(thumbnailView.div, {
|
122
|
+
top: THUMBNAIL_SCROLL_MARGIN
|
123
|
+
});
|
108
124
|
}
|
109
125
|
}
|
126
|
+
|
110
127
|
this._currentPageNumber = pageNumber;
|
111
128
|
}
|
112
129
|
}, {
|
113
|
-
key:
|
130
|
+
key: "cleanup",
|
114
131
|
value: function cleanup() {
|
115
132
|
_pdf_thumbnail_view.PDFThumbnailView.cleanup();
|
116
133
|
}
|
117
134
|
}, {
|
118
|
-
key:
|
135
|
+
key: "_resetView",
|
119
136
|
value: function _resetView() {
|
120
137
|
this._thumbnails = [];
|
121
138
|
this._currentPageNumber = 1;
|
@@ -125,21 +142,28 @@ var PDFThumbnailViewer = function () {
|
|
125
142
|
this.container.textContent = '';
|
126
143
|
}
|
127
144
|
}, {
|
128
|
-
key:
|
145
|
+
key: "setDocument",
|
129
146
|
value: function setDocument(pdfDocument) {
|
130
147
|
var _this = this;
|
131
148
|
|
132
149
|
if (this.pdfDocument) {
|
133
150
|
this._cancelRendering();
|
151
|
+
|
134
152
|
this._resetView();
|
135
153
|
}
|
154
|
+
|
136
155
|
this.pdfDocument = pdfDocument;
|
156
|
+
|
137
157
|
if (!pdfDocument) {
|
138
158
|
return;
|
139
159
|
}
|
160
|
+
|
140
161
|
pdfDocument.getPage(1).then(function (firstPage) {
|
141
162
|
var pagesCount = pdfDocument.numPages;
|
142
|
-
var viewport = firstPage.getViewport(
|
163
|
+
var viewport = firstPage.getViewport({
|
164
|
+
scale: 1
|
165
|
+
});
|
166
|
+
|
143
167
|
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
144
168
|
var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
|
145
169
|
container: _this.container,
|
@@ -150,16 +174,18 @@ var PDFThumbnailViewer = function () {
|
|
150
174
|
disableCanvasToImageConversion: false,
|
151
175
|
l10n: _this.l10n
|
152
176
|
});
|
177
|
+
|
153
178
|
_this._thumbnails.push(thumbnail);
|
154
179
|
}
|
180
|
+
|
155
181
|
var thumbnailView = _this._thumbnails[_this._currentPageNumber - 1];
|
156
182
|
thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
|
157
|
-
})
|
183
|
+
})["catch"](function (reason) {
|
158
184
|
console.error('Unable to initialize thumbnail viewer', reason);
|
159
185
|
});
|
160
186
|
}
|
161
187
|
}, {
|
162
|
-
key:
|
188
|
+
key: "_cancelRendering",
|
163
189
|
value: function _cancelRendering() {
|
164
190
|
for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
|
165
191
|
if (this._thumbnails[i]) {
|
@@ -168,41 +194,47 @@ var PDFThumbnailViewer = function () {
|
|
168
194
|
}
|
169
195
|
}
|
170
196
|
}, {
|
171
|
-
key:
|
197
|
+
key: "setPageLabels",
|
172
198
|
value: function setPageLabels(labels) {
|
173
199
|
if (!this.pdfDocument) {
|
174
200
|
return;
|
175
201
|
}
|
202
|
+
|
176
203
|
if (!labels) {
|
177
204
|
this._pageLabels = null;
|
178
|
-
} else if (!(labels
|
205
|
+
} else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
|
179
206
|
this._pageLabels = null;
|
180
207
|
console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.');
|
181
208
|
} else {
|
182
209
|
this._pageLabels = labels;
|
183
210
|
}
|
211
|
+
|
184
212
|
for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
|
185
213
|
var label = this._pageLabels && this._pageLabels[i];
|
214
|
+
|
186
215
|
this._thumbnails[i].setPageLabel(label);
|
187
216
|
}
|
188
217
|
}
|
189
218
|
}, {
|
190
|
-
key:
|
219
|
+
key: "_ensurePdfPageLoaded",
|
191
220
|
value: function _ensurePdfPageLoaded(thumbView) {
|
192
221
|
var _this2 = this;
|
193
222
|
|
194
223
|
if (thumbView.pdfPage) {
|
195
224
|
return Promise.resolve(thumbView.pdfPage);
|
196
225
|
}
|
226
|
+
|
197
227
|
var pageNumber = thumbView.id;
|
228
|
+
|
198
229
|
if (this._pagesRequests[pageNumber]) {
|
199
230
|
return this._pagesRequests[pageNumber];
|
200
231
|
}
|
232
|
+
|
201
233
|
var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
|
202
234
|
thumbView.setPdfPage(pdfPage);
|
203
235
|
_this2._pagesRequests[pageNumber] = null;
|
204
236
|
return pdfPage;
|
205
|
-
})
|
237
|
+
})["catch"](function (reason) {
|
206
238
|
console.error('Unable to get page for thumb view', reason);
|
207
239
|
_this2._pagesRequests[pageNumber] = null;
|
208
240
|
});
|
@@ -210,22 +242,26 @@ var PDFThumbnailViewer = function () {
|
|
210
242
|
return promise;
|
211
243
|
}
|
212
244
|
}, {
|
213
|
-
key:
|
245
|
+
key: "forceRendering",
|
214
246
|
value: function forceRendering() {
|
215
247
|
var _this3 = this;
|
216
248
|
|
217
249
|
var visibleThumbs = this._getVisibleThumbs();
|
250
|
+
|
218
251
|
var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
|
252
|
+
|
219
253
|
if (thumbView) {
|
220
254
|
this._ensurePdfPageLoaded(thumbView).then(function () {
|
221
255
|
_this3.renderingQueue.renderView(thumbView);
|
222
256
|
});
|
257
|
+
|
223
258
|
return true;
|
224
259
|
}
|
260
|
+
|
225
261
|
return false;
|
226
262
|
}
|
227
263
|
}, {
|
228
|
-
key:
|
264
|
+
key: "pagesRotation",
|
229
265
|
get: function get() {
|
230
266
|
return this._pagesRotation;
|
231
267
|
},
|
@@ -233,13 +269,17 @@ var PDFThumbnailViewer = function () {
|
|
233
269
|
if (!(0, _ui_utils.isValidRotation)(rotation)) {
|
234
270
|
throw new Error('Invalid thumbnails rotation angle.');
|
235
271
|
}
|
272
|
+
|
236
273
|
if (!this.pdfDocument) {
|
237
274
|
return;
|
238
275
|
}
|
276
|
+
|
239
277
|
if (this._pagesRotation === rotation) {
|
240
278
|
return;
|
241
279
|
}
|
280
|
+
|
242
281
|
this._pagesRotation = rotation;
|
282
|
+
|
243
283
|
for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
|
244
284
|
this._thumbnails[i].update(rotation);
|
245
285
|
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2019 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,50 +19,130 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
|
27
|
+
Object.defineProperty(exports, "AnnotationLayerBuilder", {
|
28
|
+
enumerable: true,
|
29
|
+
get: function get() {
|
30
|
+
return _annotation_layer_builder.AnnotationLayerBuilder;
|
31
|
+
}
|
32
|
+
});
|
33
|
+
Object.defineProperty(exports, "DefaultAnnotationLayerFactory", {
|
34
|
+
enumerable: true,
|
35
|
+
get: function get() {
|
36
|
+
return _annotation_layer_builder.DefaultAnnotationLayerFactory;
|
37
|
+
}
|
38
|
+
});
|
39
|
+
Object.defineProperty(exports, "DefaultTextLayerFactory", {
|
40
|
+
enumerable: true,
|
41
|
+
get: function get() {
|
42
|
+
return _text_layer_builder.DefaultTextLayerFactory;
|
43
|
+
}
|
44
|
+
});
|
45
|
+
Object.defineProperty(exports, "TextLayerBuilder", {
|
46
|
+
enumerable: true,
|
47
|
+
get: function get() {
|
48
|
+
return _text_layer_builder.TextLayerBuilder;
|
49
|
+
}
|
50
|
+
});
|
51
|
+
Object.defineProperty(exports, "EventBus", {
|
52
|
+
enumerable: true,
|
53
|
+
get: function get() {
|
54
|
+
return _ui_utils.EventBus;
|
55
|
+
}
|
56
|
+
});
|
57
|
+
Object.defineProperty(exports, "NullL10n", {
|
58
|
+
enumerable: true,
|
59
|
+
get: function get() {
|
60
|
+
return _ui_utils.NullL10n;
|
61
|
+
}
|
62
|
+
});
|
63
|
+
Object.defineProperty(exports, "ProgressBar", {
|
64
|
+
enumerable: true,
|
65
|
+
get: function get() {
|
66
|
+
return _ui_utils.ProgressBar;
|
67
|
+
}
|
68
|
+
});
|
69
|
+
Object.defineProperty(exports, "PDFLinkService", {
|
70
|
+
enumerable: true,
|
71
|
+
get: function get() {
|
72
|
+
return _pdf_link_service.PDFLinkService;
|
73
|
+
}
|
74
|
+
});
|
75
|
+
Object.defineProperty(exports, "SimpleLinkService", {
|
76
|
+
enumerable: true,
|
77
|
+
get: function get() {
|
78
|
+
return _pdf_link_service.SimpleLinkService;
|
79
|
+
}
|
80
|
+
});
|
81
|
+
Object.defineProperty(exports, "DownloadManager", {
|
82
|
+
enumerable: true,
|
83
|
+
get: function get() {
|
84
|
+
return _download_manager.DownloadManager;
|
85
|
+
}
|
86
|
+
});
|
87
|
+
Object.defineProperty(exports, "GenericL10n", {
|
88
|
+
enumerable: true,
|
89
|
+
get: function get() {
|
90
|
+
return _genericl10n.GenericL10n;
|
91
|
+
}
|
92
|
+
});
|
93
|
+
Object.defineProperty(exports, "PDFFindController", {
|
94
|
+
enumerable: true,
|
95
|
+
get: function get() {
|
96
|
+
return _pdf_find_controller.PDFFindController;
|
97
|
+
}
|
98
|
+
});
|
99
|
+
Object.defineProperty(exports, "PDFHistory", {
|
100
|
+
enumerable: true,
|
101
|
+
get: function get() {
|
102
|
+
return _pdf_history.PDFHistory;
|
103
|
+
}
|
104
|
+
});
|
105
|
+
Object.defineProperty(exports, "PDFPageView", {
|
106
|
+
enumerable: true,
|
107
|
+
get: function get() {
|
108
|
+
return _pdf_page_view.PDFPageView;
|
109
|
+
}
|
110
|
+
});
|
111
|
+
Object.defineProperty(exports, "PDFSinglePageViewer", {
|
112
|
+
enumerable: true,
|
113
|
+
get: function get() {
|
114
|
+
return _pdf_single_page_viewer.PDFSinglePageViewer;
|
115
|
+
}
|
116
|
+
});
|
117
|
+
Object.defineProperty(exports, "PDFViewer", {
|
118
|
+
enumerable: true,
|
119
|
+
get: function get() {
|
120
|
+
return _pdf_viewer.PDFViewer;
|
121
|
+
}
|
122
|
+
});
|
28
123
|
|
29
|
-
var _annotation_layer_builder = require(
|
124
|
+
var _annotation_layer_builder = require("./annotation_layer_builder.js");
|
30
125
|
|
31
|
-
var _text_layer_builder = require(
|
126
|
+
var _text_layer_builder = require("./text_layer_builder.js");
|
32
127
|
|
33
|
-
var _ui_utils = require(
|
128
|
+
var _ui_utils = require("./ui_utils.js");
|
34
129
|
|
35
|
-
var _pdf_link_service = require(
|
130
|
+
var _pdf_link_service = require("./pdf_link_service.js");
|
36
131
|
|
37
|
-
var _download_manager = require(
|
132
|
+
var _download_manager = require("./download_manager.js");
|
38
133
|
|
39
|
-
var _genericl10n = require(
|
134
|
+
var _genericl10n = require("./genericl10n.js");
|
40
135
|
|
41
|
-
var _pdf_find_controller = require(
|
136
|
+
var _pdf_find_controller = require("./pdf_find_controller.js");
|
42
137
|
|
43
|
-
var _pdf_history = require(
|
138
|
+
var _pdf_history = require("./pdf_history.js");
|
44
139
|
|
45
|
-
var _pdf_page_view = require(
|
140
|
+
var _pdf_page_view = require("./pdf_page_view.js");
|
46
141
|
|
47
|
-
var _pdf_single_page_viewer = require(
|
142
|
+
var _pdf_single_page_viewer = require("./pdf_single_page_viewer");
|
48
143
|
|
49
|
-
var _pdf_viewer = require(
|
144
|
+
var _pdf_viewer = require("./pdf_viewer.js");
|
50
145
|
|
51
|
-
var pdfjsVersion = '2.
|
52
|
-
var pdfjsBuild = '
|
53
|
-
|
54
|
-
exports.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer;
|
55
|
-
exports.PDFPageView = _pdf_page_view.PDFPageView;
|
56
|
-
exports.PDFLinkService = _pdf_link_service.PDFLinkService;
|
57
|
-
exports.SimpleLinkService = _pdf_link_service.SimpleLinkService;
|
58
|
-
exports.TextLayerBuilder = _text_layer_builder.TextLayerBuilder;
|
59
|
-
exports.DefaultTextLayerFactory = _text_layer_builder.DefaultTextLayerFactory;
|
60
|
-
exports.AnnotationLayerBuilder = _annotation_layer_builder.AnnotationLayerBuilder;
|
61
|
-
exports.DefaultAnnotationLayerFactory = _annotation_layer_builder.DefaultAnnotationLayerFactory;
|
62
|
-
exports.PDFHistory = _pdf_history.PDFHistory;
|
63
|
-
exports.PDFFindController = _pdf_find_controller.PDFFindController;
|
64
|
-
exports.EventBus = _ui_utils.EventBus;
|
65
|
-
exports.DownloadManager = _download_manager.DownloadManager;
|
66
|
-
exports.ProgressBar = _ui_utils.ProgressBar;
|
67
|
-
exports.GenericL10n = _genericl10n.GenericL10n;
|
68
|
-
exports.NullL10n = _ui_utils.NullL10n;
|
146
|
+
var pdfjsVersion = '2.2.228';
|
147
|
+
var pdfjsBuild = 'd7afb74a';
|
148
|
+
(0, _ui_utils.getGlobalEventBus)(true);
|
package/lib/web/pdf_viewer.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2019 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,99 +19,138 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.PDFViewer =
|
27
|
+
exports.PDFViewer = void 0;
|
28
28
|
|
29
|
-
var
|
29
|
+
var _base_viewer = require("./base_viewer");
|
30
30
|
|
31
|
-
var
|
31
|
+
var _pdf = require("../pdf");
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
var _pdf = require('../pdf');
|
33
|
+
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); }
|
36
34
|
|
37
35
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
38
36
|
|
39
|
-
function
|
37
|
+
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); } }
|
38
|
+
|
39
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
40
|
+
|
41
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
42
|
+
|
43
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
44
|
+
|
45
|
+
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
|
46
|
+
|
47
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
40
48
|
|
41
|
-
function
|
49
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
42
50
|
|
43
|
-
|
51
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
52
|
+
|
53
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
54
|
+
|
55
|
+
var PDFViewer =
|
56
|
+
/*#__PURE__*/
|
57
|
+
function (_BaseViewer) {
|
44
58
|
_inherits(PDFViewer, _BaseViewer);
|
45
59
|
|
46
60
|
function PDFViewer() {
|
47
61
|
_classCallCheck(this, PDFViewer);
|
48
62
|
|
49
|
-
return _possibleConstructorReturn(this, (PDFViewer
|
63
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(PDFViewer).apply(this, arguments));
|
50
64
|
}
|
51
65
|
|
52
66
|
_createClass(PDFViewer, [{
|
53
|
-
key:
|
67
|
+
key: "_scrollIntoView",
|
54
68
|
value: function _scrollIntoView(_ref) {
|
55
69
|
var pageDiv = _ref.pageDiv,
|
56
70
|
_ref$pageSpot = _ref.pageSpot,
|
57
|
-
pageSpot = _ref$pageSpot ===
|
71
|
+
pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
|
72
|
+
_ref$pageNumber = _ref.pageNumber,
|
73
|
+
pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
|
74
|
+
|
75
|
+
if (!pageSpot && !this.isInPresentationMode) {
|
76
|
+
var left = pageDiv.offsetLeft + pageDiv.clientLeft;
|
77
|
+
var right = left + pageDiv.clientWidth;
|
78
|
+
var _this$container = this.container,
|
79
|
+
scrollLeft = _this$container.scrollLeft,
|
80
|
+
clientWidth = _this$container.clientWidth;
|
81
|
+
|
82
|
+
if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
|
83
|
+
pageSpot = {
|
84
|
+
left: 0,
|
85
|
+
top: 0
|
86
|
+
};
|
87
|
+
}
|
88
|
+
}
|
58
89
|
|
59
|
-
(
|
90
|
+
_get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
|
91
|
+
pageDiv: pageDiv,
|
92
|
+
pageSpot: pageSpot,
|
93
|
+
pageNumber: pageNumber
|
94
|
+
});
|
60
95
|
}
|
61
96
|
}, {
|
62
|
-
key:
|
97
|
+
key: "_getVisiblePages",
|
63
98
|
value: function _getVisiblePages() {
|
64
|
-
if (
|
65
|
-
return
|
99
|
+
if (this.isInPresentationMode) {
|
100
|
+
return this._getCurrentVisiblePage();
|
66
101
|
}
|
67
|
-
|
68
|
-
|
69
|
-
id: currentPage.id,
|
70
|
-
view: currentPage
|
71
|
-
}];
|
72
|
-
return {
|
73
|
-
first: currentPage,
|
74
|
-
last: currentPage,
|
75
|
-
views: visible
|
76
|
-
};
|
102
|
+
|
103
|
+
return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
|
77
104
|
}
|
78
105
|
}, {
|
79
|
-
key:
|
80
|
-
value: function
|
81
|
-
|
82
|
-
var visiblePages = visible.views,
|
83
|
-
numVisiblePages = visiblePages.length;
|
84
|
-
if (numVisiblePages === 0) {
|
106
|
+
key: "_updateHelper",
|
107
|
+
value: function _updateHelper(visiblePages) {
|
108
|
+
if (this.isInPresentationMode) {
|
85
109
|
return;
|
86
110
|
}
|
87
|
-
|
88
|
-
this.renderingQueue.renderHighestPriority(visible);
|
111
|
+
|
89
112
|
var currentId = this._currentPageNumber;
|
90
113
|
var stillFullyVisible = false;
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
114
|
+
var _iteratorNormalCompletion = true;
|
115
|
+
var _didIteratorError = false;
|
116
|
+
var _iteratorError = undefined;
|
117
|
+
|
118
|
+
try {
|
119
|
+
for (var _iterator = visiblePages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
120
|
+
var page = _step.value;
|
121
|
+
|
122
|
+
if (page.percent < 100) {
|
123
|
+
break;
|
124
|
+
}
|
125
|
+
|
126
|
+
if (page.id === currentId) {
|
127
|
+
stillFullyVisible = true;
|
128
|
+
break;
|
129
|
+
}
|
95
130
|
}
|
96
|
-
|
97
|
-
|
98
|
-
|
131
|
+
} catch (err) {
|
132
|
+
_didIteratorError = true;
|
133
|
+
_iteratorError = err;
|
134
|
+
} finally {
|
135
|
+
try {
|
136
|
+
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
|
137
|
+
_iterator["return"]();
|
138
|
+
}
|
139
|
+
} finally {
|
140
|
+
if (_didIteratorError) {
|
141
|
+
throw _iteratorError;
|
142
|
+
}
|
99
143
|
}
|
100
144
|
}
|
145
|
+
|
101
146
|
if (!stillFullyVisible) {
|
102
147
|
currentId = visiblePages[0].id;
|
103
148
|
}
|
104
|
-
|
105
|
-
|
106
|
-
}
|
107
|
-
this._updateLocation(visible.first);
|
108
|
-
this.eventBus.dispatch('updateviewarea', {
|
109
|
-
source: this,
|
110
|
-
location: this._location
|
111
|
-
});
|
149
|
+
|
150
|
+
this._setCurrentPageNumber(currentId);
|
112
151
|
}
|
113
152
|
}, {
|
114
|
-
key:
|
153
|
+
key: "_setDocumentViewerElement",
|
115
154
|
get: function get() {
|
116
155
|
return (0, _pdf.shadow)(this, '_setDocumentViewerElement', this.viewer);
|
117
156
|
}
|