Skip to content

Commit

Permalink
Merge pull request #12426 from Snuffleupagus/app-triggerPrinting
Browse files Browse the repository at this point in the history
Re-factor how printing is triggered in the default viewer
  • Loading branch information
timvandermeij authored Sep 30, 2020
2 parents 8e7a6e0 + 89ce326 commit 88f72d6
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,6 @@ const PDFViewerApplication = {
this.pdfViewer.currentPageNumber = val;
},

get printing() {
return !!this.printService;
},

get supportsPrinting() {
return PDFPrintServiceFactory.instance.supportsPrinting;
},
Expand Down Expand Up @@ -1378,12 +1374,9 @@ const PDFViewerApplication = {
}
}

if (!this.supportsPrinting) {
return;
}
if (triggerAutoPrint) {
setTimeout(function () {
window.print();
setTimeout(() => {
this.triggerPrinting();
});
}
},
Expand Down Expand Up @@ -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();
},
Expand Down Expand Up @@ -1732,6 +1725,13 @@ const PDFViewerApplication = {
this.pdfPresentationMode.request();
},

triggerPrinting() {
if (!this.supportsPrinting) {
return;
}
window.print();
},

bindEvents() {
const { eventBus, _boundEvents } = this;

Expand Down Expand Up @@ -2242,9 +2242,7 @@ function webViewerNamedAction(evt) {
break;

case "Print":
if (PDFViewerApplication.supportsPrinting) {
webViewerPrint();
}
PDFViewerApplication.triggerPrinting();
break;

case "SaveAs":
Expand Down Expand Up @@ -2400,7 +2398,7 @@ function webViewerPresentationMode() {
PDFViewerApplication.requestPresentationMode();
}
function webViewerPrint() {
window.print();
PDFViewerApplication.triggerPrinting();
}
function webViewerDownloadOrSave(sourceEventType) {
if (
Expand Down

0 comments on commit 88f72d6

Please sign in to comment.