mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 17:55:37 +02:00
Move the initialization of "metadata" out of PDFViewerApplication.load
Over time, with more and more API-functionality added, the `PDFViewerApplication.load` method has become quite large and complex. In an attempt to improve the current situation somewhat, this patch moves the fetching and initialization of "metadata" out into its own (private) helper method instead.
This commit is contained in:
parent
32f1d0de76
commit
d07be1a89b
1 changed files with 142 additions and 131 deletions
19
web/app.js
19
web/app.js
|
@ -1237,10 +1237,22 @@ const PDFViewerApplication = {
|
||||||
});
|
});
|
||||||
|
|
||||||
this._initializePageLabels(pdfDocument);
|
this._initializePageLabels(pdfDocument);
|
||||||
|
this._initializeMetadata(pdfDocument);
|
||||||
|
},
|
||||||
|
|
||||||
pdfDocument
|
/**
|
||||||
.getMetadata()
|
* @private
|
||||||
.then(({ info, metadata, contentDispositionFilename }) => {
|
*/
|
||||||
|
async _initializeMetadata(pdfDocument) {
|
||||||
|
const {
|
||||||
|
info,
|
||||||
|
metadata,
|
||||||
|
contentDispositionFilename,
|
||||||
|
} = await pdfDocument.getMetadata();
|
||||||
|
|
||||||
|
if (pdfDocument !== this.pdfDocument) {
|
||||||
|
return; // The document was closed while the metadata resolved.
|
||||||
|
}
|
||||||
this.documentInfo = info;
|
this.documentInfo = info;
|
||||||
this.metadata = metadata;
|
this.metadata = metadata;
|
||||||
this.contentDispositionFilename = contentDispositionFilename;
|
this.contentDispositionFilename = contentDispositionFilename;
|
||||||
|
@ -1374,7 +1386,6 @@ const PDFViewerApplication = {
|
||||||
formType,
|
formType,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue