Merge pull request #12426 from Snuffleupagus/app-triggerPrinting

Re-factor how printing is triggered in the default viewer
This commit is contained in:
Tim van der Meij 2020-09-30 22:12:42 +02:00 committed by GitHub
commit 88f72d6b1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -593,10 +593,6 @@ const PDFViewerApplication = {
this.pdfViewer.currentPageNumber = val;
},
get printing() {
return !!this.printService;
},
get supportsPrinting() {
return PDFPrintServiceFactory.instance.supportsPrinting;
},
@ -1378,12 +1374,9 @@ const PDFViewerApplication = {
}
}
if (!this.supportsPrinting) {
return;
}
if (triggerAutoPrint) {
setTimeout(function () {
window.print();
setTimeout(() => {
this.triggerPrinting();
});
}
},
@ -1638,7 +1631,7 @@ const PDFViewerApplication = {
},
forceRendering() {
this.pdfRenderingQueue.printing = this.printing;
this.pdfRenderingQueue.printing = !!this.printService;
this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
this.pdfRenderingQueue.renderHighestPriority();
},
@ -1732,6 +1725,13 @@ const PDFViewerApplication = {
this.pdfPresentationMode.request();
},
triggerPrinting() {
if (!this.supportsPrinting) {
return;
}
window.print();
},
bindEvents() {
const { eventBus, _boundEvents } = this;
@ -2242,9 +2242,7 @@ function webViewerNamedAction(evt) {
break;
case "Print":
if (PDFViewerApplication.supportsPrinting) {
webViewerPrint();
}
PDFViewerApplication.triggerPrinting();
break;
case "SaveAs":
@ -2400,7 +2398,7 @@ function webViewerPresentationMode() {
PDFViewerApplication.requestPresentationMode();
}
function webViewerPrint() {
window.print();
PDFViewerApplication.triggerPrinting();
}
function webViewerDownloadOrSave(sourceEventType) {
if (