How to check if the print dialog is open (Mozilla and Chrome)
I have an angularjs app and try to print a PDF from a web service, the PDF has a javascript function embedded in it to display a print dialog. When the PDF is loaded into the iframe tag
<iframe ng-src="{{PDF}}" id="PDFtoPrint"></iframe>
, the print dialog is displayed and everything is fine. I am trying to figure out how to call a webservice after closing the print dialog. One idea is to check if the print dialog is open, set a timeout and check again if it closes, then call the web service.
source to share
I finally found a solution, first of all I want to say that I'm not sure how much better it is, but it seems to work. In my controller, I am using $ window for the focus function, which means the print dialog is closed (print or cancel unchanged).
$window.onfocus = function () {
console.log('This will be called after the user prints');
$timeout(Call other function, 1000);
}
}
source to share