pdfjs-dist 2.0.487 → 2.1.266
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/bower.json +1 -1
- package/build/pdf.js +15564 -9476
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +46644 -36309
- 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 +11430 -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 +406 -131
- 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 +376 -53
- package/lib/core/charsets.js +5 -4
- package/lib/core/chunked_stream.js +387 -149
- package/lib/core/cmap.js +310 -75
- package/lib/core/colorspace.js +874 -594
- package/lib/core/crypto.js +290 -45
- package/lib/core/document.js +545 -260
- package/lib/core/encodings.js +19 -10
- package/lib/core/evaluator.js +725 -147
- package/lib/core/font_renderer.js +360 -91
- package/lib/core/fonts.js +791 -186
- package/lib/core/function.js +284 -71
- package/lib/core/glyphlist.js +3 -2
- package/lib/core/image.js +168 -61
- 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 +252 -29
- package/lib/core/jpx.js +396 -6
- package/lib/core/jpx_stream.js +18 -6
- package/lib/core/metrics.js +4 -4
- package/lib/core/murmurhash3.js +24 -6
- package/lib/core/obj.js +1137 -475
- package/lib/core/operator_list.js +108 -6
- package/lib/core/parser.js +321 -68
- package/lib/core/pattern.js +145 -13
- package/lib/core/pdf_manager.js +321 -133
- package/lib/core/primitives.js +75 -22
- package/lib/core/ps_parser.js +134 -45
- package/lib/core/standard_fonts.js +10 -10
- package/lib/core/stream.js +313 -34
- package/lib/core/type1_parser.js +143 -13
- package/lib/core/unicode.js +31 -4
- package/lib/core/worker.js +210 -66
- package/lib/display/annotation_layer.js +361 -123
- package/lib/display/api.js +1454 -729
- package/lib/display/api_compatibility.js +11 -13
- package/lib/display/canvas.js +324 -29
- package/lib/display/content_disposition.js +83 -32
- package/lib/display/dom_utils.js +226 -41
- package/lib/display/fetch_stream.js +208 -84
- package/lib/display/font_loader.js +465 -236
- package/lib/display/metadata.js +38 -16
- package/lib/display/network.js +216 -51
- package/lib/display/network_utils.js +32 -19
- package/lib/display/node_stream.js +352 -169
- package/lib/display/pattern_helper.js +58 -7
- package/lib/display/svg.js +242 -29
- package/lib/display/text_layer.js +132 -18
- package/lib/display/transport_stream.js +171 -42
- 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 +57 -4
- package/lib/pdf.js +21 -4
- 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 +295 -650
- package/lib/test/unit/annotation_spec.js +629 -345
- package/lib/test/unit/api_spec.js +555 -253
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +40 -11
- package/lib/test/unit/clitests_helper.js +9 -7
- package/lib/test/unit/cmap_spec.js +80 -26
- package/lib/test/unit/colorspace_spec.js +99 -52
- package/lib/test/unit/crypto_spec.js +17 -5
- package/lib/test/unit/custom_spec.js +41 -53
- package/lib/test/unit/display_svg_spec.js +33 -17
- package/lib/test/unit/document_spec.js +3 -3
- package/lib/test/unit/dom_utils_spec.js +9 -9
- package/lib/test/unit/encodings_spec.js +25 -45
- package/lib/test/unit/evaluator_spec.js +34 -9
- package/lib/test/unit/function_spec.js +17 -5
- package/lib/test/unit/jasmine-boot.js +31 -18
- 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 +20 -5
- package/lib/test/unit/network_utils_spec.js +41 -14
- package/lib/test/unit/node_stream_spec.js +51 -27
- package/lib/test/unit/parser_spec.js +35 -8
- 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 +24 -4
- package/lib/test/unit/stream_spec.js +12 -4
- package/lib/test/unit/test_utils.js +90 -27
- 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 +452 -14
- package/lib/test/unit/unicode_spec.js +14 -11
- package/lib/test/unit/util_spec.js +131 -9
- package/lib/web/annotation_layer_builder.js +39 -22
- package/lib/web/app.js +1240 -582
- package/lib/web/app_options.js +71 -41
- package/lib/web/base_viewer.js +508 -179
- package/lib/web/chromecom.js +261 -117
- package/lib/web/debugger.js +166 -22
- package/lib/web/download_manager.js +31 -13
- package/lib/web/firefox_print_service.js +17 -9
- package/lib/web/firefoxcom.js +283 -79
- package/lib/web/genericcom.js +89 -30
- package/lib/web/genericl10n.js +142 -30
- package/lib/web/grab_to_pan.js +26 -4
- package/lib/web/interfaces.js +170 -47
- package/lib/web/overlay_manager.js +235 -85
- package/lib/web/password_prompt.js +21 -13
- 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 +80 -30
- 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 +137 -76
- package/lib/web/pdf_outline_viewer.js +73 -22
- package/lib/web/pdf_page_view.js +196 -63
- package/lib/web/pdf_presentation_mode.js +99 -34
- package/lib/web/pdf_print_service.js +57 -11
- package/lib/web/pdf_rendering_queue.js +27 -5
- package/lib/web/pdf_sidebar.js +120 -67
- 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 +103 -32
- package/lib/web/pdf_thumbnail_viewer.js +64 -24
- package/lib/web/pdf_viewer.component.js +112 -32
- package/lib/web/pdf_viewer.js +91 -52
- package/lib/web/preferences.js +275 -80
- package/lib/web/secondary_toolbar.js +165 -40
- package/lib/web/text_layer_builder.js +162 -65
- 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 +58 -1
- package/web/pdf_viewer.js +6346 -3919
- package/web/pdf_viewer.js.map +1 -1
- package/lib/test/unit/fonts_spec.js +0 -81
- package/lib/web/dom_events.js +0 -137
package/lib/display/api.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 2018 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,104 +19,166 @@
|
|
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.
|
28
|
-
|
29
|
-
|
27
|
+
exports.getDocument = getDocument;
|
28
|
+
exports.setPDFNetworkStreamFactory = setPDFNetworkStreamFactory;
|
29
|
+
exports.build = exports.version = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFWorker = exports.PDFDataRangeTransport = exports.LoopbackPort = void 0;
|
30
30
|
|
31
|
-
var
|
31
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
32
32
|
|
33
|
-
var _util = require(
|
33
|
+
var _util = require("../shared/util");
|
34
34
|
|
35
|
-
var _dom_utils = require(
|
35
|
+
var _dom_utils = require("./dom_utils");
|
36
36
|
|
37
|
-
var _font_loader = require(
|
37
|
+
var _font_loader = require("./font_loader");
|
38
38
|
|
39
|
-
var _api_compatibility = require(
|
39
|
+
var _api_compatibility = require("./api_compatibility");
|
40
40
|
|
41
|
-
var _canvas = require(
|
41
|
+
var _canvas = require("./canvas");
|
42
42
|
|
43
|
-
var _global_scope = require(
|
43
|
+
var _global_scope = _interopRequireDefault(require("../shared/global_scope"));
|
44
44
|
|
45
|
-
var
|
45
|
+
var _worker_options = require("./worker_options");
|
46
46
|
|
47
|
-
var
|
47
|
+
var _message_handler = require("../shared/message_handler");
|
48
48
|
|
49
|
-
var _metadata = require(
|
49
|
+
var _metadata = require("./metadata");
|
50
50
|
|
51
|
-
var _transport_stream = require(
|
51
|
+
var _transport_stream = require("./transport_stream");
|
52
52
|
|
53
|
-
var _webgl = require(
|
53
|
+
var _webgl = require("./webgl");
|
54
54
|
|
55
55
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
56
56
|
|
57
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
58
|
+
|
59
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
60
|
+
|
61
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
62
|
+
|
63
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
64
|
+
|
65
|
+
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
66
|
+
|
67
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
68
|
+
|
69
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
70
|
+
|
71
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
72
|
+
|
73
|
+
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
74
|
+
|
75
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
76
|
+
|
57
77
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
58
78
|
|
79
|
+
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); } }
|
80
|
+
|
81
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
82
|
+
|
83
|
+
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); }
|
84
|
+
|
59
85
|
var DEFAULT_RANGE_CHUNK_SIZE = 65536;
|
60
86
|
var isWorkerDisabled = false;
|
61
|
-
var
|
62
|
-
var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
|
87
|
+
var fallbackWorkerSrc;
|
63
88
|
var fakeWorkerFilesLoader = null;
|
64
|
-
var useRequireEnsure = false;
|
65
89
|
{
|
90
|
+
var useRequireEnsure = false;
|
91
|
+
|
66
92
|
if (typeof window === 'undefined') {
|
67
93
|
isWorkerDisabled = true;
|
94
|
+
|
68
95
|
if (typeof require.ensure === 'undefined') {
|
69
96
|
require.ensure = require('node-ensure');
|
70
97
|
}
|
98
|
+
|
71
99
|
useRequireEnsure = true;
|
72
100
|
} else if (typeof require !== 'undefined' && typeof require.ensure === 'function') {
|
73
101
|
useRequireEnsure = true;
|
74
102
|
}
|
103
|
+
|
75
104
|
if (typeof requirejs !== 'undefined' && requirejs.toUrl) {
|
76
|
-
|
105
|
+
fallbackWorkerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js');
|
77
106
|
}
|
107
|
+
|
78
108
|
var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load;
|
79
|
-
fakeWorkerFilesLoader = useRequireEnsure ? function (
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
109
|
+
fakeWorkerFilesLoader = useRequireEnsure ? function () {
|
110
|
+
return new Promise(function (resolve, reject) {
|
111
|
+
require.ensure([], function () {
|
112
|
+
try {
|
113
|
+
var worker;
|
114
|
+
worker = require('../pdf.worker.js');
|
115
|
+
resolve(worker.WorkerMessageHandler);
|
116
|
+
} catch (ex) {
|
117
|
+
reject(ex);
|
118
|
+
}
|
119
|
+
}, reject, 'pdfjsWorker');
|
84
120
|
});
|
85
|
-
} : dynamicLoaderSupported ? function (
|
86
|
-
|
87
|
-
|
121
|
+
} : dynamicLoaderSupported ? function () {
|
122
|
+
return new Promise(function (resolve, reject) {
|
123
|
+
requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) {
|
124
|
+
try {
|
125
|
+
resolve(worker.WorkerMessageHandler);
|
126
|
+
} catch (ex) {
|
127
|
+
reject(ex);
|
128
|
+
}
|
129
|
+
}, reject);
|
88
130
|
});
|
89
131
|
} : null;
|
132
|
+
|
133
|
+
if (!fallbackWorkerSrc && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object' && 'currentScript' in document) {
|
134
|
+
var pdfjsFilePath = document.currentScript && document.currentScript.src;
|
135
|
+
|
136
|
+
if (pdfjsFilePath) {
|
137
|
+
fallbackWorkerSrc = pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, '.worker$1$2');
|
138
|
+
}
|
139
|
+
}
|
90
140
|
}
|
91
141
|
var createPDFNetworkStream;
|
142
|
+
|
92
143
|
function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
|
93
144
|
createPDFNetworkStream = pdfNetworkStreamFactory;
|
94
145
|
}
|
146
|
+
|
95
147
|
function getDocument(src) {
|
96
148
|
var task = new PDFDocumentLoadingTask();
|
97
149
|
var source;
|
150
|
+
|
98
151
|
if (typeof src === 'string') {
|
99
|
-
source = {
|
152
|
+
source = {
|
153
|
+
url: src
|
154
|
+
};
|
100
155
|
} else if ((0, _util.isArrayBuffer)(src)) {
|
101
|
-
source = {
|
156
|
+
source = {
|
157
|
+
data: src
|
158
|
+
};
|
102
159
|
} else if (src instanceof PDFDataRangeTransport) {
|
103
|
-
source = {
|
160
|
+
source = {
|
161
|
+
range: src
|
162
|
+
};
|
104
163
|
} else {
|
105
|
-
if (
|
164
|
+
if (_typeof(src) !== 'object') {
|
106
165
|
throw new Error('Invalid parameter in getDocument, ' + 'need either Uint8Array, string or a parameter object');
|
107
166
|
}
|
167
|
+
|
108
168
|
if (!src.url && !src.data && !src.range) {
|
109
169
|
throw new Error('Invalid parameter object: need either .data, .range or .url');
|
110
170
|
}
|
171
|
+
|
111
172
|
source = src;
|
112
173
|
}
|
174
|
+
|
113
175
|
var params = Object.create(null);
|
114
|
-
var rangeTransport = null
|
115
|
-
|
116
|
-
|
176
|
+
var rangeTransport = null,
|
177
|
+
worker = null;
|
178
|
+
|
117
179
|
for (var key in source) {
|
118
180
|
if (key === 'url' && typeof window !== 'undefined') {
|
119
|
-
params[key] = new URL(source[key], window.location).href;
|
181
|
+
params[key] = new _util.URL(source[key], window.location).href;
|
120
182
|
continue;
|
121
183
|
} else if (key === 'range') {
|
122
184
|
rangeTransport = source[key];
|
@@ -126,75 +188,86 @@ function getDocument(src) {
|
|
126
188
|
continue;
|
127
189
|
} else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
|
128
190
|
var pdfBytes = source[key];
|
191
|
+
|
129
192
|
if (typeof pdfBytes === 'string') {
|
130
193
|
params[key] = (0, _util.stringToBytes)(pdfBytes);
|
131
|
-
} else if (
|
194
|
+
} else if (_typeof(pdfBytes) === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
|
132
195
|
params[key] = new Uint8Array(pdfBytes);
|
133
196
|
} else if ((0, _util.isArrayBuffer)(pdfBytes)) {
|
134
197
|
params[key] = new Uint8Array(pdfBytes);
|
135
198
|
} else {
|
136
199
|
throw new Error('Invalid PDF binary data: either typed array, ' + 'string or array-like object is expected in the ' + 'data property.');
|
137
200
|
}
|
138
|
-
|
139
|
-
} else if (key === 'CMapReaderFactory') {
|
140
|
-
CMapReaderFactory = source[key];
|
201
|
+
|
141
202
|
continue;
|
142
203
|
}
|
204
|
+
|
143
205
|
params[key] = source[key];
|
144
206
|
}
|
207
|
+
|
145
208
|
params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
|
209
|
+
params.CMapReaderFactory = params.CMapReaderFactory || _dom_utils.DOMCMapReaderFactory;
|
146
210
|
params.ignoreErrors = params.stopAtErrors !== true;
|
147
211
|
params.pdfBug = params.pdfBug === true;
|
148
212
|
var NativeImageDecoderValues = Object.values(_util.NativeImageDecoding);
|
213
|
+
|
149
214
|
if (params.nativeImageDecoderSupport === undefined || !NativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) {
|
150
|
-
params.nativeImageDecoderSupport = _util.NativeImageDecoding.DECODE;
|
215
|
+
params.nativeImageDecoderSupport = _api_compatibility.apiCompatibilityParams.nativeImageDecoderSupport || _util.NativeImageDecoding.DECODE;
|
151
216
|
}
|
217
|
+
|
152
218
|
if (!Number.isInteger(params.maxImageSize)) {
|
153
219
|
params.maxImageSize = -1;
|
154
220
|
}
|
221
|
+
|
155
222
|
if (typeof params.isEvalSupported !== 'boolean') {
|
156
223
|
params.isEvalSupported = true;
|
157
224
|
}
|
225
|
+
|
158
226
|
if (typeof params.disableFontFace !== 'boolean') {
|
159
|
-
params.disableFontFace = false;
|
227
|
+
params.disableFontFace = _api_compatibility.apiCompatibilityParams.disableFontFace || false;
|
160
228
|
}
|
229
|
+
|
161
230
|
if (typeof params.disableRange !== 'boolean') {
|
162
|
-
params.disableRange =
|
231
|
+
params.disableRange = false;
|
163
232
|
}
|
233
|
+
|
164
234
|
if (typeof params.disableStream !== 'boolean') {
|
165
|
-
params.disableStream =
|
235
|
+
params.disableStream = false;
|
166
236
|
}
|
237
|
+
|
167
238
|
if (typeof params.disableAutoFetch !== 'boolean') {
|
168
239
|
params.disableAutoFetch = false;
|
169
240
|
}
|
241
|
+
|
170
242
|
if (typeof params.disableCreateObjectURL !== 'boolean') {
|
171
243
|
params.disableCreateObjectURL = _api_compatibility.apiCompatibilityParams.disableCreateObjectURL || false;
|
172
244
|
}
|
245
|
+
|
173
246
|
(0, _util.setVerbosityLevel)(params.verbosity);
|
247
|
+
|
174
248
|
if (!worker) {
|
175
249
|
var workerParams = {
|
176
250
|
postMessageTransfers: params.postMessageTransfers,
|
177
|
-
verbosity: params.verbosity
|
251
|
+
verbosity: params.verbosity,
|
252
|
+
port: _worker_options.GlobalWorkerOptions.workerPort
|
178
253
|
};
|
179
|
-
|
180
|
-
if (workerPort) {
|
181
|
-
workerParams.port = workerPort;
|
182
|
-
worker = PDFWorker.fromPort(workerParams);
|
183
|
-
} else {
|
184
|
-
worker = new PDFWorker(workerParams);
|
185
|
-
}
|
254
|
+
worker = workerParams.port ? PDFWorker.fromPort(workerParams) : new PDFWorker(workerParams);
|
186
255
|
task._worker = worker;
|
187
256
|
}
|
257
|
+
|
188
258
|
var docId = task.docId;
|
189
259
|
worker.promise.then(function () {
|
190
260
|
if (task.destroyed) {
|
191
261
|
throw new Error('Loading aborted');
|
192
262
|
}
|
263
|
+
|
193
264
|
return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
|
194
265
|
if (task.destroyed) {
|
195
266
|
throw new Error('Loading aborted');
|
196
267
|
}
|
197
|
-
|
268
|
+
|
269
|
+
var networkStream;
|
270
|
+
|
198
271
|
if (rangeTransport) {
|
199
272
|
networkStream = new _transport_stream.PDFDataTransportStream({
|
200
273
|
length: params.length,
|
@@ -213,26 +286,30 @@ function getDocument(src) {
|
|
213
286
|
disableStream: params.disableStream
|
214
287
|
});
|
215
288
|
}
|
216
|
-
|
289
|
+
|
290
|
+
var messageHandler = new _message_handler.MessageHandler(docId, workerId, worker.port);
|
217
291
|
messageHandler.postMessageTransfers = worker.postMessageTransfers;
|
218
|
-
var transport = new WorkerTransport(messageHandler, task, networkStream, params
|
292
|
+
var transport = new WorkerTransport(messageHandler, task, networkStream, params);
|
219
293
|
task._transport = transport;
|
220
294
|
messageHandler.send('Ready', null);
|
221
295
|
});
|
222
296
|
}).catch(task._capability.reject);
|
223
297
|
return task;
|
224
298
|
}
|
299
|
+
|
225
300
|
function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
226
301
|
if (worker.destroyed) {
|
227
302
|
return Promise.reject(new Error('Worker was destroyed'));
|
228
303
|
}
|
304
|
+
|
229
305
|
if (pdfDataRangeTransport) {
|
230
306
|
source.length = pdfDataRangeTransport.length;
|
231
307
|
source.initialData = pdfDataRangeTransport.initialData;
|
232
308
|
}
|
309
|
+
|
233
310
|
return worker.messageHandler.sendWithPromise('GetDocRequest', {
|
234
311
|
docId: docId,
|
235
|
-
apiVersion: '2.
|
312
|
+
apiVersion: '2.1.266',
|
236
313
|
source: {
|
237
314
|
data: source.data,
|
238
315
|
url: source.url,
|
@@ -253,47 +330,72 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|
253
330
|
if (worker.destroyed) {
|
254
331
|
throw new Error('Worker was destroyed');
|
255
332
|
}
|
333
|
+
|
256
334
|
return workerId;
|
257
335
|
});
|
258
336
|
}
|
337
|
+
|
259
338
|
var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
|
260
339
|
var nextDocumentId = 0;
|
261
|
-
function PDFDocumentLoadingTask() {
|
262
|
-
this._capability = (0, _util.createPromiseCapability)();
|
263
|
-
this._transport = null;
|
264
|
-
this._worker = null;
|
265
|
-
this.docId = 'd' + nextDocumentId++;
|
266
|
-
this.destroyed = false;
|
267
|
-
this.onPassword = null;
|
268
|
-
this.onProgress = null;
|
269
|
-
this.onUnsupportedFeature = null;
|
270
|
-
}
|
271
|
-
PDFDocumentLoadingTask.prototype = {
|
272
|
-
get promise() {
|
273
|
-
return this._capability.promise;
|
274
|
-
},
|
275
|
-
destroy: function destroy() {
|
276
|
-
var _this = this;
|
277
340
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
_this._worker.destroy();
|
284
|
-
_this._worker = null;
|
285
|
-
}
|
286
|
-
});
|
287
|
-
},
|
341
|
+
var PDFDocumentLoadingTask =
|
342
|
+
/*#__PURE__*/
|
343
|
+
function () {
|
344
|
+
function PDFDocumentLoadingTask() {
|
345
|
+
_classCallCheck(this, PDFDocumentLoadingTask);
|
288
346
|
|
289
|
-
|
290
|
-
|
347
|
+
this._capability = (0, _util.createPromiseCapability)();
|
348
|
+
this._transport = null;
|
349
|
+
this._worker = null;
|
350
|
+
this.docId = 'd' + nextDocumentId++;
|
351
|
+
this.destroyed = false;
|
352
|
+
this.onPassword = null;
|
353
|
+
this.onProgress = null;
|
354
|
+
this.onUnsupportedFeature = null;
|
291
355
|
}
|
292
|
-
|
356
|
+
|
357
|
+
_createClass(PDFDocumentLoadingTask, [{
|
358
|
+
key: "destroy",
|
359
|
+
value: function destroy() {
|
360
|
+
var _this = this;
|
361
|
+
|
362
|
+
this.destroyed = true;
|
363
|
+
var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
|
364
|
+
return transportDestroyed.then(function () {
|
365
|
+
_this._transport = null;
|
366
|
+
|
367
|
+
if (_this._worker) {
|
368
|
+
_this._worker.destroy();
|
369
|
+
|
370
|
+
_this._worker = null;
|
371
|
+
}
|
372
|
+
});
|
373
|
+
}
|
374
|
+
}, {
|
375
|
+
key: "then",
|
376
|
+
value: function then(onFulfilled, onRejected) {
|
377
|
+
(0, _util.deprecated)('PDFDocumentLoadingTask.then method, ' + 'use the `promise` getter instead.');
|
378
|
+
return this.promise.then.apply(this.promise, arguments);
|
379
|
+
}
|
380
|
+
}, {
|
381
|
+
key: "promise",
|
382
|
+
get: function get() {
|
383
|
+
return this._capability.promise;
|
384
|
+
}
|
385
|
+
}]);
|
386
|
+
|
387
|
+
return PDFDocumentLoadingTask;
|
388
|
+
}();
|
389
|
+
|
293
390
|
return PDFDocumentLoadingTask;
|
294
391
|
}();
|
295
|
-
|
392
|
+
|
393
|
+
var PDFDataRangeTransport =
|
394
|
+
/*#__PURE__*/
|
395
|
+
function () {
|
296
396
|
function PDFDataRangeTransport(length, initialData) {
|
397
|
+
_classCallCheck(this, PDFDataRangeTransport);
|
398
|
+
|
297
399
|
this.length = length;
|
298
400
|
this.initialData = initialData;
|
299
401
|
this._rangeListeners = [];
|
@@ -301,126 +403,260 @@ var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
|
|
301
403
|
this._progressiveReadListeners = [];
|
302
404
|
this._readyCapability = (0, _util.createPromiseCapability)();
|
303
405
|
}
|
304
|
-
|
305
|
-
|
406
|
+
|
407
|
+
_createClass(PDFDataRangeTransport, [{
|
408
|
+
key: "addRangeListener",
|
409
|
+
value: function addRangeListener(listener) {
|
306
410
|
this._rangeListeners.push(listener);
|
307
|
-
}
|
308
|
-
|
411
|
+
}
|
412
|
+
}, {
|
413
|
+
key: "addProgressListener",
|
414
|
+
value: function addProgressListener(listener) {
|
309
415
|
this._progressListeners.push(listener);
|
310
|
-
}
|
311
|
-
|
416
|
+
}
|
417
|
+
}, {
|
418
|
+
key: "addProgressiveReadListener",
|
419
|
+
value: function addProgressiveReadListener(listener) {
|
312
420
|
this._progressiveReadListeners.push(listener);
|
313
|
-
}
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
421
|
+
}
|
422
|
+
}, {
|
423
|
+
key: "onDataRange",
|
424
|
+
value: function onDataRange(begin, chunk) {
|
425
|
+
var _iteratorNormalCompletion = true;
|
426
|
+
var _didIteratorError = false;
|
427
|
+
var _iteratorError = undefined;
|
428
|
+
|
429
|
+
try {
|
430
|
+
for (var _iterator = this._rangeListeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
431
|
+
var listener = _step.value;
|
432
|
+
listener(begin, chunk);
|
433
|
+
}
|
434
|
+
} catch (err) {
|
435
|
+
_didIteratorError = true;
|
436
|
+
_iteratorError = err;
|
437
|
+
} finally {
|
438
|
+
try {
|
439
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
440
|
+
_iterator.return();
|
441
|
+
}
|
442
|
+
} finally {
|
443
|
+
if (_didIteratorError) {
|
444
|
+
throw _iteratorError;
|
445
|
+
}
|
446
|
+
}
|
318
447
|
}
|
319
|
-
}
|
320
|
-
|
448
|
+
}
|
449
|
+
}, {
|
450
|
+
key: "onDataProgress",
|
451
|
+
value: function onDataProgress(loaded) {
|
321
452
|
var _this2 = this;
|
322
453
|
|
323
454
|
this._readyCapability.promise.then(function () {
|
324
|
-
var
|
325
|
-
|
326
|
-
|
455
|
+
var _iteratorNormalCompletion2 = true;
|
456
|
+
var _didIteratorError2 = false;
|
457
|
+
var _iteratorError2 = undefined;
|
458
|
+
|
459
|
+
try {
|
460
|
+
for (var _iterator2 = _this2._progressListeners[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
461
|
+
var listener = _step2.value;
|
462
|
+
listener(loaded);
|
463
|
+
}
|
464
|
+
} catch (err) {
|
465
|
+
_didIteratorError2 = true;
|
466
|
+
_iteratorError2 = err;
|
467
|
+
} finally {
|
468
|
+
try {
|
469
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
470
|
+
_iterator2.return();
|
471
|
+
}
|
472
|
+
} finally {
|
473
|
+
if (_didIteratorError2) {
|
474
|
+
throw _iteratorError2;
|
475
|
+
}
|
476
|
+
}
|
327
477
|
}
|
328
478
|
});
|
329
|
-
}
|
330
|
-
|
479
|
+
}
|
480
|
+
}, {
|
481
|
+
key: "onDataProgressiveRead",
|
482
|
+
value: function onDataProgressiveRead(chunk) {
|
331
483
|
var _this3 = this;
|
332
484
|
|
333
485
|
this._readyCapability.promise.then(function () {
|
334
|
-
var
|
335
|
-
|
336
|
-
|
486
|
+
var _iteratorNormalCompletion3 = true;
|
487
|
+
var _didIteratorError3 = false;
|
488
|
+
var _iteratorError3 = undefined;
|
489
|
+
|
490
|
+
try {
|
491
|
+
for (var _iterator3 = _this3._progressiveReadListeners[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
492
|
+
var listener = _step3.value;
|
493
|
+
listener(chunk);
|
494
|
+
}
|
495
|
+
} catch (err) {
|
496
|
+
_didIteratorError3 = true;
|
497
|
+
_iteratorError3 = err;
|
498
|
+
} finally {
|
499
|
+
try {
|
500
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
501
|
+
_iterator3.return();
|
502
|
+
}
|
503
|
+
} finally {
|
504
|
+
if (_didIteratorError3) {
|
505
|
+
throw _iteratorError3;
|
506
|
+
}
|
507
|
+
}
|
337
508
|
}
|
338
509
|
});
|
339
|
-
}
|
340
|
-
|
510
|
+
}
|
511
|
+
}, {
|
512
|
+
key: "transportReady",
|
513
|
+
value: function transportReady() {
|
341
514
|
this._readyCapability.resolve();
|
342
|
-
}
|
343
|
-
|
515
|
+
}
|
516
|
+
}, {
|
517
|
+
key: "requestDataRange",
|
518
|
+
value: function requestDataRange(begin, end) {
|
344
519
|
(0, _util.unreachable)('Abstract method PDFDataRangeTransport.requestDataRange');
|
345
|
-
}
|
346
|
-
|
347
|
-
|
520
|
+
}
|
521
|
+
}, {
|
522
|
+
key: "abort",
|
523
|
+
value: function abort() {}
|
524
|
+
}]);
|
525
|
+
|
348
526
|
return PDFDataRangeTransport;
|
349
527
|
}();
|
350
|
-
|
528
|
+
|
529
|
+
exports.PDFDataRangeTransport = PDFDataRangeTransport;
|
530
|
+
|
531
|
+
var PDFDocumentProxy =
|
532
|
+
/*#__PURE__*/
|
533
|
+
function () {
|
351
534
|
function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
|
352
|
-
this
|
353
|
-
|
535
|
+
_classCallCheck(this, PDFDocumentProxy);
|
536
|
+
|
354
537
|
this.loadingTask = loadingTask;
|
538
|
+
this._pdfInfo = pdfInfo;
|
539
|
+
this._transport = transport;
|
355
540
|
}
|
356
|
-
PDFDocumentProxy.prototype = {
|
357
|
-
get numPages() {
|
358
|
-
return this.pdfInfo.numPages;
|
359
|
-
},
|
360
|
-
get fingerprint() {
|
361
|
-
return this.pdfInfo.fingerprint;
|
362
|
-
},
|
363
|
-
getPage: function getPage(pageNumber) {
|
364
|
-
return this.transport.getPage(pageNumber);
|
365
|
-
},
|
366
|
-
|
367
|
-
getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
|
368
|
-
return this.transport.getPageIndex(ref);
|
369
|
-
},
|
370
|
-
getDestinations: function PDFDocumentProxy_getDestinations() {
|
371
|
-
return this.transport.getDestinations();
|
372
|
-
},
|
373
|
-
getDestination: function PDFDocumentProxy_getDestination(id) {
|
374
|
-
return this.transport.getDestination(id);
|
375
|
-
},
|
376
|
-
getPageLabels: function PDFDocumentProxy_getPageLabels() {
|
377
|
-
return this.transport.getPageLabels();
|
378
|
-
},
|
379
|
-
getPageMode: function getPageMode() {
|
380
|
-
return this.transport.getPageMode();
|
381
|
-
},
|
382
|
-
|
383
|
-
getAttachments: function PDFDocumentProxy_getAttachments() {
|
384
|
-
return this.transport.getAttachments();
|
385
|
-
},
|
386
|
-
getJavaScript: function getJavaScript() {
|
387
|
-
return this.transport.getJavaScript();
|
388
|
-
},
|
389
541
|
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
return this.
|
404
|
-
}
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
542
|
+
_createClass(PDFDocumentProxy, [{
|
543
|
+
key: "getPage",
|
544
|
+
value: function getPage(pageNumber) {
|
545
|
+
return this._transport.getPage(pageNumber);
|
546
|
+
}
|
547
|
+
}, {
|
548
|
+
key: "getPageIndex",
|
549
|
+
value: function getPageIndex(ref) {
|
550
|
+
return this._transport.getPageIndex(ref);
|
551
|
+
}
|
552
|
+
}, {
|
553
|
+
key: "getDestinations",
|
554
|
+
value: function getDestinations() {
|
555
|
+
return this._transport.getDestinations();
|
556
|
+
}
|
557
|
+
}, {
|
558
|
+
key: "getDestination",
|
559
|
+
value: function getDestination(id) {
|
560
|
+
return this._transport.getDestination(id);
|
561
|
+
}
|
562
|
+
}, {
|
563
|
+
key: "getPageLabels",
|
564
|
+
value: function getPageLabels() {
|
565
|
+
return this._transport.getPageLabels();
|
566
|
+
}
|
567
|
+
}, {
|
568
|
+
key: "getPageMode",
|
569
|
+
value: function getPageMode() {
|
570
|
+
return this._transport.getPageMode();
|
571
|
+
}
|
572
|
+
}, {
|
573
|
+
key: "getOpenActionDestination",
|
574
|
+
value: function getOpenActionDestination() {
|
575
|
+
return this._transport.getOpenActionDestination();
|
576
|
+
}
|
577
|
+
}, {
|
578
|
+
key: "getAttachments",
|
579
|
+
value: function getAttachments() {
|
580
|
+
return this._transport.getAttachments();
|
581
|
+
}
|
582
|
+
}, {
|
583
|
+
key: "getJavaScript",
|
584
|
+
value: function getJavaScript() {
|
585
|
+
return this._transport.getJavaScript();
|
586
|
+
}
|
587
|
+
}, {
|
588
|
+
key: "getOutline",
|
589
|
+
value: function getOutline() {
|
590
|
+
return this._transport.getOutline();
|
591
|
+
}
|
592
|
+
}, {
|
593
|
+
key: "getPermissions",
|
594
|
+
value: function getPermissions() {
|
595
|
+
return this._transport.getPermissions();
|
596
|
+
}
|
597
|
+
}, {
|
598
|
+
key: "getMetadata",
|
599
|
+
value: function getMetadata() {
|
600
|
+
return this._transport.getMetadata();
|
601
|
+
}
|
602
|
+
}, {
|
603
|
+
key: "getData",
|
604
|
+
value: function getData() {
|
605
|
+
return this._transport.getData();
|
606
|
+
}
|
607
|
+
}, {
|
608
|
+
key: "getDownloadInfo",
|
609
|
+
value: function getDownloadInfo() {
|
610
|
+
return this._transport.downloadInfoCapability.promise;
|
611
|
+
}
|
612
|
+
}, {
|
613
|
+
key: "getStats",
|
614
|
+
value: function getStats() {
|
615
|
+
return this._transport.getStats();
|
616
|
+
}
|
617
|
+
}, {
|
618
|
+
key: "cleanup",
|
619
|
+
value: function cleanup() {
|
620
|
+
this._transport.startCleanup();
|
621
|
+
}
|
622
|
+
}, {
|
623
|
+
key: "destroy",
|
624
|
+
value: function destroy() {
|
409
625
|
return this.loadingTask.destroy();
|
410
|
-
},
|
411
|
-
get loadingParams() {
|
412
|
-
return this.transport.loadingParams;
|
413
626
|
}
|
414
|
-
}
|
627
|
+
}, {
|
628
|
+
key: "numPages",
|
629
|
+
get: function get() {
|
630
|
+
return this._pdfInfo.numPages;
|
631
|
+
}
|
632
|
+
}, {
|
633
|
+
key: "fingerprint",
|
634
|
+
get: function get() {
|
635
|
+
return this._pdfInfo.fingerprint;
|
636
|
+
}
|
637
|
+
}, {
|
638
|
+
key: "loadingParams",
|
639
|
+
get: function get() {
|
640
|
+
return this._transport.loadingParams;
|
641
|
+
}
|
642
|
+
}]);
|
643
|
+
|
415
644
|
return PDFDocumentProxy;
|
416
645
|
}();
|
417
|
-
|
646
|
+
|
647
|
+
exports.PDFDocumentProxy = PDFDocumentProxy;
|
648
|
+
|
649
|
+
var PDFPageProxy =
|
650
|
+
/*#__PURE__*/
|
651
|
+
function () {
|
418
652
|
function PDFPageProxy(pageIndex, pageInfo, transport) {
|
419
653
|
var pdfBug = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
420
654
|
|
655
|
+
_classCallCheck(this, PDFPageProxy);
|
656
|
+
|
421
657
|
this.pageIndex = pageIndex;
|
422
|
-
this.
|
423
|
-
this.
|
658
|
+
this._pageInfo = pageInfo;
|
659
|
+
this._transport = transport;
|
424
660
|
this._stats = pdfBug ? new _dom_utils.StatTimer() : _dom_utils.DummyStatTimer;
|
425
661
|
this._pdfBug = pdfBug;
|
426
662
|
this.commonObjs = transport.commonObjs;
|
@@ -430,50 +666,81 @@ var PDFPageProxy = function PDFPageProxyClosure() {
|
|
430
666
|
this.intentStates = Object.create(null);
|
431
667
|
this.destroyed = false;
|
432
668
|
}
|
433
|
-
PDFPageProxy.prototype = {
|
434
|
-
get pageNumber() {
|
435
|
-
return this.pageIndex + 1;
|
436
|
-
},
|
437
|
-
get rotate() {
|
438
|
-
return this.pageInfo.rotate;
|
439
|
-
},
|
440
|
-
get ref() {
|
441
|
-
return this.pageInfo.ref;
|
442
|
-
},
|
443
|
-
get userUnit() {
|
444
|
-
return this.pageInfo.userUnit;
|
445
|
-
},
|
446
|
-
get view() {
|
447
|
-
return this.pageInfo.view;
|
448
|
-
},
|
449
|
-
getViewport: function getViewport(scale) {
|
450
|
-
var rotate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.rotate;
|
451
|
-
var dontFlip = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
452
669
|
|
453
|
-
|
454
|
-
|
670
|
+
_createClass(PDFPageProxy, [{
|
671
|
+
key: "getViewport",
|
672
|
+
value: function getViewport() {
|
673
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
674
|
+
scale = _ref.scale,
|
675
|
+
_ref$rotation = _ref.rotation,
|
676
|
+
rotation = _ref$rotation === void 0 ? this.rotate : _ref$rotation,
|
677
|
+
_ref$dontFlip = _ref.dontFlip,
|
678
|
+
dontFlip = _ref$dontFlip === void 0 ? false : _ref$dontFlip;
|
679
|
+
|
680
|
+
if (arguments.length > 1 || typeof arguments[0] === 'number') {
|
681
|
+
(0, _util.deprecated)('getViewport is called with obsolete arguments.');
|
682
|
+
scale = arguments[0];
|
683
|
+
rotation = typeof arguments[1] === 'number' ? arguments[1] : this.rotate;
|
684
|
+
dontFlip = typeof arguments[2] === 'boolean' ? arguments[2] : false;
|
685
|
+
}
|
686
|
+
|
687
|
+
return new _dom_utils.PageViewport({
|
688
|
+
viewBox: this.view,
|
689
|
+
scale: scale,
|
690
|
+
rotation: rotation,
|
691
|
+
dontFlip: dontFlip
|
692
|
+
});
|
693
|
+
}
|
694
|
+
}, {
|
695
|
+
key: "getAnnotations",
|
696
|
+
value: function getAnnotations() {
|
697
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
698
|
+
_ref2$intent = _ref2.intent,
|
699
|
+
intent = _ref2$intent === void 0 ? null : _ref2$intent;
|
455
700
|
|
456
|
-
getAnnotations: function PDFPageProxy_getAnnotations(params) {
|
457
|
-
var intent = params && params.intent || null;
|
458
701
|
if (!this.annotationsPromise || this.annotationsIntent !== intent) {
|
459
|
-
this.annotationsPromise = this.
|
702
|
+
this.annotationsPromise = this._transport.getAnnotations(this.pageIndex, intent);
|
460
703
|
this.annotationsIntent = intent;
|
461
704
|
}
|
705
|
+
|
462
706
|
return this.annotationsPromise;
|
463
|
-
}
|
464
|
-
|
707
|
+
}
|
708
|
+
}, {
|
709
|
+
key: "render",
|
710
|
+
value: function render(_ref3) {
|
465
711
|
var _this4 = this;
|
466
712
|
|
713
|
+
var canvasContext = _ref3.canvasContext,
|
714
|
+
viewport = _ref3.viewport,
|
715
|
+
_ref3$intent = _ref3.intent,
|
716
|
+
intent = _ref3$intent === void 0 ? 'display' : _ref3$intent,
|
717
|
+
_ref3$enableWebGL = _ref3.enableWebGL,
|
718
|
+
enableWebGL = _ref3$enableWebGL === void 0 ? false : _ref3$enableWebGL,
|
719
|
+
_ref3$renderInteracti = _ref3.renderInteractiveForms,
|
720
|
+
renderInteractiveForms = _ref3$renderInteracti === void 0 ? false : _ref3$renderInteracti,
|
721
|
+
_ref3$transform = _ref3.transform,
|
722
|
+
transform = _ref3$transform === void 0 ? null : _ref3$transform,
|
723
|
+
_ref3$imageLayer = _ref3.imageLayer,
|
724
|
+
imageLayer = _ref3$imageLayer === void 0 ? null : _ref3$imageLayer,
|
725
|
+
_ref3$canvasFactory = _ref3.canvasFactory,
|
726
|
+
canvasFactory = _ref3$canvasFactory === void 0 ? null : _ref3$canvasFactory,
|
727
|
+
_ref3$background = _ref3.background,
|
728
|
+
background = _ref3$background === void 0 ? null : _ref3$background;
|
467
729
|
var stats = this._stats;
|
468
730
|
stats.time('Overall');
|
469
731
|
this.pendingCleanup = false;
|
470
|
-
var renderingIntent =
|
471
|
-
var
|
472
|
-
var webGLContext = new _webgl.WebGLContext({
|
732
|
+
var renderingIntent = intent === 'print' ? 'print' : 'display';
|
733
|
+
var canvasFactoryInstance = canvasFactory || new _dom_utils.DOMCanvasFactory();
|
734
|
+
var webGLContext = new _webgl.WebGLContext({
|
735
|
+
enable: enableWebGL
|
736
|
+
});
|
737
|
+
|
473
738
|
if (!this.intentStates[renderingIntent]) {
|
474
739
|
this.intentStates[renderingIntent] = Object.create(null);
|
475
740
|
}
|
741
|
+
|
476
742
|
var intentState = this.intentStates[renderingIntent];
|
743
|
+
|
477
744
|
if (!intentState.displayReadyCapability) {
|
478
745
|
intentState.receivingOperatorList = true;
|
479
746
|
intentState.displayReadyCapability = (0, _util.createPromiseCapability)();
|
@@ -483,34 +750,60 @@ var PDFPageProxy = function PDFPageProxyClosure() {
|
|
483
750
|
lastChunk: false
|
484
751
|
};
|
485
752
|
stats.time('Page Request');
|
486
|
-
|
753
|
+
|
754
|
+
this._transport.messageHandler.send('RenderPageRequest', {
|
487
755
|
pageIndex: this.pageNumber - 1,
|
488
756
|
intent: renderingIntent,
|
489
|
-
renderInteractiveForms:
|
757
|
+
renderInteractiveForms: renderInteractiveForms === true
|
490
758
|
});
|
491
759
|
}
|
760
|
+
|
492
761
|
var complete = function complete(error) {
|
493
762
|
var i = intentState.renderTasks.indexOf(internalRenderTask);
|
763
|
+
|
494
764
|
if (i >= 0) {
|
495
765
|
intentState.renderTasks.splice(i, 1);
|
496
766
|
}
|
767
|
+
|
497
768
|
if (_this4.cleanupAfterRender) {
|
498
769
|
_this4.pendingCleanup = true;
|
499
770
|
}
|
771
|
+
|
500
772
|
_this4._tryCleanup();
|
773
|
+
|
501
774
|
if (error) {
|
502
775
|
internalRenderTask.capability.reject(error);
|
503
776
|
} else {
|
504
777
|
internalRenderTask.capability.resolve();
|
505
778
|
}
|
779
|
+
|
506
780
|
stats.timeEnd('Rendering');
|
507
781
|
stats.timeEnd('Overall');
|
508
782
|
};
|
509
|
-
|
510
|
-
internalRenderTask
|
783
|
+
|
784
|
+
var internalRenderTask = new InternalRenderTask({
|
785
|
+
callback: complete,
|
786
|
+
params: {
|
787
|
+
canvasContext: canvasContext,
|
788
|
+
viewport: viewport,
|
789
|
+
transform: transform,
|
790
|
+
imageLayer: imageLayer,
|
791
|
+
background: background
|
792
|
+
},
|
793
|
+
objs: this.objs,
|
794
|
+
commonObjs: this.commonObjs,
|
795
|
+
operatorList: intentState.operatorList,
|
796
|
+
pageNumber: this.pageNumber,
|
797
|
+
canvasFactory: canvasFactoryInstance,
|
798
|
+
webGLContext: webGLContext,
|
799
|
+
useRequestAnimationFrame: renderingIntent !== 'print',
|
800
|
+
pdfBug: this._pdfBug
|
801
|
+
});
|
802
|
+
|
511
803
|
if (!intentState.renderTasks) {
|
512
804
|
intentState.renderTasks = [];
|
513
805
|
}
|
806
|
+
|
514
807
|
intentState.renderTasks.push(internalRenderTask);
|
515
808
|
var renderTask = internalRenderTask.task;
|
516
809
|
intentState.displayReadyCapability.promise.then(function (transparency) {
|
@@ -518,28 +811,36 @@ var PDFPageProxy = function PDFPageProxyClosure() {
|
|
518
811
|
complete();
|
519
812
|
return;
|
520
813
|
}
|
814
|
+
|
521
815
|
stats.time('Rendering');
|
522
816
|
internalRenderTask.initializeGraphics(transparency);
|
523
817
|
internalRenderTask.operatorListChanged();
|
524
818
|
}).catch(complete);
|
525
819
|
return renderTask;
|
526
|
-
}
|
527
|
-
|
820
|
+
}
|
821
|
+
}, {
|
822
|
+
key: "getOperatorList",
|
823
|
+
value: function getOperatorList() {
|
528
824
|
function operatorListChanged() {
|
529
825
|
if (intentState.operatorList.lastChunk) {
|
530
826
|
intentState.opListReadCapability.resolve(intentState.operatorList);
|
531
827
|
var i = intentState.renderTasks.indexOf(opListTask);
|
828
|
+
|
532
829
|
if (i >= 0) {
|
533
830
|
intentState.renderTasks.splice(i, 1);
|
534
831
|
}
|
535
832
|
}
|
536
833
|
}
|
834
|
+
|
537
835
|
var renderingIntent = 'oplist';
|
836
|
+
|
538
837
|
if (!this.intentStates[renderingIntent]) {
|
539
838
|
this.intentStates[renderingIntent] = Object.create(null);
|
540
839
|
}
|
840
|
+
|
541
841
|
var intentState = this.intentStates[renderingIntent];
|
542
842
|
var opListTask;
|
843
|
+
|
543
844
|
if (!intentState.opListReadCapability) {
|
544
845
|
opListTask = {};
|
545
846
|
opListTask.operatorListChanged = operatorListChanged;
|
@@ -552,47 +853,64 @@ var PDFPageProxy = function PDFPageProxyClosure() {
|
|
552
853
|
argsArray: [],
|
553
854
|
lastChunk: false
|
554
855
|
};
|
555
|
-
|
856
|
+
|
857
|
+
this._stats.time('Page Request');
|
858
|
+
|
859
|
+
this._transport.messageHandler.send('RenderPageRequest', {
|
556
860
|
pageIndex: this.pageIndex,
|
557
861
|
intent: renderingIntent
|
558
862
|
});
|
559
863
|
}
|
864
|
+
|
560
865
|
return intentState.opListReadCapability.promise;
|
561
|
-
}
|
562
|
-
|
563
|
-
|
866
|
+
}
|
867
|
+
}, {
|
868
|
+
key: "streamTextContent",
|
869
|
+
value: function streamTextContent() {
|
870
|
+
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
871
|
+
_ref4$normalizeWhites = _ref4.normalizeWhitespace,
|
872
|
+
normalizeWhitespace = _ref4$normalizeWhites === void 0 ? false : _ref4$normalizeWhites,
|
873
|
+
_ref4$disableCombineT = _ref4.disableCombineTextItems,
|
874
|
+
disableCombineTextItems = _ref4$disableCombineT === void 0 ? false : _ref4$disableCombineT;
|
564
875
|
|
565
876
|
var TEXT_CONTENT_CHUNK_SIZE = 100;
|
566
|
-
return this.
|
877
|
+
return this._transport.messageHandler.sendWithStream('GetTextContent', {
|
567
878
|
pageIndex: this.pageNumber - 1,
|
568
|
-
normalizeWhitespace:
|
569
|
-
combineTextItems:
|
879
|
+
normalizeWhitespace: normalizeWhitespace === true,
|
880
|
+
combineTextItems: disableCombineTextItems !== true
|
570
881
|
}, {
|
571
882
|
highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
|
572
883
|
size: function size(textContent) {
|
573
884
|
return textContent.items.length;
|
574
885
|
}
|
575
886
|
});
|
576
|
-
}
|
577
|
-
|
578
|
-
|
579
|
-
|
887
|
+
}
|
888
|
+
}, {
|
889
|
+
key: "getTextContent",
|
890
|
+
value: function getTextContent() {
|
891
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
580
892
|
var readableStream = this.streamTextContent(params);
|
581
893
|
return new Promise(function (resolve, reject) {
|
582
894
|
function pump() {
|
583
|
-
reader.read().then(function (
|
584
|
-
var
|
585
|
-
|
895
|
+
reader.read().then(function (_ref5) {
|
896
|
+
var _textContent$items;
|
897
|
+
|
898
|
+
var value = _ref5.value,
|
899
|
+
done = _ref5.done;
|
586
900
|
|
587
901
|
if (done) {
|
588
902
|
resolve(textContent);
|
589
903
|
return;
|
590
904
|
}
|
591
|
-
|
592
|
-
|
905
|
+
|
906
|
+
Object.assign(textContent.styles, value.styles);
|
907
|
+
|
908
|
+
(_textContent$items = textContent.items).push.apply(_textContent$items, _toConsumableArray(value.items));
|
909
|
+
|
593
910
|
pump();
|
594
911
|
}, reject);
|
595
912
|
}
|
913
|
+
|
596
914
|
var reader = readableStream.getReader();
|
597
915
|
var textContent = {
|
598
916
|
items: [],
|
@@ -600,15 +918,18 @@ var PDFPageProxy = function PDFPageProxyClosure() {
|
|
600
918
|
};
|
601
919
|
pump();
|
602
920
|
});
|
603
|
-
}
|
604
|
-
|
921
|
+
}
|
922
|
+
}, {
|
923
|
+
key: "_destroy",
|
924
|
+
value: function _destroy() {
|
605
925
|
this.destroyed = true;
|
606
|
-
this.
|
926
|
+
this._transport.pageCache[this.pageIndex] = null;
|
607
927
|
var waitOn = [];
|
608
928
|
Object.keys(this.intentStates).forEach(function (intent) {
|
609
929
|
if (intent === 'oplist') {
|
610
930
|
return;
|
611
931
|
}
|
932
|
+
|
612
933
|
var intentState = this.intentStates[intent];
|
613
934
|
intentState.renderTasks.forEach(function (renderTask) {
|
614
935
|
var renderCompleted = renderTask.capability.promise.catch(function () {});
|
@@ -620,14 +941,18 @@ var PDFPageProxy = function PDFPageProxyClosure() {
|
|
620
941
|
this.annotationsPromise = null;
|
621
942
|
this.pendingCleanup = false;
|
622
943
|
return Promise.all(waitOn);
|
623
|
-
}
|
624
|
-
|
944
|
+
}
|
945
|
+
}, {
|
946
|
+
key: "cleanup",
|
947
|
+
value: function cleanup() {
|
625
948
|
var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
626
|
-
|
627
949
|
this.pendingCleanup = true;
|
950
|
+
|
628
951
|
this._tryCleanup(resetStats);
|
629
|
-
}
|
630
|
-
|
952
|
+
}
|
953
|
+
}, {
|
954
|
+
key: "_tryCleanup",
|
955
|
+
value: function _tryCleanup() {
|
631
956
|
var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
632
957
|
|
633
958
|
if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
|
@@ -636,48 +961,93 @@ var PDFPageProxy = function PDFPageProxyClosure() {
|
|
636
961
|
}, this)) {
|
637
962
|
return;
|
638
963
|
}
|
964
|
+
|
639
965
|
Object.keys(this.intentStates).forEach(function (intent) {
|
640
966
|
delete this.intentStates[intent];
|
641
967
|
}, this);
|
642
968
|
this.objs.clear();
|
643
969
|
this.annotationsPromise = null;
|
970
|
+
|
644
971
|
if (resetStats && this._stats instanceof _dom_utils.StatTimer) {
|
645
972
|
this._stats = new _dom_utils.StatTimer();
|
646
973
|
}
|
647
|
-
this.pendingCleanup = false;
|
648
|
-
},
|
649
974
|
|
650
|
-
|
975
|
+
this.pendingCleanup = false;
|
976
|
+
}
|
977
|
+
}, {
|
978
|
+
key: "_startRenderPage",
|
979
|
+
value: function _startRenderPage(transparency, intent) {
|
651
980
|
var intentState = this.intentStates[intent];
|
981
|
+
|
652
982
|
if (intentState.displayReadyCapability) {
|
653
983
|
intentState.displayReadyCapability.resolve(transparency);
|
654
984
|
}
|
655
|
-
}
|
656
|
-
|
985
|
+
}
|
986
|
+
}, {
|
987
|
+
key: "_renderPageChunk",
|
988
|
+
value: function _renderPageChunk(operatorListChunk, intent) {
|
657
989
|
var intentState = this.intentStates[intent];
|
658
|
-
|
659
|
-
for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
|
990
|
+
|
991
|
+
for (var i = 0, ii = operatorListChunk.length; i < ii; i++) {
|
660
992
|
intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
|
661
993
|
intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
|
662
994
|
}
|
995
|
+
|
663
996
|
intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
|
664
|
-
|
665
|
-
|
997
|
+
|
998
|
+
for (var _i = 0; _i < intentState.renderTasks.length; _i++) {
|
999
|
+
intentState.renderTasks[_i].operatorListChanged();
|
666
1000
|
}
|
1001
|
+
|
667
1002
|
if (operatorListChunk.lastChunk) {
|
668
1003
|
intentState.receivingOperatorList = false;
|
1004
|
+
|
669
1005
|
this._tryCleanup();
|
670
1006
|
}
|
671
|
-
}
|
672
|
-
|
1007
|
+
}
|
1008
|
+
}, {
|
1009
|
+
key: "pageNumber",
|
1010
|
+
get: function get() {
|
1011
|
+
return this.pageIndex + 1;
|
1012
|
+
}
|
1013
|
+
}, {
|
1014
|
+
key: "rotate",
|
1015
|
+
get: function get() {
|
1016
|
+
return this._pageInfo.rotate;
|
1017
|
+
}
|
1018
|
+
}, {
|
1019
|
+
key: "ref",
|
1020
|
+
get: function get() {
|
1021
|
+
return this._pageInfo.ref;
|
1022
|
+
}
|
1023
|
+
}, {
|
1024
|
+
key: "userUnit",
|
1025
|
+
get: function get() {
|
1026
|
+
return this._pageInfo.userUnit;
|
1027
|
+
}
|
1028
|
+
}, {
|
1029
|
+
key: "view",
|
1030
|
+
get: function get() {
|
1031
|
+
return this._pageInfo.view;
|
1032
|
+
}
|
1033
|
+
}, {
|
1034
|
+
key: "stats",
|
1035
|
+
get: function get() {
|
673
1036
|
return this._stats instanceof _dom_utils.StatTimer ? this._stats : null;
|
674
1037
|
}
|
675
|
-
};
|
1038
|
+
}]);
|
1039
|
+
|
676
1040
|
return PDFPageProxy;
|
677
1041
|
}();
|
678
1042
|
|
679
|
-
|
680
|
-
|
1043
|
+
exports.PDFPageProxy = PDFPageProxy;
|
1044
|
+
|
1045
|
+
var LoopbackPort =
|
1046
|
+
/*#__PURE__*/
|
1047
|
+
function () {
|
1048
|
+
function LoopbackPort() {
|
1049
|
+
var defer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
1050
|
+
|
681
1051
|
_classCallCheck(this, LoopbackPort);
|
682
1052
|
|
683
1053
|
this._listeners = [];
|
@@ -686,21 +1056,24 @@ var LoopbackPort = function () {
|
|
686
1056
|
}
|
687
1057
|
|
688
1058
|
_createClass(LoopbackPort, [{
|
689
|
-
key:
|
1059
|
+
key: "postMessage",
|
690
1060
|
value: function postMessage(obj, transfers) {
|
691
1061
|
var _this5 = this;
|
692
1062
|
|
693
1063
|
function cloneValue(value) {
|
694
|
-
if (
|
1064
|
+
if (_typeof(value) !== 'object' || value === null) {
|
695
1065
|
return value;
|
696
1066
|
}
|
1067
|
+
|
697
1068
|
if (cloned.has(value)) {
|
698
1069
|
return cloned.get(value);
|
699
1070
|
}
|
700
|
-
|
701
|
-
var buffer;
|
1071
|
+
|
1072
|
+
var buffer, result;
|
1073
|
+
|
702
1074
|
if ((buffer = value.buffer) && (0, _util.isArrayBuffer)(buffer)) {
|
703
1075
|
var transferable = transfers && transfers.includes(buffer);
|
1076
|
+
|
704
1077
|
if (value === buffer) {
|
705
1078
|
result = value;
|
706
1079
|
} else if (transferable) {
|
@@ -708,32 +1081,47 @@ var LoopbackPort = function () {
|
|
708
1081
|
} else {
|
709
1082
|
result = new value.constructor(value);
|
710
1083
|
}
|
1084
|
+
|
711
1085
|
cloned.set(value, result);
|
712
1086
|
return result;
|
713
1087
|
}
|
1088
|
+
|
714
1089
|
result = Array.isArray(value) ? [] : {};
|
715
1090
|
cloned.set(value, result);
|
1091
|
+
|
716
1092
|
for (var i in value) {
|
717
|
-
var desc,
|
1093
|
+
var desc = void 0,
|
718
1094
|
p = value;
|
1095
|
+
|
719
1096
|
while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
|
720
1097
|
p = Object.getPrototypeOf(p);
|
721
1098
|
}
|
1099
|
+
|
722
1100
|
if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
|
723
1101
|
continue;
|
724
1102
|
}
|
1103
|
+
|
725
1104
|
result[i] = cloneValue(desc.value);
|
726
1105
|
}
|
1106
|
+
|
727
1107
|
return result;
|
728
1108
|
}
|
1109
|
+
|
729
1110
|
if (!this._defer) {
|
730
1111
|
this._listeners.forEach(function (listener) {
|
731
|
-
listener.call(this, {
|
1112
|
+
listener.call(this, {
|
1113
|
+
data: obj
|
1114
|
+
});
|
732
1115
|
}, this);
|
1116
|
+
|
733
1117
|
return;
|
734
1118
|
}
|
1119
|
+
|
735
1120
|
var cloned = new WeakMap();
|
736
|
-
var e = {
|
1121
|
+
var e = {
|
1122
|
+
data: cloneValue(obj)
|
1123
|
+
};
|
1124
|
+
|
737
1125
|
this._deferred.then(function () {
|
738
1126
|
_this5._listeners.forEach(function (listener) {
|
739
1127
|
listener.call(this, e);
|
@@ -741,18 +1129,19 @@ var LoopbackPort = function () {
|
|
741
1129
|
});
|
742
1130
|
}
|
743
1131
|
}, {
|
744
|
-
key:
|
1132
|
+
key: "addEventListener",
|
745
1133
|
value: function addEventListener(name, listener) {
|
746
1134
|
this._listeners.push(listener);
|
747
1135
|
}
|
748
1136
|
}, {
|
749
|
-
key:
|
1137
|
+
key: "removeEventListener",
|
750
1138
|
value: function removeEventListener(name, listener) {
|
751
1139
|
var i = this._listeners.indexOf(listener);
|
1140
|
+
|
752
1141
|
this._listeners.splice(i, 1);
|
753
1142
|
}
|
754
1143
|
}, {
|
755
|
-
key:
|
1144
|
+
key: "terminate",
|
756
1145
|
value: function terminate() {
|
757
1146
|
this._listeners = [];
|
758
1147
|
}
|
@@ -761,230 +1150,321 @@ var LoopbackPort = function () {
|
|
761
1150
|
return LoopbackPort;
|
762
1151
|
}();
|
763
1152
|
|
1153
|
+
exports.LoopbackPort = LoopbackPort;
|
1154
|
+
|
764
1155
|
var PDFWorker = function PDFWorkerClosure() {
|
1156
|
+
var pdfWorkerPorts = new WeakMap();
|
765
1157
|
var nextFakeWorkerId = 0;
|
766
|
-
|
1158
|
+
var fakeWorkerFilesLoadedCapability;
|
1159
|
+
|
1160
|
+
function _getWorkerSrc() {
|
767
1161
|
if (_worker_options.GlobalWorkerOptions.workerSrc) {
|
768
1162
|
return _worker_options.GlobalWorkerOptions.workerSrc;
|
769
1163
|
}
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
if (pdfjsFilePath) {
|
774
|
-
return pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, '.worker$1$2');
|
1164
|
+
|
1165
|
+
if (typeof fallbackWorkerSrc !== 'undefined') {
|
1166
|
+
return fallbackWorkerSrc;
|
775
1167
|
}
|
1168
|
+
|
776
1169
|
throw new Error('No "GlobalWorkerOptions.workerSrc" specified.');
|
777
1170
|
}
|
1171
|
+
|
778
1172
|
function getMainThreadWorkerMessageHandler() {
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
1173
|
+
try {
|
1174
|
+
if (typeof window !== 'undefined') {
|
1175
|
+
return window.pdfjsWorker && window.pdfjsWorker.WorkerMessageHandler;
|
1176
|
+
}
|
1177
|
+
} catch (ex) {}
|
1178
|
+
|
1179
|
+
return null;
|
783
1180
|
}
|
784
|
-
|
1181
|
+
|
785
1182
|
function setupFakeWorkerGlobal() {
|
786
1183
|
if (fakeWorkerFilesLoadedCapability) {
|
787
1184
|
return fakeWorkerFilesLoadedCapability.promise;
|
788
1185
|
}
|
1186
|
+
|
789
1187
|
fakeWorkerFilesLoadedCapability = (0, _util.createPromiseCapability)();
|
790
1188
|
var mainWorkerMessageHandler = getMainThreadWorkerMessageHandler();
|
1189
|
+
|
791
1190
|
if (mainWorkerMessageHandler) {
|
792
1191
|
fakeWorkerFilesLoadedCapability.resolve(mainWorkerMessageHandler);
|
793
1192
|
return fakeWorkerFilesLoadedCapability.promise;
|
794
1193
|
}
|
795
|
-
|
796
|
-
|
797
|
-
|
1194
|
+
|
1195
|
+
var loader = fakeWorkerFilesLoader || function () {
|
1196
|
+
return (0, _dom_utils.loadScript)(_getWorkerSrc()).then(function () {
|
1197
|
+
return window.pdfjsWorker.WorkerMessageHandler;
|
798
1198
|
});
|
799
1199
|
};
|
800
|
-
|
1200
|
+
|
1201
|
+
loader().then(fakeWorkerFilesLoadedCapability.resolve, fakeWorkerFilesLoadedCapability.reject);
|
801
1202
|
return fakeWorkerFilesLoadedCapability.promise;
|
802
1203
|
}
|
1204
|
+
|
803
1205
|
function createCDNWrapper(url) {
|
804
1206
|
var wrapper = 'importScripts(\'' + url + '\');';
|
805
|
-
return URL.createObjectURL(new Blob([wrapper]));
|
1207
|
+
return _util.URL.createObjectURL(new Blob([wrapper]));
|
806
1208
|
}
|
807
|
-
var pdfWorkerPorts = new WeakMap();
|
808
|
-
function PDFWorker() {
|
809
|
-
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
810
|
-
_ref2$name = _ref2.name,
|
811
|
-
name = _ref2$name === undefined ? null : _ref2$name,
|
812
|
-
_ref2$port = _ref2.port,
|
813
|
-
port = _ref2$port === undefined ? null : _ref2$port,
|
814
|
-
_ref2$postMessageTran = _ref2.postMessageTransfers,
|
815
|
-
postMessageTransfers = _ref2$postMessageTran === undefined ? true : _ref2$postMessageTran,
|
816
|
-
_ref2$verbosity = _ref2.verbosity,
|
817
|
-
verbosity = _ref2$verbosity === undefined ? null : _ref2$verbosity;
|
818
|
-
|
819
|
-
if (port && pdfWorkerPorts.has(port)) {
|
820
|
-
throw new Error('Cannot use more than one PDFWorker per port');
|
821
|
-
}
|
822
|
-
this.name = name;
|
823
|
-
this.destroyed = false;
|
824
|
-
this.postMessageTransfers = postMessageTransfers !== false;
|
825
|
-
this.verbosity = (0, _util.isNum)(verbosity) ? verbosity : (0, _util.getVerbosityLevel)();
|
826
|
-
this._readyCapability = (0, _util.createPromiseCapability)();
|
827
|
-
this._port = null;
|
828
|
-
this._webWorker = null;
|
829
|
-
this._messageHandler = null;
|
830
|
-
if (port) {
|
831
|
-
pdfWorkerPorts.set(port, this);
|
832
|
-
this._initializeFromPort(port);
|
833
|
-
return;
|
834
|
-
}
|
835
|
-
this._initialize();
|
836
|
-
}
|
837
|
-
PDFWorker.prototype = {
|
838
|
-
get promise() {
|
839
|
-
return this._readyCapability.promise;
|
840
|
-
},
|
841
|
-
get port() {
|
842
|
-
return this._port;
|
843
|
-
},
|
844
|
-
get messageHandler() {
|
845
|
-
return this._messageHandler;
|
846
|
-
},
|
847
|
-
_initializeFromPort: function PDFWorker_initializeFromPort(port) {
|
848
|
-
this._port = port;
|
849
|
-
this._messageHandler = new _util.MessageHandler('main', 'worker', port);
|
850
|
-
this._messageHandler.on('ready', function () {});
|
851
|
-
this._readyCapability.resolve();
|
852
|
-
},
|
853
|
-
_initialize: function PDFWorker_initialize() {
|
854
|
-
var _this6 = this;
|
855
1209
|
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
1210
|
+
var PDFWorker =
|
1211
|
+
/*#__PURE__*/
|
1212
|
+
function () {
|
1213
|
+
function PDFWorker() {
|
1214
|
+
var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
1215
|
+
_ref6$name = _ref6.name,
|
1216
|
+
name = _ref6$name === void 0 ? null : _ref6$name,
|
1217
|
+
_ref6$port = _ref6.port,
|
1218
|
+
port = _ref6$port === void 0 ? null : _ref6$port,
|
1219
|
+
_ref6$postMessageTran = _ref6.postMessageTransfers,
|
1220
|
+
postMessageTransfers = _ref6$postMessageTran === void 0 ? true : _ref6$postMessageTran,
|
1221
|
+
_ref6$verbosity = _ref6.verbosity,
|
1222
|
+
verbosity = _ref6$verbosity === void 0 ? (0, _util.getVerbosityLevel)() : _ref6$verbosity;
|
1223
|
+
|
1224
|
+
_classCallCheck(this, PDFWorker);
|
1225
|
+
|
1226
|
+
if (port && pdfWorkerPorts.has(port)) {
|
1227
|
+
throw new Error('Cannot use more than one PDFWorker per port');
|
1228
|
+
}
|
1229
|
+
|
1230
|
+
this.name = name;
|
1231
|
+
this.destroyed = false;
|
1232
|
+
this.postMessageTransfers = postMessageTransfers !== false;
|
1233
|
+
this.verbosity = verbosity;
|
1234
|
+
this._readyCapability = (0, _util.createPromiseCapability)();
|
1235
|
+
this._port = null;
|
1236
|
+
this._webWorker = null;
|
1237
|
+
this._messageHandler = null;
|
1238
|
+
|
1239
|
+
if (port) {
|
1240
|
+
pdfWorkerPorts.set(port, this);
|
1241
|
+
|
1242
|
+
this._initializeFromPort(port);
|
1243
|
+
|
1244
|
+
return;
|
1245
|
+
}
|
1246
|
+
|
1247
|
+
this._initialize();
|
1248
|
+
}
|
1249
|
+
|
1250
|
+
_createClass(PDFWorker, [{
|
1251
|
+
key: "_initializeFromPort",
|
1252
|
+
value: function _initializeFromPort(port) {
|
1253
|
+
this._port = port;
|
1254
|
+
this._messageHandler = new _message_handler.MessageHandler('main', 'worker', port);
|
1255
|
+
|
1256
|
+
this._messageHandler.on('ready', function () {});
|
1257
|
+
|
1258
|
+
this._readyCapability.resolve();
|
1259
|
+
}
|
1260
|
+
}, {
|
1261
|
+
key: "_initialize",
|
1262
|
+
value: function _initialize() {
|
1263
|
+
var _this6 = this;
|
1264
|
+
|
1265
|
+
if (typeof Worker !== 'undefined' && !isWorkerDisabled && !getMainThreadWorkerMessageHandler()) {
|
1266
|
+
var workerSrc = _getWorkerSrc();
|
1267
|
+
|
1268
|
+
try {
|
1269
|
+
if (!(0, _util.isSameOrigin)(window.location.href, workerSrc)) {
|
1270
|
+
workerSrc = createCDNWrapper(new _util.URL(workerSrc, window.location).href);
|
885
1271
|
}
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
_this6.postMessageTransfers = false;
|
893
|
-
}
|
894
|
-
_this6._readyCapability.resolve();
|
895
|
-
messageHandler.send('configure', { verbosity: _this6.verbosity });
|
896
|
-
} else {
|
897
|
-
_this6._setupFakeWorker();
|
1272
|
+
|
1273
|
+
var worker = new Worker(workerSrc);
|
1274
|
+
var messageHandler = new _message_handler.MessageHandler('main', 'worker', worker);
|
1275
|
+
|
1276
|
+
var terminateEarly = function terminateEarly() {
|
1277
|
+
worker.removeEventListener('error', onWorkerError);
|
898
1278
|
messageHandler.destroy();
|
899
1279
|
worker.terminate();
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
}
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
1280
|
+
|
1281
|
+
if (_this6.destroyed) {
|
1282
|
+
_this6._readyCapability.reject(new Error('Worker was destroyed'));
|
1283
|
+
} else {
|
1284
|
+
_this6._setupFakeWorker();
|
1285
|
+
}
|
1286
|
+
};
|
1287
|
+
|
1288
|
+
var onWorkerError = function onWorkerError() {
|
1289
|
+
if (!_this6._webWorker) {
|
1290
|
+
terminateEarly();
|
1291
|
+
}
|
1292
|
+
};
|
1293
|
+
|
1294
|
+
worker.addEventListener('error', onWorkerError);
|
1295
|
+
messageHandler.on('test', function (data) {
|
1296
|
+
worker.removeEventListener('error', onWorkerError);
|
1297
|
+
|
1298
|
+
if (_this6.destroyed) {
|
1299
|
+
terminateEarly();
|
1300
|
+
return;
|
1301
|
+
}
|
1302
|
+
|
1303
|
+
if (data && data.supportTypedArray) {
|
1304
|
+
_this6._messageHandler = messageHandler;
|
1305
|
+
_this6._port = worker;
|
1306
|
+
_this6._webWorker = worker;
|
1307
|
+
|
1308
|
+
if (!data.supportTransfers) {
|
1309
|
+
_this6.postMessageTransfers = false;
|
1310
|
+
}
|
1311
|
+
|
1312
|
+
_this6._readyCapability.resolve();
|
1313
|
+
|
1314
|
+
messageHandler.send('configure', {
|
1315
|
+
verbosity: _this6.verbosity
|
1316
|
+
});
|
1317
|
+
} else {
|
1318
|
+
_this6._setupFakeWorker();
|
1319
|
+
|
1320
|
+
messageHandler.destroy();
|
1321
|
+
worker.terminate();
|
1322
|
+
}
|
1323
|
+
});
|
1324
|
+
messageHandler.on('ready', function (data) {
|
1325
|
+
worker.removeEventListener('error', onWorkerError);
|
1326
|
+
|
1327
|
+
if (_this6.destroyed) {
|
1328
|
+
terminateEarly();
|
1329
|
+
return;
|
1330
|
+
}
|
1331
|
+
|
1332
|
+
try {
|
1333
|
+
sendTest();
|
1334
|
+
} catch (e) {
|
1335
|
+
_this6._setupFakeWorker();
|
1336
|
+
}
|
1337
|
+
});
|
1338
|
+
|
1339
|
+
var sendTest = function sendTest() {
|
1340
|
+
var testObj = new Uint8Array([_this6.postMessageTransfers ? 255 : 0]);
|
1341
|
+
|
1342
|
+
try {
|
1343
|
+
messageHandler.send('test', testObj, [testObj.buffer]);
|
1344
|
+
} catch (ex) {
|
1345
|
+
(0, _util.info)('Cannot use postMessage transfers');
|
1346
|
+
testObj[0] = 0;
|
1347
|
+
messageHandler.send('test', testObj);
|
1348
|
+
}
|
1349
|
+
};
|
1350
|
+
|
1351
|
+
sendTest();
|
1352
|
+
return;
|
1353
|
+
} catch (e) {
|
1354
|
+
(0, _util.info)('The worker has been disabled.');
|
1355
|
+
}
|
928
1356
|
}
|
1357
|
+
|
1358
|
+
this._setupFakeWorker();
|
929
1359
|
}
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
1360
|
+
}, {
|
1361
|
+
key: "_setupFakeWorker",
|
1362
|
+
value: function _setupFakeWorker() {
|
1363
|
+
var _this7 = this;
|
934
1364
|
|
935
|
-
|
936
|
-
|
937
|
-
|
1365
|
+
if (!isWorkerDisabled) {
|
1366
|
+
(0, _util.warn)('Setting up fake worker.');
|
1367
|
+
isWorkerDisabled = true;
|
1368
|
+
}
|
1369
|
+
|
1370
|
+
setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
|
1371
|
+
if (_this7.destroyed) {
|
1372
|
+
_this7._readyCapability.reject(new Error('Worker was destroyed'));
|
1373
|
+
|
1374
|
+
return;
|
1375
|
+
}
|
1376
|
+
|
1377
|
+
var port = new LoopbackPort();
|
1378
|
+
_this7._port = port;
|
1379
|
+
var id = 'fake' + nextFakeWorkerId++;
|
1380
|
+
var workerHandler = new _message_handler.MessageHandler(id + '_worker', id, port);
|
1381
|
+
WorkerMessageHandler.setup(workerHandler, port);
|
1382
|
+
var messageHandler = new _message_handler.MessageHandler(id, id + '_worker', port);
|
1383
|
+
_this7._messageHandler = messageHandler;
|
1384
|
+
|
1385
|
+
_this7._readyCapability.resolve();
|
1386
|
+
}).catch(function (reason) {
|
1387
|
+
_this7._readyCapability.reject(new Error("Setting up fake worker failed: \"".concat(reason.message, "\".")));
|
1388
|
+
});
|
938
1389
|
}
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
1390
|
+
}, {
|
1391
|
+
key: "destroy",
|
1392
|
+
value: function destroy() {
|
1393
|
+
this.destroyed = true;
|
1394
|
+
|
1395
|
+
if (this._webWorker) {
|
1396
|
+
this._webWorker.terminate();
|
1397
|
+
|
1398
|
+
this._webWorker = null;
|
1399
|
+
}
|
1400
|
+
|
1401
|
+
pdfWorkerPorts.delete(this._port);
|
1402
|
+
this._port = null;
|
1403
|
+
|
1404
|
+
if (this._messageHandler) {
|
1405
|
+
this._messageHandler.destroy();
|
1406
|
+
|
1407
|
+
this._messageHandler = null;
|
943
1408
|
}
|
944
|
-
var isTypedArraysPresent = Uint8Array !== Float32Array;
|
945
|
-
var port = new LoopbackPort(isTypedArraysPresent);
|
946
|
-
_this7._port = port;
|
947
|
-
var id = 'fake' + nextFakeWorkerId++;
|
948
|
-
var workerHandler = new _util.MessageHandler(id + '_worker', id, port);
|
949
|
-
WorkerMessageHandler.setup(workerHandler, port);
|
950
|
-
var messageHandler = new _util.MessageHandler(id, id + '_worker', port);
|
951
|
-
_this7._messageHandler = messageHandler;
|
952
|
-
_this7._readyCapability.resolve();
|
953
|
-
});
|
954
|
-
},
|
955
|
-
destroy: function PDFWorker_destroy() {
|
956
|
-
this.destroyed = true;
|
957
|
-
if (this._webWorker) {
|
958
|
-
this._webWorker.terminate();
|
959
|
-
this._webWorker = null;
|
960
1409
|
}
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
this.
|
965
|
-
this._messageHandler = null;
|
1410
|
+
}, {
|
1411
|
+
key: "promise",
|
1412
|
+
get: function get() {
|
1413
|
+
return this._readyCapability.promise;
|
966
1414
|
}
|
967
|
-
}
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
}
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
1415
|
+
}, {
|
1416
|
+
key: "port",
|
1417
|
+
get: function get() {
|
1418
|
+
return this._port;
|
1419
|
+
}
|
1420
|
+
}, {
|
1421
|
+
key: "messageHandler",
|
1422
|
+
get: function get() {
|
1423
|
+
return this._messageHandler;
|
1424
|
+
}
|
1425
|
+
}], [{
|
1426
|
+
key: "fromPort",
|
1427
|
+
value: function fromPort(params) {
|
1428
|
+
if (!params || !params.port) {
|
1429
|
+
throw new Error('PDFWorker.fromPort - invalid method signature.');
|
1430
|
+
}
|
1431
|
+
|
1432
|
+
if (pdfWorkerPorts.has(params.port)) {
|
1433
|
+
return pdfWorkerPorts.get(params.port);
|
1434
|
+
}
|
1435
|
+
|
1436
|
+
return new PDFWorker(params);
|
1437
|
+
}
|
1438
|
+
}, {
|
1439
|
+
key: "getWorkerSrc",
|
1440
|
+
value: function getWorkerSrc() {
|
1441
|
+
return _getWorkerSrc();
|
1442
|
+
}
|
1443
|
+
}]);
|
1444
|
+
|
1445
|
+
return PDFWorker;
|
1446
|
+
}();
|
1447
|
+
|
978
1448
|
return PDFWorker;
|
979
1449
|
}();
|
980
|
-
|
981
|
-
|
1450
|
+
|
1451
|
+
exports.PDFWorker = PDFWorker;
|
1452
|
+
|
1453
|
+
var WorkerTransport =
|
1454
|
+
/*#__PURE__*/
|
1455
|
+
function () {
|
1456
|
+
function WorkerTransport(messageHandler, loadingTask, networkStream, params) {
|
1457
|
+
_classCallCheck(this, WorkerTransport);
|
1458
|
+
|
982
1459
|
this.messageHandler = messageHandler;
|
983
1460
|
this.loadingTask = loadingTask;
|
984
1461
|
this.commonObjs = new PDFObjects();
|
985
|
-
this.fontLoader = new _font_loader.FontLoader(
|
1462
|
+
this.fontLoader = new _font_loader.FontLoader({
|
1463
|
+
docId: loadingTask.docId,
|
1464
|
+
onUnsupportedFeature: this._onUnsupportedFeature.bind(this)
|
1465
|
+
});
|
986
1466
|
this._params = params;
|
987
|
-
this.CMapReaderFactory = new CMapReaderFactory({
|
1467
|
+
this.CMapReaderFactory = new params.CMapReaderFactory({
|
988
1468
|
baseUrl: params.cMapUrl,
|
989
1469
|
isCompressed: params.cMapPacked
|
990
1470
|
});
|
@@ -999,18 +1479,23 @@ var WorkerTransport = function WorkerTransportClosure() {
|
|
999
1479
|
this.downloadInfoCapability = (0, _util.createPromiseCapability)();
|
1000
1480
|
this.setupMessageHandler();
|
1001
1481
|
}
|
1002
|
-
|
1003
|
-
|
1482
|
+
|
1483
|
+
_createClass(WorkerTransport, [{
|
1484
|
+
key: "destroy",
|
1485
|
+
value: function destroy() {
|
1004
1486
|
var _this8 = this;
|
1005
1487
|
|
1006
1488
|
if (this.destroyCapability) {
|
1007
1489
|
return this.destroyCapability.promise;
|
1008
1490
|
}
|
1491
|
+
|
1009
1492
|
this.destroyed = true;
|
1010
1493
|
this.destroyCapability = (0, _util.createPromiseCapability)();
|
1494
|
+
|
1011
1495
|
if (this._passwordCapability) {
|
1012
1496
|
this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
|
1013
1497
|
}
|
1498
|
+
|
1014
1499
|
var waitOn = [];
|
1015
1500
|
this.pageCache.forEach(function (page) {
|
1016
1501
|
if (page) {
|
@@ -1023,46 +1508,56 @@ var WorkerTransport = function WorkerTransportClosure() {
|
|
1023
1508
|
waitOn.push(terminated);
|
1024
1509
|
Promise.all(waitOn).then(function () {
|
1025
1510
|
_this8.fontLoader.clear();
|
1511
|
+
|
1026
1512
|
if (_this8._networkStream) {
|
1027
1513
|
_this8._networkStream.cancelAllRequests();
|
1028
1514
|
}
|
1515
|
+
|
1029
1516
|
if (_this8.messageHandler) {
|
1030
1517
|
_this8.messageHandler.destroy();
|
1518
|
+
|
1031
1519
|
_this8.messageHandler = null;
|
1032
1520
|
}
|
1521
|
+
|
1033
1522
|
_this8.destroyCapability.resolve();
|
1034
1523
|
}, this.destroyCapability.reject);
|
1035
1524
|
return this.destroyCapability.promise;
|
1036
|
-
}
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1525
|
+
}
|
1526
|
+
}, {
|
1527
|
+
key: "setupMessageHandler",
|
1528
|
+
value: function setupMessageHandler() {
|
1529
|
+
var messageHandler = this.messageHandler,
|
1530
|
+
loadingTask = this.loadingTask;
|
1040
1531
|
messageHandler.on('GetReader', function (data, sink) {
|
1041
1532
|
var _this9 = this;
|
1042
1533
|
|
1043
1534
|
(0, _util.assert)(this._networkStream);
|
1044
1535
|
this._fullReader = this._networkStream.getFullReader();
|
1536
|
+
|
1045
1537
|
this._fullReader.onProgress = function (evt) {
|
1046
1538
|
_this9._lastProgress = {
|
1047
1539
|
loaded: evt.loaded,
|
1048
1540
|
total: evt.total
|
1049
1541
|
};
|
1050
1542
|
};
|
1543
|
+
|
1051
1544
|
sink.onPull = function () {
|
1052
|
-
_this9._fullReader.read().then(function (
|
1053
|
-
var value =
|
1054
|
-
done =
|
1545
|
+
_this9._fullReader.read().then(function (_ref7) {
|
1546
|
+
var value = _ref7.value,
|
1547
|
+
done = _ref7.done;
|
1055
1548
|
|
1056
1549
|
if (done) {
|
1057
1550
|
sink.close();
|
1058
1551
|
return;
|
1059
1552
|
}
|
1553
|
+
|
1060
1554
|
(0, _util.assert)((0, _util.isArrayBuffer)(value));
|
1061
1555
|
sink.enqueue(new Uint8Array(value), 1, [value]);
|
1062
1556
|
}).catch(function (reason) {
|
1063
1557
|
sink.error(reason);
|
1064
1558
|
});
|
1065
1559
|
};
|
1560
|
+
|
1066
1561
|
sink.onCancel = function (reason) {
|
1067
1562
|
_this9._fullReader.cancel(reason);
|
1068
1563
|
};
|
@@ -1074,14 +1569,11 @@ var WorkerTransport = function WorkerTransportClosure() {
|
|
1074
1569
|
var fullReader = this._fullReader;
|
1075
1570
|
fullReader.headersReady.then(function () {
|
1076
1571
|
if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
|
1077
|
-
if (_this10._lastProgress) {
|
1078
|
-
|
1079
|
-
if (_loadingTask.onProgress) {
|
1080
|
-
_loadingTask.onProgress(_this10._lastProgress);
|
1081
|
-
}
|
1572
|
+
if (_this10._lastProgress && loadingTask.onProgress) {
|
1573
|
+
loadingTask.onProgress(_this10._lastProgress);
|
1082
1574
|
}
|
1575
|
+
|
1083
1576
|
fullReader.onProgress = function (evt) {
|
1084
|
-
var loadingTask = _this10.loadingTask;
|
1085
1577
|
if (loadingTask.onProgress) {
|
1086
1578
|
loadingTask.onProgress({
|
1087
1579
|
loaded: evt.loaded,
|
@@ -1090,6 +1582,7 @@ var WorkerTransport = function WorkerTransportClosure() {
|
|
1090
1582
|
}
|
1091
1583
|
};
|
1092
1584
|
}
|
1585
|
+
|
1093
1586
|
headersCapability.resolve({
|
1094
1587
|
isStreamingSupported: fullReader.isStreamingSupported,
|
1095
1588
|
isRangeSupported: fullReader.isRangeSupported,
|
@@ -1100,173 +1593,222 @@ var WorkerTransport = function WorkerTransportClosure() {
|
|
1100
1593
|
}, this);
|
1101
1594
|
messageHandler.on('GetRangeReader', function (data, sink) {
|
1102
1595
|
(0, _util.assert)(this._networkStream);
|
1103
|
-
|
1596
|
+
|
1597
|
+
var rangeReader = this._networkStream.getRangeReader(data.begin, data.end);
|
1598
|
+
|
1104
1599
|
sink.onPull = function () {
|
1105
|
-
|
1106
|
-
var value =
|
1107
|
-
done =
|
1600
|
+
rangeReader.read().then(function (_ref8) {
|
1601
|
+
var value = _ref8.value,
|
1602
|
+
done = _ref8.done;
|
1108
1603
|
|
1109
1604
|
if (done) {
|
1110
1605
|
sink.close();
|
1111
1606
|
return;
|
1112
1607
|
}
|
1608
|
+
|
1113
1609
|
(0, _util.assert)((0, _util.isArrayBuffer)(value));
|
1114
1610
|
sink.enqueue(new Uint8Array(value), 1, [value]);
|
1115
1611
|
}).catch(function (reason) {
|
1116
1612
|
sink.error(reason);
|
1117
1613
|
});
|
1118
1614
|
};
|
1615
|
+
|
1119
1616
|
sink.onCancel = function (reason) {
|
1120
|
-
|
1617
|
+
rangeReader.cancel(reason);
|
1121
1618
|
};
|
1122
1619
|
}, this);
|
1123
|
-
messageHandler.on('GetDoc', function
|
1124
|
-
var pdfInfo =
|
1125
|
-
|
1620
|
+
messageHandler.on('GetDoc', function (_ref9) {
|
1621
|
+
var pdfInfo = _ref9.pdfInfo;
|
1126
1622
|
this.numPages = pdfInfo.numPages;
|
1127
|
-
|
1128
|
-
|
1129
|
-
this.pdfDocument
|
1130
|
-
loadingTask._capability.resolve(pdfDocument);
|
1623
|
+
this.pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
|
1624
|
+
|
1625
|
+
loadingTask._capability.resolve(this.pdfDocument);
|
1131
1626
|
}, this);
|
1132
|
-
messageHandler.on('PasswordRequest', function
|
1627
|
+
messageHandler.on('PasswordRequest', function (exception) {
|
1133
1628
|
var _this11 = this;
|
1134
1629
|
|
1135
1630
|
this._passwordCapability = (0, _util.createPromiseCapability)();
|
1631
|
+
|
1136
1632
|
if (loadingTask.onPassword) {
|
1137
1633
|
var updatePassword = function updatePassword(password) {
|
1138
|
-
_this11._passwordCapability.resolve({
|
1634
|
+
_this11._passwordCapability.resolve({
|
1635
|
+
password: password
|
1636
|
+
});
|
1139
1637
|
};
|
1140
|
-
|
1638
|
+
|
1639
|
+
try {
|
1640
|
+
loadingTask.onPassword(updatePassword, exception.code);
|
1641
|
+
} catch (ex) {
|
1642
|
+
this._passwordCapability.reject(ex);
|
1643
|
+
}
|
1141
1644
|
} else {
|
1142
1645
|
this._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
|
1143
1646
|
}
|
1647
|
+
|
1144
1648
|
return this._passwordCapability.promise;
|
1145
1649
|
}, this);
|
1146
|
-
messageHandler.on('PasswordException', function
|
1650
|
+
messageHandler.on('PasswordException', function (exception) {
|
1147
1651
|
loadingTask._capability.reject(new _util.PasswordException(exception.message, exception.code));
|
1148
1652
|
}, this);
|
1149
|
-
messageHandler.on('InvalidPDF', function
|
1150
|
-
|
1653
|
+
messageHandler.on('InvalidPDF', function (exception) {
|
1654
|
+
loadingTask._capability.reject(new _util.InvalidPDFException(exception.message));
|
1151
1655
|
}, this);
|
1152
|
-
messageHandler.on('MissingPDF', function
|
1153
|
-
|
1656
|
+
messageHandler.on('MissingPDF', function (exception) {
|
1657
|
+
loadingTask._capability.reject(new _util.MissingPDFException(exception.message));
|
1154
1658
|
}, this);
|
1155
|
-
messageHandler.on('UnexpectedResponse', function
|
1156
|
-
|
1659
|
+
messageHandler.on('UnexpectedResponse', function (exception) {
|
1660
|
+
loadingTask._capability.reject(new _util.UnexpectedResponseException(exception.message, exception.status));
|
1157
1661
|
}, this);
|
1158
|
-
messageHandler.on('UnknownError', function
|
1159
|
-
|
1662
|
+
messageHandler.on('UnknownError', function (exception) {
|
1663
|
+
loadingTask._capability.reject(new _util.UnknownErrorException(exception.message, exception.details));
|
1160
1664
|
}, this);
|
1161
|
-
messageHandler.on('DataLoaded', function
|
1665
|
+
messageHandler.on('DataLoaded', function (data) {
|
1666
|
+
if (loadingTask.onProgress) {
|
1667
|
+
loadingTask.onProgress({
|
1668
|
+
loaded: data.length,
|
1669
|
+
total: data.length
|
1670
|
+
});
|
1671
|
+
}
|
1672
|
+
|
1162
1673
|
this.downloadInfoCapability.resolve(data);
|
1163
1674
|
}, this);
|
1164
|
-
messageHandler.on('
|
1165
|
-
messageHandler.on('StartRenderPage', function transportRender(data) {
|
1675
|
+
messageHandler.on('StartRenderPage', function (data) {
|
1166
1676
|
if (this.destroyed) {
|
1167
1677
|
return;
|
1168
1678
|
}
|
1679
|
+
|
1169
1680
|
var page = this.pageCache[data.pageIndex];
|
1681
|
+
|
1170
1682
|
page._stats.timeEnd('Page Request');
|
1683
|
+
|
1171
1684
|
page._startRenderPage(data.transparency, data.intent);
|
1172
1685
|
}, this);
|
1173
|
-
messageHandler.on('RenderPageChunk', function
|
1686
|
+
messageHandler.on('RenderPageChunk', function (data) {
|
1174
1687
|
if (this.destroyed) {
|
1175
1688
|
return;
|
1176
1689
|
}
|
1690
|
+
|
1177
1691
|
var page = this.pageCache[data.pageIndex];
|
1692
|
+
|
1178
1693
|
page._renderPageChunk(data.operatorList, data.intent);
|
1179
1694
|
}, this);
|
1180
|
-
messageHandler.on('commonobj', function
|
1695
|
+
messageHandler.on('commonobj', function (data) {
|
1181
1696
|
var _this12 = this;
|
1182
1697
|
|
1183
1698
|
if (this.destroyed) {
|
1184
1699
|
return;
|
1185
1700
|
}
|
1186
|
-
|
1187
|
-
var
|
1188
|
-
|
1701
|
+
|
1702
|
+
var _data = _slicedToArray(data, 3),
|
1703
|
+
id = _data[0],
|
1704
|
+
type = _data[1],
|
1705
|
+
exportedData = _data[2];
|
1706
|
+
|
1707
|
+
if (this.commonObjs.has(id)) {
|
1189
1708
|
return;
|
1190
1709
|
}
|
1710
|
+
|
1191
1711
|
switch (type) {
|
1192
1712
|
case 'Font':
|
1193
|
-
var exportedData = data[2];
|
1194
1713
|
var params = this._params;
|
1714
|
+
|
1195
1715
|
if ('error' in exportedData) {
|
1196
1716
|
var exportedError = exportedData.error;
|
1197
|
-
(0, _util.warn)(
|
1717
|
+
(0, _util.warn)("Error during font loading: ".concat(exportedError));
|
1198
1718
|
this.commonObjs.resolve(id, exportedError);
|
1199
1719
|
break;
|
1200
1720
|
}
|
1721
|
+
|
1201
1722
|
var fontRegistry = null;
|
1202
|
-
|
1723
|
+
|
1724
|
+
if (params.pdfBug && _global_scope.default.FontInspector && _global_scope.default.FontInspector.enabled) {
|
1203
1725
|
fontRegistry = {
|
1204
1726
|
registerFont: function registerFont(font, url) {
|
1205
|
-
|
1727
|
+
_global_scope.default['FontInspector'].fontAdded(font, url);
|
1206
1728
|
}
|
1207
1729
|
};
|
1208
1730
|
}
|
1731
|
+
|
1209
1732
|
var font = new _font_loader.FontFaceObject(exportedData, {
|
1210
1733
|
isEvalSupported: params.isEvalSupported,
|
1211
1734
|
disableFontFace: params.disableFontFace,
|
1735
|
+
ignoreErrors: params.ignoreErrors,
|
1736
|
+
onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
|
1212
1737
|
fontRegistry: fontRegistry
|
1213
1738
|
});
|
1214
|
-
|
1739
|
+
this.fontLoader.bind(font).then(function () {
|
1215
1740
|
_this12.commonObjs.resolve(id, font);
|
1216
|
-
}
|
1217
|
-
|
1741
|
+
}, function (reason) {
|
1742
|
+
messageHandler.sendWithPromise('FontFallback', {
|
1743
|
+
id: id
|
1744
|
+
}).finally(function () {
|
1745
|
+
_this12.commonObjs.resolve(id, font);
|
1746
|
+
});
|
1747
|
+
});
|
1218
1748
|
break;
|
1749
|
+
|
1219
1750
|
case 'FontPath':
|
1220
|
-
this.commonObjs.resolve(id,
|
1751
|
+
this.commonObjs.resolve(id, exportedData);
|
1221
1752
|
break;
|
1753
|
+
|
1222
1754
|
default:
|
1223
|
-
throw new Error(
|
1755
|
+
throw new Error("Got unknown common object type ".concat(type));
|
1224
1756
|
}
|
1225
1757
|
}, this);
|
1226
|
-
messageHandler.on('obj', function
|
1758
|
+
messageHandler.on('obj', function (data) {
|
1227
1759
|
if (this.destroyed) {
|
1228
1760
|
return;
|
1229
1761
|
}
|
1230
|
-
|
1231
|
-
var
|
1232
|
-
|
1762
|
+
|
1763
|
+
var _data2 = _slicedToArray(data, 4),
|
1764
|
+
id = _data2[0],
|
1765
|
+
pageIndex = _data2[1],
|
1766
|
+
type = _data2[2],
|
1767
|
+
imageData = _data2[3];
|
1768
|
+
|
1233
1769
|
var pageProxy = this.pageCache[pageIndex];
|
1234
|
-
|
1235
|
-
if (pageProxy.objs.
|
1770
|
+
|
1771
|
+
if (pageProxy.objs.has(id)) {
|
1236
1772
|
return;
|
1237
1773
|
}
|
1774
|
+
|
1238
1775
|
switch (type) {
|
1239
1776
|
case 'JpegStream':
|
1240
|
-
imageData = data[3];
|
1241
1777
|
return new Promise(function (resolve, reject) {
|
1242
1778
|
var img = new Image();
|
1779
|
+
|
1243
1780
|
img.onload = function () {
|
1244
1781
|
resolve(img);
|
1245
1782
|
};
|
1783
|
+
|
1246
1784
|
img.onerror = function () {
|
1247
1785
|
reject(new Error('Error during JPEG image loading'));
|
1248
1786
|
};
|
1787
|
+
|
1249
1788
|
img.src = imageData;
|
1250
1789
|
}).then(function (img) {
|
1251
1790
|
pageProxy.objs.resolve(id, img);
|
1252
1791
|
});
|
1792
|
+
|
1253
1793
|
case 'Image':
|
1254
|
-
imageData = data[3];
|
1255
1794
|
pageProxy.objs.resolve(id, imageData);
|
1256
1795
|
var MAX_IMAGE_SIZE_TO_STORE = 8000000;
|
1796
|
+
|
1257
1797
|
if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
|
1258
1798
|
pageProxy.cleanupAfterRender = true;
|
1259
1799
|
}
|
1800
|
+
|
1260
1801
|
break;
|
1802
|
+
|
1261
1803
|
default:
|
1262
|
-
throw new Error(
|
1804
|
+
throw new Error("Got unknown object type ".concat(type));
|
1263
1805
|
}
|
1264
1806
|
}, this);
|
1265
|
-
messageHandler.on('DocProgress', function
|
1807
|
+
messageHandler.on('DocProgress', function (data) {
|
1266
1808
|
if (this.destroyed) {
|
1267
1809
|
return;
|
1268
1810
|
}
|
1269
|
-
|
1811
|
+
|
1270
1812
|
if (loadingTask.onProgress) {
|
1271
1813
|
loadingTask.onProgress({
|
1272
1814
|
loaded: data.loaded,
|
@@ -1274,80 +1816,85 @@ var WorkerTransport = function WorkerTransportClosure() {
|
|
1274
1816
|
});
|
1275
1817
|
}
|
1276
1818
|
}, this);
|
1277
|
-
messageHandler.on('PageError', function
|
1819
|
+
messageHandler.on('PageError', function (data) {
|
1278
1820
|
if (this.destroyed) {
|
1279
1821
|
return;
|
1280
1822
|
}
|
1823
|
+
|
1281
1824
|
var page = this.pageCache[data.pageNum - 1];
|
1282
1825
|
var intentState = page.intentStates[data.intent];
|
1826
|
+
|
1283
1827
|
if (intentState.displayReadyCapability) {
|
1284
1828
|
intentState.displayReadyCapability.reject(data.error);
|
1285
1829
|
} else {
|
1286
1830
|
throw new Error(data.error);
|
1287
1831
|
}
|
1832
|
+
|
1288
1833
|
if (intentState.operatorList) {
|
1289
1834
|
intentState.operatorList.lastChunk = true;
|
1835
|
+
|
1290
1836
|
for (var i = 0; i < intentState.renderTasks.length; i++) {
|
1291
1837
|
intentState.renderTasks[i].operatorListChanged();
|
1292
1838
|
}
|
1293
1839
|
}
|
1294
1840
|
}, this);
|
1295
|
-
messageHandler.on('UnsupportedFeature',
|
1296
|
-
if (this.destroyed) {
|
1297
|
-
return;
|
1298
|
-
}
|
1299
|
-
var loadingTask = this.loadingTask;
|
1300
|
-
if (loadingTask.onUnsupportedFeature) {
|
1301
|
-
loadingTask.onUnsupportedFeature(data.featureId);
|
1302
|
-
}
|
1303
|
-
}, this);
|
1841
|
+
messageHandler.on('UnsupportedFeature', this._onUnsupportedFeature, this);
|
1304
1842
|
messageHandler.on('JpegDecode', function (data) {
|
1305
1843
|
if (this.destroyed) {
|
1306
1844
|
return Promise.reject(new Error('Worker was destroyed'));
|
1307
1845
|
}
|
1846
|
+
|
1308
1847
|
if (typeof document === 'undefined') {
|
1309
1848
|
return Promise.reject(new Error('"document" is not defined.'));
|
1310
1849
|
}
|
1311
|
-
|
1312
|
-
var
|
1850
|
+
|
1851
|
+
var _data3 = _slicedToArray(data, 2),
|
1852
|
+
imageUrl = _data3[0],
|
1853
|
+
components = _data3[1];
|
1854
|
+
|
1313
1855
|
if (components !== 3 && components !== 1) {
|
1314
1856
|
return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
|
1315
1857
|
}
|
1858
|
+
|
1316
1859
|
return new Promise(function (resolve, reject) {
|
1317
1860
|
var img = new Image();
|
1861
|
+
|
1318
1862
|
img.onload = function () {
|
1319
1863
|
var width = img.width;
|
1320
1864
|
var height = img.height;
|
1321
1865
|
var size = width * height;
|
1322
1866
|
var rgbaLength = size * 4;
|
1323
|
-
var buf = new
|
1867
|
+
var buf = new Uint8ClampedArray(size * components);
|
1324
1868
|
var tmpCanvas = document.createElement('canvas');
|
1325
1869
|
tmpCanvas.width = width;
|
1326
1870
|
tmpCanvas.height = height;
|
1327
1871
|
var tmpCtx = tmpCanvas.getContext('2d');
|
1328
1872
|
tmpCtx.drawImage(img, 0, 0);
|
1329
1873
|
var data = tmpCtx.getImageData(0, 0, width, height).data;
|
1330
|
-
|
1874
|
+
|
1331
1875
|
if (components === 3) {
|
1332
|
-
for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
|
1876
|
+
for (var i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
|
1333
1877
|
buf[j] = data[i];
|
1334
1878
|
buf[j + 1] = data[i + 1];
|
1335
1879
|
buf[j + 2] = data[i + 2];
|
1336
1880
|
}
|
1337
1881
|
} else if (components === 1) {
|
1338
|
-
for (
|
1339
|
-
buf[
|
1882
|
+
for (var _i2 = 0, _j = 0; _i2 < rgbaLength; _i2 += 4, _j++) {
|
1883
|
+
buf[_j] = data[_i2];
|
1340
1884
|
}
|
1341
1885
|
}
|
1886
|
+
|
1342
1887
|
resolve({
|
1343
1888
|
data: buf,
|
1344
1889
|
width: width,
|
1345
1890
|
height: height
|
1346
1891
|
});
|
1347
1892
|
};
|
1893
|
+
|
1348
1894
|
img.onerror = function () {
|
1349
1895
|
reject(new Error('JpegDecode failed to load image'));
|
1350
1896
|
};
|
1897
|
+
|
1351
1898
|
img.src = imageUrl;
|
1352
1899
|
});
|
1353
1900
|
}, this);
|
@@ -1355,68 +1902,130 @@ var WorkerTransport = function WorkerTransportClosure() {
|
|
1355
1902
|
if (this.destroyed) {
|
1356
1903
|
return Promise.reject(new Error('Worker was destroyed'));
|
1357
1904
|
}
|
1358
|
-
|
1905
|
+
|
1906
|
+
return this.CMapReaderFactory.fetch({
|
1907
|
+
name: data.name
|
1908
|
+
});
|
1359
1909
|
}, this);
|
1360
|
-
}
|
1361
|
-
|
1910
|
+
}
|
1911
|
+
}, {
|
1912
|
+
key: "_onUnsupportedFeature",
|
1913
|
+
value: function _onUnsupportedFeature(_ref10) {
|
1914
|
+
var featureId = _ref10.featureId;
|
1915
|
+
|
1916
|
+
if (this.destroyed) {
|
1917
|
+
return;
|
1918
|
+
}
|
1919
|
+
|
1920
|
+
if (this.loadingTask.onUnsupportedFeature) {
|
1921
|
+
this.loadingTask.onUnsupportedFeature(featureId);
|
1922
|
+
}
|
1923
|
+
}
|
1924
|
+
}, {
|
1925
|
+
key: "getData",
|
1926
|
+
value: function getData() {
|
1362
1927
|
return this.messageHandler.sendWithPromise('GetData', null);
|
1363
|
-
}
|
1364
|
-
|
1928
|
+
}
|
1929
|
+
}, {
|
1930
|
+
key: "getPage",
|
1931
|
+
value: function getPage(pageNumber) {
|
1365
1932
|
var _this13 = this;
|
1366
1933
|
|
1367
1934
|
if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
|
1368
1935
|
return Promise.reject(new Error('Invalid page request'));
|
1369
1936
|
}
|
1937
|
+
|
1370
1938
|
var pageIndex = pageNumber - 1;
|
1939
|
+
|
1371
1940
|
if (pageIndex in this.pagePromises) {
|
1372
1941
|
return this.pagePromises[pageIndex];
|
1373
1942
|
}
|
1374
|
-
|
1943
|
+
|
1944
|
+
var promise = this.messageHandler.sendWithPromise('GetPage', {
|
1945
|
+
pageIndex: pageIndex
|
1946
|
+
}).then(function (pageInfo) {
|
1375
1947
|
if (_this13.destroyed) {
|
1376
1948
|
throw new Error('Transport destroyed');
|
1377
1949
|
}
|
1950
|
+
|
1378
1951
|
var page = new PDFPageProxy(pageIndex, pageInfo, _this13, _this13._params.pdfBug);
|
1379
1952
|
_this13.pageCache[pageIndex] = page;
|
1380
1953
|
return page;
|
1381
1954
|
});
|
1382
1955
|
this.pagePromises[pageIndex] = promise;
|
1383
1956
|
return promise;
|
1384
|
-
}
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1957
|
+
}
|
1958
|
+
}, {
|
1959
|
+
key: "getPageIndex",
|
1960
|
+
value: function getPageIndex(ref) {
|
1961
|
+
return this.messageHandler.sendWithPromise('GetPageIndex', {
|
1962
|
+
ref: ref
|
1963
|
+
}).catch(function (reason) {
|
1388
1964
|
return Promise.reject(new Error(reason));
|
1389
1965
|
});
|
1390
|
-
}
|
1391
|
-
|
1966
|
+
}
|
1967
|
+
}, {
|
1968
|
+
key: "getAnnotations",
|
1969
|
+
value: function getAnnotations(pageIndex, intent) {
|
1392
1970
|
return this.messageHandler.sendWithPromise('GetAnnotations', {
|
1393
1971
|
pageIndex: pageIndex,
|
1394
1972
|
intent: intent
|
1395
1973
|
});
|
1396
|
-
}
|
1397
|
-
|
1974
|
+
}
|
1975
|
+
}, {
|
1976
|
+
key: "getDestinations",
|
1977
|
+
value: function getDestinations() {
|
1398
1978
|
return this.messageHandler.sendWithPromise('GetDestinations', null);
|
1399
|
-
}
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1979
|
+
}
|
1980
|
+
}, {
|
1981
|
+
key: "getDestination",
|
1982
|
+
value: function getDestination(id) {
|
1983
|
+
if (typeof id !== 'string') {
|
1984
|
+
return Promise.reject(new Error('Invalid destination request.'));
|
1985
|
+
}
|
1986
|
+
|
1987
|
+
return this.messageHandler.sendWithPromise('GetDestination', {
|
1988
|
+
id: id
|
1989
|
+
});
|
1990
|
+
}
|
1991
|
+
}, {
|
1992
|
+
key: "getPageLabels",
|
1993
|
+
value: function getPageLabels() {
|
1404
1994
|
return this.messageHandler.sendWithPromise('GetPageLabels', null);
|
1405
|
-
}
|
1406
|
-
|
1995
|
+
}
|
1996
|
+
}, {
|
1997
|
+
key: "getPageMode",
|
1998
|
+
value: function getPageMode() {
|
1407
1999
|
return this.messageHandler.sendWithPromise('GetPageMode', null);
|
1408
|
-
}
|
1409
|
-
|
1410
|
-
|
2000
|
+
}
|
2001
|
+
}, {
|
2002
|
+
key: "getOpenActionDestination",
|
2003
|
+
value: function getOpenActionDestination() {
|
2004
|
+
return this.messageHandler.sendWithPromise('getOpenActionDestination', null);
|
2005
|
+
}
|
2006
|
+
}, {
|
2007
|
+
key: "getAttachments",
|
2008
|
+
value: function getAttachments() {
|
1411
2009
|
return this.messageHandler.sendWithPromise('GetAttachments', null);
|
1412
|
-
}
|
1413
|
-
|
2010
|
+
}
|
2011
|
+
}, {
|
2012
|
+
key: "getJavaScript",
|
2013
|
+
value: function getJavaScript() {
|
1414
2014
|
return this.messageHandler.sendWithPromise('GetJavaScript', null);
|
1415
|
-
}
|
1416
|
-
|
2015
|
+
}
|
2016
|
+
}, {
|
2017
|
+
key: "getOutline",
|
2018
|
+
value: function getOutline() {
|
1417
2019
|
return this.messageHandler.sendWithPromise('GetOutline', null);
|
1418
|
-
}
|
1419
|
-
|
2020
|
+
}
|
2021
|
+
}, {
|
2022
|
+
key: "getPermissions",
|
2023
|
+
value: function getPermissions() {
|
2024
|
+
return this.messageHandler.sendWithPromise('GetPermissions', null);
|
2025
|
+
}
|
2026
|
+
}, {
|
2027
|
+
key: "getMetadata",
|
2028
|
+
value: function getMetadata() {
|
1420
2029
|
var _this14 = this;
|
1421
2030
|
|
1422
2031
|
return this.messageHandler.sendWithPromise('GetMetadata', null).then(function (results) {
|
@@ -1426,239 +2035,355 @@ var WorkerTransport = function WorkerTransportClosure() {
|
|
1426
2035
|
contentDispositionFilename: _this14._fullReader ? _this14._fullReader.filename : null
|
1427
2036
|
};
|
1428
2037
|
});
|
1429
|
-
}
|
1430
|
-
|
2038
|
+
}
|
2039
|
+
}, {
|
2040
|
+
key: "getStats",
|
2041
|
+
value: function getStats() {
|
1431
2042
|
return this.messageHandler.sendWithPromise('GetStats', null);
|
1432
|
-
}
|
1433
|
-
|
2043
|
+
}
|
2044
|
+
}, {
|
2045
|
+
key: "startCleanup",
|
2046
|
+
value: function startCleanup() {
|
1434
2047
|
var _this15 = this;
|
1435
2048
|
|
1436
2049
|
this.messageHandler.sendWithPromise('Cleanup', null).then(function () {
|
1437
2050
|
for (var i = 0, ii = _this15.pageCache.length; i < ii; i++) {
|
1438
2051
|
var page = _this15.pageCache[i];
|
2052
|
+
|
1439
2053
|
if (page) {
|
1440
2054
|
page.cleanup();
|
1441
2055
|
}
|
1442
2056
|
}
|
2057
|
+
|
1443
2058
|
_this15.commonObjs.clear();
|
2059
|
+
|
1444
2060
|
_this15.fontLoader.clear();
|
1445
2061
|
});
|
1446
|
-
}
|
1447
|
-
|
2062
|
+
}
|
2063
|
+
}, {
|
2064
|
+
key: "loadingParams",
|
2065
|
+
get: function get() {
|
1448
2066
|
var params = this._params;
|
1449
2067
|
return (0, _util.shadow)(this, 'loadingParams', {
|
1450
|
-
disableRange: params.disableRange,
|
1451
|
-
disableStream: params.disableStream,
|
1452
2068
|
disableAutoFetch: params.disableAutoFetch,
|
1453
|
-
disableCreateObjectURL: params.disableCreateObjectURL
|
2069
|
+
disableCreateObjectURL: params.disableCreateObjectURL,
|
2070
|
+
disableFontFace: params.disableFontFace,
|
2071
|
+
nativeImageDecoderSupport: params.nativeImageDecoderSupport
|
1454
2072
|
});
|
1455
2073
|
}
|
1456
|
-
};
|
2074
|
+
}]);
|
2075
|
+
|
1457
2076
|
return WorkerTransport;
|
1458
2077
|
}();
|
1459
|
-
|
2078
|
+
|
2079
|
+
var PDFObjects =
|
2080
|
+
/*#__PURE__*/
|
2081
|
+
function () {
|
1460
2082
|
function PDFObjects() {
|
1461
|
-
this
|
2083
|
+
_classCallCheck(this, PDFObjects);
|
2084
|
+
|
2085
|
+
this._objs = Object.create(null);
|
1462
2086
|
}
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
2087
|
+
|
2088
|
+
_createClass(PDFObjects, [{
|
2089
|
+
key: "_ensureObj",
|
2090
|
+
value: function _ensureObj(objId) {
|
2091
|
+
if (this._objs[objId]) {
|
2092
|
+
return this._objs[objId];
|
1467
2093
|
}
|
1468
|
-
|
2094
|
+
|
2095
|
+
return this._objs[objId] = {
|
1469
2096
|
capability: (0, _util.createPromiseCapability)(),
|
1470
2097
|
data: null,
|
1471
2098
|
resolved: false
|
1472
2099
|
};
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
2100
|
+
}
|
2101
|
+
}, {
|
2102
|
+
key: "get",
|
2103
|
+
value: function get(objId) {
|
2104
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
2105
|
+
|
1477
2106
|
if (callback) {
|
1478
|
-
this.
|
2107
|
+
this._ensureObj(objId).capability.promise.then(callback);
|
2108
|
+
|
1479
2109
|
return null;
|
1480
2110
|
}
|
1481
|
-
|
2111
|
+
|
2112
|
+
var obj = this._objs[objId];
|
2113
|
+
|
1482
2114
|
if (!obj || !obj.resolved) {
|
1483
|
-
throw new Error(
|
2115
|
+
throw new Error("Requesting object that isn't resolved yet ".concat(objId, "."));
|
1484
2116
|
}
|
2117
|
+
|
1485
2118
|
return obj.data;
|
1486
|
-
}
|
1487
|
-
|
1488
|
-
|
2119
|
+
}
|
2120
|
+
}, {
|
2121
|
+
key: "has",
|
2122
|
+
value: function has(objId) {
|
2123
|
+
var obj = this._objs[objId];
|
2124
|
+
return obj ? obj.resolved : false;
|
2125
|
+
}
|
2126
|
+
}, {
|
2127
|
+
key: "resolve",
|
2128
|
+
value: function resolve(objId, data) {
|
2129
|
+
var obj = this._ensureObj(objId);
|
2130
|
+
|
1489
2131
|
obj.resolved = true;
|
1490
2132
|
obj.data = data;
|
1491
2133
|
obj.capability.resolve(data);
|
1492
|
-
},
|
1493
|
-
isResolved: function PDFObjects_isResolved(objId) {
|
1494
|
-
var objs = this.objs;
|
1495
|
-
if (!objs[objId]) {
|
1496
|
-
return false;
|
1497
|
-
}
|
1498
|
-
return objs[objId].resolved;
|
1499
|
-
},
|
1500
|
-
hasData: function PDFObjects_hasData(objId) {
|
1501
|
-
return this.isResolved(objId);
|
1502
|
-
},
|
1503
|
-
getData: function PDFObjects_getData(objId) {
|
1504
|
-
var objs = this.objs;
|
1505
|
-
if (!objs[objId] || !objs[objId].resolved) {
|
1506
|
-
return null;
|
1507
|
-
}
|
1508
|
-
return objs[objId].data;
|
1509
|
-
},
|
1510
|
-
clear: function PDFObjects_clear() {
|
1511
|
-
this.objs = Object.create(null);
|
1512
2134
|
}
|
1513
|
-
}
|
2135
|
+
}, {
|
2136
|
+
key: "clear",
|
2137
|
+
value: function clear() {
|
2138
|
+
this._objs = Object.create(null);
|
2139
|
+
}
|
2140
|
+
}]);
|
2141
|
+
|
1514
2142
|
return PDFObjects;
|
1515
2143
|
}();
|
1516
|
-
|
2144
|
+
|
2145
|
+
var RenderTask =
|
2146
|
+
/*#__PURE__*/
|
2147
|
+
function () {
|
1517
2148
|
function RenderTask(internalRenderTask) {
|
2149
|
+
_classCallCheck(this, RenderTask);
|
2150
|
+
|
1518
2151
|
this._internalRenderTask = internalRenderTask;
|
1519
2152
|
this.onContinue = null;
|
1520
2153
|
}
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
cancel: function RenderTask_cancel() {
|
2154
|
+
|
2155
|
+
_createClass(RenderTask, [{
|
2156
|
+
key: "cancel",
|
2157
|
+
value: function cancel() {
|
1526
2158
|
this._internalRenderTask.cancel();
|
1527
|
-
}
|
1528
|
-
|
2159
|
+
}
|
2160
|
+
}, {
|
2161
|
+
key: "then",
|
2162
|
+
value: function then(onFulfilled, onRejected) {
|
2163
|
+
(0, _util.deprecated)('RenderTask.then method, use the `promise` getter instead.');
|
1529
2164
|
return this.promise.then.apply(this.promise, arguments);
|
1530
2165
|
}
|
1531
|
-
}
|
2166
|
+
}, {
|
2167
|
+
key: "promise",
|
2168
|
+
get: function get() {
|
2169
|
+
return this._internalRenderTask.capability.promise;
|
2170
|
+
}
|
2171
|
+
}]);
|
2172
|
+
|
1532
2173
|
return RenderTask;
|
1533
2174
|
}();
|
2175
|
+
|
1534
2176
|
var InternalRenderTask = function InternalRenderTaskClosure() {
|
1535
|
-
var canvasInRendering = new
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
}
|
1567
|
-
canvasInRendering.set(this._canvas, this);
|
1568
|
-
}
|
1569
|
-
if (this.cancelled) {
|
1570
|
-
return;
|
1571
|
-
}
|
1572
|
-
if (this._pdfBug && _global_scope2.default.StepperManager && _global_scope2.default.StepperManager.enabled) {
|
1573
|
-
this.stepper = _global_scope2.default.StepperManager.create(this.pageNumber - 1);
|
1574
|
-
this.stepper.init(this.operatorList);
|
1575
|
-
this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
|
1576
|
-
}
|
1577
|
-
var params = this.params;
|
1578
|
-
this.gfx = new _canvas.CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext, params.imageLayer);
|
1579
|
-
this.gfx.beginDrawing({
|
1580
|
-
transform: params.transform,
|
1581
|
-
viewport: params.viewport,
|
1582
|
-
transparency: transparency,
|
1583
|
-
background: params.background
|
1584
|
-
});
|
1585
|
-
this.operatorListIdx = 0;
|
1586
|
-
this.graphicsReady = true;
|
1587
|
-
if (this.graphicsReadyCallback) {
|
1588
|
-
this.graphicsReadyCallback();
|
1589
|
-
}
|
1590
|
-
},
|
1591
|
-
cancel: function InternalRenderTask_cancel() {
|
2177
|
+
var canvasInRendering = new WeakSet();
|
2178
|
+
|
2179
|
+
var InternalRenderTask =
|
2180
|
+
/*#__PURE__*/
|
2181
|
+
function () {
|
2182
|
+
function InternalRenderTask(_ref11) {
|
2183
|
+
var callback = _ref11.callback,
|
2184
|
+
params = _ref11.params,
|
2185
|
+
objs = _ref11.objs,
|
2186
|
+
commonObjs = _ref11.commonObjs,
|
2187
|
+
operatorList = _ref11.operatorList,
|
2188
|
+
pageNumber = _ref11.pageNumber,
|
2189
|
+
canvasFactory = _ref11.canvasFactory,
|
2190
|
+
webGLContext = _ref11.webGLContext,
|
2191
|
+
_ref11$useRequestAnim = _ref11.useRequestAnimationFrame,
|
2192
|
+
useRequestAnimationFrame = _ref11$useRequestAnim === void 0 ? false : _ref11$useRequestAnim,
|
2193
|
+
_ref11$pdfBug = _ref11.pdfBug,
|
2194
|
+
pdfBug = _ref11$pdfBug === void 0 ? false : _ref11$pdfBug;
|
2195
|
+
|
2196
|
+
_classCallCheck(this, InternalRenderTask);
|
2197
|
+
|
2198
|
+
this.callback = callback;
|
2199
|
+
this.params = params;
|
2200
|
+
this.objs = objs;
|
2201
|
+
this.commonObjs = commonObjs;
|
2202
|
+
this.operatorListIdx = null;
|
2203
|
+
this.operatorList = operatorList;
|
2204
|
+
this.pageNumber = pageNumber;
|
2205
|
+
this.canvasFactory = canvasFactory;
|
2206
|
+
this.webGLContext = webGLContext;
|
2207
|
+
this._pdfBug = pdfBug;
|
1592
2208
|
this.running = false;
|
1593
|
-
this.
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
this.
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
2209
|
+
this.graphicsReadyCallback = null;
|
2210
|
+
this.graphicsReady = false;
|
2211
|
+
this._useRequestAnimationFrame = useRequestAnimationFrame === true && typeof window !== 'undefined';
|
2212
|
+
this.cancelled = false;
|
2213
|
+
this.capability = (0, _util.createPromiseCapability)();
|
2214
|
+
this.task = new RenderTask(this);
|
2215
|
+
this._continueBound = this._continue.bind(this);
|
2216
|
+
this._scheduleNextBound = this._scheduleNext.bind(this);
|
2217
|
+
this._nextBound = this._next.bind(this);
|
2218
|
+
this._canvas = params.canvasContext.canvas;
|
2219
|
+
}
|
2220
|
+
|
2221
|
+
_createClass(InternalRenderTask, [{
|
2222
|
+
key: "initializeGraphics",
|
2223
|
+
value: function initializeGraphics() {
|
2224
|
+
var transparency = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
2225
|
+
|
2226
|
+
if (this.cancelled) {
|
2227
|
+
return;
|
2228
|
+
}
|
2229
|
+
|
2230
|
+
if (this._canvas) {
|
2231
|
+
if (canvasInRendering.has(this._canvas)) {
|
2232
|
+
throw new Error('Cannot use the same canvas during multiple render() operations. ' + 'Use different canvas or ensure previous operations were ' + 'cancelled or completed.');
|
2233
|
+
}
|
2234
|
+
|
2235
|
+
canvasInRendering.add(this._canvas);
|
2236
|
+
}
|
2237
|
+
|
2238
|
+
if (this._pdfBug && _global_scope.default.StepperManager && _global_scope.default.StepperManager.enabled) {
|
2239
|
+
this.stepper = _global_scope.default.StepperManager.create(this.pageNumber - 1);
|
2240
|
+
this.stepper.init(this.operatorList);
|
2241
|
+
this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
|
2242
|
+
}
|
2243
|
+
|
2244
|
+
var _this$params = this.params,
|
2245
|
+
canvasContext = _this$params.canvasContext,
|
2246
|
+
viewport = _this$params.viewport,
|
2247
|
+
transform = _this$params.transform,
|
2248
|
+
imageLayer = _this$params.imageLayer,
|
2249
|
+
background = _this$params.background;
|
2250
|
+
this.gfx = new _canvas.CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext, imageLayer);
|
2251
|
+
this.gfx.beginDrawing({
|
2252
|
+
transform: transform,
|
2253
|
+
viewport: viewport,
|
2254
|
+
transparency: transparency,
|
2255
|
+
background: background
|
2256
|
+
});
|
2257
|
+
this.operatorListIdx = 0;
|
2258
|
+
this.graphicsReady = true;
|
2259
|
+
|
2260
|
+
if (this.graphicsReadyCallback) {
|
2261
|
+
this.graphicsReadyCallback();
|
1603
2262
|
}
|
1604
|
-
return;
|
1605
|
-
}
|
1606
|
-
if (this.stepper) {
|
1607
|
-
this.stepper.updateOperatorList(this.operatorList);
|
1608
|
-
}
|
1609
|
-
if (this.running) {
|
1610
|
-
return;
|
1611
|
-
}
|
1612
|
-
this._continue();
|
1613
|
-
},
|
1614
|
-
_continue: function InternalRenderTask__continue() {
|
1615
|
-
this.running = true;
|
1616
|
-
if (this.cancelled) {
|
1617
|
-
return;
|
1618
|
-
}
|
1619
|
-
if (this.task.onContinue) {
|
1620
|
-
this.task.onContinue(this._scheduleNextBound);
|
1621
|
-
} else {
|
1622
|
-
this._scheduleNext();
|
1623
|
-
}
|
1624
|
-
},
|
1625
|
-
_scheduleNext: function InternalRenderTask__scheduleNext() {
|
1626
|
-
if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
|
1627
|
-
window.requestAnimationFrame(this._nextBound);
|
1628
|
-
} else {
|
1629
|
-
Promise.resolve(undefined).then(this._nextBound);
|
1630
|
-
}
|
1631
|
-
},
|
1632
|
-
_next: function InternalRenderTask__next() {
|
1633
|
-
if (this.cancelled) {
|
1634
|
-
return;
|
1635
2263
|
}
|
1636
|
-
|
1637
|
-
|
2264
|
+
}, {
|
2265
|
+
key: "cancel",
|
2266
|
+
value: function cancel() {
|
2267
|
+
var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
1638
2268
|
this.running = false;
|
1639
|
-
|
2269
|
+
this.cancelled = true;
|
2270
|
+
|
2271
|
+
if (this.gfx) {
|
1640
2272
|
this.gfx.endDrawing();
|
1641
|
-
|
1642
|
-
|
2273
|
+
}
|
2274
|
+
|
2275
|
+
if (this._canvas) {
|
2276
|
+
canvasInRendering.delete(this._canvas);
|
2277
|
+
}
|
2278
|
+
|
2279
|
+
this.callback(error || new _dom_utils.RenderingCancelledException("Rendering cancelled, page ".concat(this.pageNumber), 'canvas'));
|
2280
|
+
}
|
2281
|
+
}, {
|
2282
|
+
key: "operatorListChanged",
|
2283
|
+
value: function operatorListChanged() {
|
2284
|
+
if (!this.graphicsReady) {
|
2285
|
+
if (!this.graphicsReadyCallback) {
|
2286
|
+
this.graphicsReadyCallback = this._continueBound;
|
1643
2287
|
}
|
1644
|
-
|
2288
|
+
|
2289
|
+
return;
|
2290
|
+
}
|
2291
|
+
|
2292
|
+
if (this.stepper) {
|
2293
|
+
this.stepper.updateOperatorList(this.operatorList);
|
1645
2294
|
}
|
2295
|
+
|
2296
|
+
if (this.running) {
|
2297
|
+
return;
|
2298
|
+
}
|
2299
|
+
|
2300
|
+
this._continue();
|
1646
2301
|
}
|
1647
|
-
}
|
1648
|
-
|
2302
|
+
}, {
|
2303
|
+
key: "_continue",
|
2304
|
+
value: function _continue() {
|
2305
|
+
this.running = true;
|
2306
|
+
|
2307
|
+
if (this.cancelled) {
|
2308
|
+
return;
|
2309
|
+
}
|
2310
|
+
|
2311
|
+
if (this.task.onContinue) {
|
2312
|
+
this.task.onContinue(this._scheduleNextBound);
|
2313
|
+
} else {
|
2314
|
+
this._scheduleNext();
|
2315
|
+
}
|
2316
|
+
}
|
2317
|
+
}, {
|
2318
|
+
key: "_scheduleNext",
|
2319
|
+
value: function _scheduleNext() {
|
2320
|
+
var _this16 = this;
|
2321
|
+
|
2322
|
+
if (this._useRequestAnimationFrame) {
|
2323
|
+
window.requestAnimationFrame(function () {
|
2324
|
+
_this16._nextBound().catch(_this16.cancel.bind(_this16));
|
2325
|
+
});
|
2326
|
+
} else {
|
2327
|
+
Promise.resolve().then(this._nextBound).catch(this.cancel.bind(this));
|
2328
|
+
}
|
2329
|
+
}
|
2330
|
+
}, {
|
2331
|
+
key: "_next",
|
2332
|
+
value: function () {
|
2333
|
+
var _next2 = _asyncToGenerator(
|
2334
|
+
/*#__PURE__*/
|
2335
|
+
_regenerator.default.mark(function _callee() {
|
2336
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
2337
|
+
while (1) {
|
2338
|
+
switch (_context.prev = _context.next) {
|
2339
|
+
case 0:
|
2340
|
+
if (!this.cancelled) {
|
2341
|
+
_context.next = 2;
|
2342
|
+
break;
|
2343
|
+
}
|
2344
|
+
|
2345
|
+
return _context.abrupt("return");
|
2346
|
+
|
2347
|
+
case 2:
|
2348
|
+
this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
|
2349
|
+
|
2350
|
+
if (this.operatorListIdx === this.operatorList.argsArray.length) {
|
2351
|
+
this.running = false;
|
2352
|
+
|
2353
|
+
if (this.operatorList.lastChunk) {
|
2354
|
+
this.gfx.endDrawing();
|
2355
|
+
|
2356
|
+
if (this._canvas) {
|
2357
|
+
canvasInRendering.delete(this._canvas);
|
2358
|
+
}
|
2359
|
+
|
2360
|
+
this.callback();
|
2361
|
+
}
|
2362
|
+
}
|
2363
|
+
|
2364
|
+
case 4:
|
2365
|
+
case "end":
|
2366
|
+
return _context.stop();
|
2367
|
+
}
|
2368
|
+
}
|
2369
|
+
}, _callee, this);
|
2370
|
+
}));
|
2371
|
+
|
2372
|
+
function _next() {
|
2373
|
+
return _next2.apply(this, arguments);
|
2374
|
+
}
|
2375
|
+
|
2376
|
+
return _next;
|
2377
|
+
}()
|
2378
|
+
}]);
|
2379
|
+
|
2380
|
+
return InternalRenderTask;
|
2381
|
+
}();
|
2382
|
+
|
1649
2383
|
return InternalRenderTask;
|
1650
2384
|
}();
|
1651
|
-
|
1652
|
-
|
1653
|
-
exports.version = version = '2.0.487';
|
1654
|
-
exports.build = build = '2275485c';
|
1655
|
-
}
|
1656
|
-
exports.getDocument = getDocument;
|
1657
|
-
exports.LoopbackPort = LoopbackPort;
|
1658
|
-
exports.PDFDataRangeTransport = PDFDataRangeTransport;
|
1659
|
-
exports.PDFWorker = PDFWorker;
|
1660
|
-
exports.PDFDocumentProxy = PDFDocumentProxy;
|
1661
|
-
exports.PDFPageProxy = PDFPageProxy;
|
1662
|
-
exports.setPDFNetworkStreamFactory = setPDFNetworkStreamFactory;
|
2385
|
+
|
2386
|
+
var version = '2.1.266';
|
1663
2387
|
exports.version = version;
|
2388
|
+
var build = '81f5835c';
|
1664
2389
|
exports.build = build;
|