diff --git a/src/js/init.js b/src/js/init.js index 8d2515e..528e35a 100644 --- a/src/js/init.js +++ b/src/js/init.js @@ -30,6 +30,7 @@ export default { onLoadingEnd: null, onPrintDialogClose: () => {}, onIncompatibleBrowser: () => {}, + onAfterPrint: () => {}, modalMessage: 'Retrieving Document...', frameId: 'printJS', frameRemoveDelay: null, diff --git a/src/js/print.js b/src/js/print.js index 40f9629..f21e093 100644 --- a/src/js/print.js +++ b/src/js/print.js @@ -57,15 +57,24 @@ function performPrint (iframeElement, params) { // If Edge or IE, try catch with execCommand if (Browser.isEdge() || Browser.isIE()) { try { + iframeElement.contentWindow.onafterprint = function (event) { + params.onAfterPrint.call(this,event) + } iframeElement.contentWindow.document.execCommand('print', false, null) } catch (e) { setTimeout(function(){ + iframeElement.contentWindow.onafterprint = function (event) { + params.onAfterPrint.call(this,event) + } iframeElement.contentWindow.print() },1000) } } else { - // Other browsers + // Other browsers setTimeout(function(){ + iframeElement.contentWindow.onafterprint = function (event) { + params.onAfterPrint.call(this,event) + } iframeElement.contentWindow.print() },1000) }