Move the initialization of "auto print" 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 "auto print" out into its own (private) helper method instead.
This commit is contained in:
parent
d07be1a89b
commit
b9add65099
39
web/app.js
39
web/app.js
@ -1185,11 +1185,35 @@ const PDFViewerApplication = {
|
||||
});
|
||||
});
|
||||
|
||||
pagesPromise.then(async () => {
|
||||
pagesPromise.then(() => {
|
||||
this._initializeAutoPrint(pdfDocument, openActionPromise);
|
||||
});
|
||||
|
||||
onePageRendered.then(() => {
|
||||
pdfDocument.getOutline().then(outline => {
|
||||
this.pdfOutlineViewer.render({ outline });
|
||||
});
|
||||
pdfDocument.getAttachments().then(attachments => {
|
||||
this.pdfAttachmentViewer.render({ attachments });
|
||||
});
|
||||
});
|
||||
|
||||
this._initializePageLabels(pdfDocument);
|
||||
this._initializeMetadata(pdfDocument);
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
async _initializeAutoPrint(pdfDocument, openActionPromise) {
|
||||
const [openAction, javaScript] = await Promise.all([
|
||||
openActionPromise,
|
||||
pdfDocument.getJavaScript(),
|
||||
]);
|
||||
|
||||
if (pdfDocument !== this.pdfDocument) {
|
||||
return; // The document was closed while the auto print data resolved.
|
||||
}
|
||||
let triggerAutoPrint = false;
|
||||
|
||||
if (openAction && openAction.action === "Print") {
|
||||
@ -1225,19 +1249,6 @@ const PDFViewerApplication = {
|
||||
window.print();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onePageRendered.then(() => {
|
||||
pdfDocument.getOutline().then(outline => {
|
||||
this.pdfOutlineViewer.render({ outline });
|
||||
});
|
||||
pdfDocument.getAttachments().then(attachments => {
|
||||
this.pdfAttachmentViewer.render({ attachments });
|
||||
});
|
||||
});
|
||||
|
||||
this._initializePageLabels(pdfDocument);
|
||||
this._initializeMetadata(pdfDocument);
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user