|
@@ -23,8 +23,8 @@
|
|
|
}
|
|
|
}(this, function (exports) {
|
|
|
'use strict';
|
|
|
- var pdfjsVersion = '1.6.419';
|
|
|
- var pdfjsBuild = '4e62562';
|
|
|
+ var pdfjsVersion = '1.6.422';
|
|
|
+ var pdfjsBuild = 'aabfb77';
|
|
|
var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
|
|
|
var pdfjsLibs = {};
|
|
|
(function pdfjsWrapper() {
|
|
@@ -47211,6 +47211,7 @@
|
|
|
this.fontLoader = new FontLoader(loadingTask.docId);
|
|
|
this.destroyed = false;
|
|
|
this.destroyCapability = null;
|
|
|
+ this._passwordCapability = null;
|
|
|
this.pageCache = [];
|
|
|
this.pagePromises = [];
|
|
|
this.downloadInfoCapability = createPromiseCapability();
|
|
@@ -47223,6 +47224,9 @@
|
|
|
}
|
|
|
this.destroyed = true;
|
|
|
this.destroyCapability = createPromiseCapability();
|
|
|
+ if (this._passwordCapability) {
|
|
|
+ this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
|
|
|
+ }
|
|
|
var waitOn = [];
|
|
|
this.pageCache.forEach(function (page) {
|
|
|
if (page) {
|
|
@@ -47250,9 +47254,7 @@
|
|
|
},
|
|
|
setupMessageHandler: function WorkerTransport_setupMessageHandler() {
|
|
|
var messageHandler = this.messageHandler;
|
|
|
- function updatePassword(password) {
|
|
|
- messageHandler.send('UpdatePassword', password);
|
|
|
- }
|
|
|
+ var loadingTask = this.loadingTask;
|
|
|
var pdfDataRangeTransport = this.pdfDataRangeTransport;
|
|
|
if (pdfDataRangeTransport) {
|
|
|
pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
|
|
@@ -47279,18 +47281,19 @@
|
|
|
this.pdfDocument = pdfDocument;
|
|
|
loadingTask._capability.resolve(pdfDocument);
|
|
|
}, this);
|
|
|
- messageHandler.on('NeedPassword', function transportNeedPassword(exception) {
|
|
|
- var loadingTask = this.loadingTask;
|
|
|
+ messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
|
|
|
+ this._passwordCapability = createPromiseCapability();
|
|
|
if (loadingTask.onPassword) {
|
|
|
- return loadingTask.onPassword(updatePassword, PasswordResponses.NEED_PASSWORD);
|
|
|
+ var updatePassword = function (password) {
|
|
|
+ this._passwordCapability.resolve({ password: password });
|
|
|
+ }.bind(this);
|
|
|
+ loadingTask.onPassword(updatePassword, exception.code);
|
|
|
+ } else {
|
|
|
+ this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
|
|
|
}
|
|
|
- loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
|
|
|
+ return this._passwordCapability.promise;
|
|
|
}, this);
|
|
|
- messageHandler.on('IncorrectPassword', function transportIncorrectPassword(exception) {
|
|
|
- var loadingTask = this.loadingTask;
|
|
|
- if (loadingTask.onPassword) {
|
|
|
- return loadingTask.onPassword(updatePassword, PasswordResponses.INCORRECT_PASSWORD);
|
|
|
- }
|
|
|
+ messageHandler.on('PasswordException', function transportPasswordException(exception) {
|
|
|
loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
|
|
|
}, this);
|
|
|
messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
|
|
@@ -49989,12 +49992,12 @@
|
|
|
return Catalog;
|
|
|
}();
|
|
|
var XRef = function XRefClosure() {
|
|
|
- function XRef(stream, password) {
|
|
|
+ function XRef(stream, pdfManager) {
|
|
|
this.stream = stream;
|
|
|
+ this.pdfManager = pdfManager;
|
|
|
this.entries = [];
|
|
|
this.xrefstms = Object.create(null);
|
|
|
this.cache = [];
|
|
|
- this.password = password;
|
|
|
this.stats = {
|
|
|
streamTypes: [],
|
|
|
fontTypes: []
|
|
@@ -50015,11 +50018,11 @@
|
|
|
trailerDict.assignXref(this);
|
|
|
this.trailer = trailerDict;
|
|
|
var encrypt = trailerDict.get('Encrypt');
|
|
|
- if (encrypt) {
|
|
|
+ if (isDict(encrypt)) {
|
|
|
var ids = trailerDict.get('ID');
|
|
|
var fileId = ids && ids.length ? ids[0] : '';
|
|
|
encrypt.suppressEncryption = true;
|
|
|
- this.encrypt = new CipherTransformFactory(encrypt, fileId, this.password);
|
|
|
+ this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
|
|
|
}
|
|
|
if (!(this.root = trailerDict.get('Root'))) {
|
|
|
error('Invalid root reference');
|
|
@@ -55552,21 +55555,19 @@
|
|
|
var PDFDocument = function PDFDocumentClosure() {
|
|
|
var FINGERPRINT_FIRST_BYTES = 1024;
|
|
|
var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
|
|
|
- function PDFDocument(pdfManager, arg, password) {
|
|
|
+ function PDFDocument(pdfManager, arg) {
|
|
|
+ var stream;
|
|
|
if (isStream(arg)) {
|
|
|
- init.call(this, pdfManager, arg, password);
|
|
|
+ stream = arg;
|
|
|
} else if (isArrayBuffer(arg)) {
|
|
|
- init.call(this, pdfManager, new Stream(arg), password);
|
|
|
+ stream = new Stream(arg);
|
|
|
} else {
|
|
|
error('PDFDocument: Unknown argument type');
|
|
|
}
|
|
|
- }
|
|
|
- function init(pdfManager, stream, password) {
|
|
|
assert(stream.length > 0, 'stream must have data');
|
|
|
this.pdfManager = pdfManager;
|
|
|
this.stream = stream;
|
|
|
- var xref = new XRef(this.stream, password, pdfManager);
|
|
|
- this.xref = xref;
|
|
|
+ this.xref = new XRef(stream, pdfManager);
|
|
|
}
|
|
|
function find(stream, needle, limit, backwards) {
|
|
|
var pos = stream.pos;
|
|
@@ -55799,6 +55800,9 @@
|
|
|
get docId() {
|
|
|
return this._docId;
|
|
|
},
|
|
|
+ get password() {
|
|
|
+ return this._password;
|
|
|
+ },
|
|
|
get docBaseUrl() {
|
|
|
var docBaseUrl = null;
|
|
|
if (this._docBaseUrl) {
|
|
@@ -55842,14 +55846,7 @@
|
|
|
return new NotImplementedException();
|
|
|
},
|
|
|
updatePassword: function BasePdfManager_updatePassword(password) {
|
|
|
- this.pdfDocument.xref.password = this.password = password;
|
|
|
- if (this._passwordChangedCapability) {
|
|
|
- this._passwordChangedCapability.resolve();
|
|
|
- }
|
|
|
- },
|
|
|
- passwordChanged: function BasePdfManager_passwordChanged() {
|
|
|
- this._passwordChangedCapability = createPromiseCapability();
|
|
|
- return this._passwordChangedCapability.promise;
|
|
|
+ this._password = password;
|
|
|
},
|
|
|
terminate: function BasePdfManager_terminate() {
|
|
|
return new NotImplementedException();
|
|
@@ -55860,10 +55857,11 @@
|
|
|
var LocalPdfManager = function LocalPdfManagerClosure() {
|
|
|
function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
|
|
|
this._docId = docId;
|
|
|
+ this._password = password;
|
|
|
this._docBaseUrl = docBaseUrl;
|
|
|
this.evaluatorOptions = evaluatorOptions;
|
|
|
var stream = new Stream(data);
|
|
|
- this.pdfDocument = new PDFDocument(this, stream, password);
|
|
|
+ this.pdfDocument = new PDFDocument(this, stream);
|
|
|
this._loadedStreamCapability = createPromiseCapability();
|
|
|
this._loadedStreamCapability.resolve(stream);
|
|
|
}
|
|
@@ -55902,6 +55900,7 @@
|
|
|
var NetworkPdfManager = function NetworkPdfManagerClosure() {
|
|
|
function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
|
|
|
this._docId = docId;
|
|
|
+ this._password = args.password;
|
|
|
this._docBaseUrl = docBaseUrl;
|
|
|
this.msgHandler = args.msgHandler;
|
|
|
this.evaluatorOptions = evaluatorOptions;
|
|
@@ -55913,7 +55912,7 @@
|
|
|
rangeChunkSize: args.rangeChunkSize
|
|
|
};
|
|
|
this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
|
|
|
- this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(), args.password);
|
|
|
+ this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
|
|
|
}
|
|
|
Util.inherit(NetworkPdfManager, BasePdfManager, {
|
|
|
ensure: function NetworkPdfManager_ensure(obj, prop, args) {
|
|
@@ -56415,18 +56414,23 @@
|
|
|
};
|
|
|
return pdfManagerCapability.promise;
|
|
|
}
|
|
|
- var setupDoc = function (data) {
|
|
|
- var onSuccess = function (doc) {
|
|
|
+ function setupDoc(data) {
|
|
|
+ function onSuccess(doc) {
|
|
|
ensureNotTerminated();
|
|
|
handler.send('GetDoc', { pdfInfo: doc });
|
|
|
- };
|
|
|
- var onFailure = function (e) {
|
|
|
+ }
|
|
|
+ function onFailure(e) {
|
|
|
if (e instanceof PasswordException) {
|
|
|
- if (e.code === PasswordResponses.NEED_PASSWORD) {
|
|
|
- handler.send('NeedPassword', e);
|
|
|
- } else if (e.code === PasswordResponses.INCORRECT_PASSWORD) {
|
|
|
- handler.send('IncorrectPassword', e);
|
|
|
- }
|
|
|
+ var task = new WorkerTask('PasswordException: response ' + e.code);
|
|
|
+ startWorkerTask(task);
|
|
|
+ handler.sendWithPromise('PasswordRequest', e).then(function (data) {
|
|
|
+ finishWorkerTask(task);
|
|
|
+ pdfManager.updatePassword(data.password);
|
|
|
+ pdfManagerReady();
|
|
|
+ }).catch(function (ex) {
|
|
|
+ finishWorkerTask(task);
|
|
|
+ handler.send('PasswordException', ex);
|
|
|
+ }.bind(null, e));
|
|
|
} else if (e instanceof InvalidPDFException) {
|
|
|
handler.send('InvalidPDF', e);
|
|
|
} else if (e instanceof MissingPDFException) {
|
|
@@ -56436,7 +56440,22 @@
|
|
|
} else {
|
|
|
handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
+ function pdfManagerReady() {
|
|
|
+ ensureNotTerminated();
|
|
|
+ loadDocument(false).then(onSuccess, function loadFailure(ex) {
|
|
|
+ ensureNotTerminated();
|
|
|
+ if (!(ex instanceof XRefParseException)) {
|
|
|
+ onFailure(ex);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ pdfManager.requestLoadedStream();
|
|
|
+ pdfManager.onLoadedStream().then(function () {
|
|
|
+ ensureNotTerminated();
|
|
|
+ loadDocument(true).then(onSuccess, onFailure);
|
|
|
+ });
|
|
|
+ }, onFailure);
|
|
|
+ }
|
|
|
ensureNotTerminated();
|
|
|
var cMapOptions = {
|
|
|
url: data.cMapUrl === undefined ? null : data.cMapUrl,
|
|
@@ -56458,25 +56477,8 @@
|
|
|
pdfManager.onLoadedStream().then(function (stream) {
|
|
|
handler.send('DataLoaded', { length: stream.bytes.byteLength });
|
|
|
});
|
|
|
- }).then(function pdfManagerReady() {
|
|
|
- ensureNotTerminated();
|
|
|
- loadDocument(false).then(onSuccess, function loadFailure(ex) {
|
|
|
- ensureNotTerminated();
|
|
|
- if (!(ex instanceof XRefParseException)) {
|
|
|
- if (ex instanceof PasswordException) {
|
|
|
- pdfManager.passwordChanged().then(pdfManagerReady);
|
|
|
- }
|
|
|
- onFailure(ex);
|
|
|
- return;
|
|
|
- }
|
|
|
- pdfManager.requestLoadedStream();
|
|
|
- pdfManager.onLoadedStream().then(function () {
|
|
|
- ensureNotTerminated();
|
|
|
- loadDocument(true).then(onSuccess, onFailure);
|
|
|
- });
|
|
|
- }, onFailure);
|
|
|
- }, onFailure);
|
|
|
- };
|
|
|
+ }).then(pdfManagerReady, onFailure);
|
|
|
+ }
|
|
|
handler.on('GetPage', function wphSetupGetPage(data) {
|
|
|
return pdfManager.getPage(data.pageIndex).then(function (page) {
|
|
|
var rotatePromise = pdfManager.ensure(page, 'rotate');
|
|
@@ -56536,9 +56538,6 @@
|
|
|
handler.on('GetStats', function wphSetupGetStats(data) {
|
|
|
return pdfManager.pdfDocument.xref.stats;
|
|
|
});
|
|
|
- handler.on('UpdatePassword', function wphSetupUpdatePassword(data) {
|
|
|
- pdfManager.updatePassword(data);
|
|
|
- });
|
|
|
handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
|
|
|
return pdfManager.getPage(data.pageIndex).then(function (page) {
|
|
|
return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
|