mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Fixes PDFDocumentProxy.getDownloadInfo API name (and refactoring)
This commit is contained in:
parent
3c6ac0dad5
commit
e5e9c6e243
4 changed files with 16 additions and 25 deletions
|
@ -234,7 +234,11 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
|||
PDFJS.disableCreateObjectURL = data.disableCreateObjectURL;
|
||||
PDFJS.verbosity = data.verbosity;
|
||||
|
||||
getPdfManager(data).then(function pdfManagerReady() {
|
||||
getPdfManager(data).then(function () {
|
||||
pdfManager.onLoadedStream().then(function(stream) {
|
||||
handler.send('DataLoaded', { length: stream.bytes.byteLength });
|
||||
});
|
||||
}).then(function pdfManagerReady() {
|
||||
loadDocument(false).then(onSuccess, function loadFailure(ex) {
|
||||
// Try again with recoveryMode == true
|
||||
if (!(ex instanceof XRefParseException)) {
|
||||
|
@ -301,12 +305,6 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
|||
});
|
||||
});
|
||||
|
||||
handler.on('DataLoaded', function wphSetupDataLoaded(data, deferred) {
|
||||
pdfManager.onLoadedStream().then(function(stream) {
|
||||
deferred.resolve({ length: stream.bytes.byteLength });
|
||||
});
|
||||
});
|
||||
|
||||
handler.on('UpdatePassword', function wphSetupUpdatePassword(data) {
|
||||
pdfManager.updatePassword(data);
|
||||
});
|
||||
|
|
|
@ -302,10 +302,11 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
|||
},
|
||||
/**
|
||||
* @return {Promise} A promise that is resolved when the document's data
|
||||
* is loaded
|
||||
* is loaded. It is resolved with an {Object} that contains the length
|
||||
* property that indicates size of the PDF data in bytes.
|
||||
*/
|
||||
dataLoaded: function PDFDocumentProxy_dataLoaded() {
|
||||
return this.transport.dataLoaded();
|
||||
getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
|
||||
return this.transport.downloadInfoPromise;
|
||||
},
|
||||
/**
|
||||
* Cleans up resources allocated by the document, e.g. created @font-face.
|
||||
|
@ -578,7 +579,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||
this.pageCache = [];
|
||||
this.pagePromises = [];
|
||||
this.embeddedFontsUsed = false;
|
||||
|
||||
this.downloadInfoPromise = new PDFJS.LegacyPromise();
|
||||
this.passwordCallback = null;
|
||||
|
||||
// If worker support isn't disabled explicit and the browser has worker
|
||||
|
@ -758,6 +759,10 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||
this.workerReadyPromise.reject(data.exception.message, data.exception);
|
||||
}, this);
|
||||
|
||||
messageHandler.on('DataLoaded', function transportPage(data) {
|
||||
this.downloadInfoPromise.resolve(data);
|
||||
}, this);
|
||||
|
||||
messageHandler.on('GetPage', function transportPage(data) {
|
||||
var pageInfo = data.pageInfo;
|
||||
var page = new PDFPageProxy(pageInfo, this);
|
||||
|
@ -924,18 +929,6 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||
});
|
||||
},
|
||||
|
||||
dataLoaded: function WorkerTransport_dataLoaded() {
|
||||
if (this.dataLoadedPromise) {
|
||||
return this.dataLoadedPromise;
|
||||
}
|
||||
var promise = new PDFJS.LegacyPromise();
|
||||
this.messageHandler.send('DataLoaded', null, function(args) {
|
||||
promise.resolve(args);
|
||||
});
|
||||
this.dataLoadedPromise = promise;
|
||||
return promise;
|
||||
},
|
||||
|
||||
getPage: function WorkerTransport_getPage(pageNumber, promise) {
|
||||
var pageIndex = pageNumber - 1;
|
||||
if (pageIndex in this.pagePromises)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue