We have an AngularJS web app that loads PDF documents from the server and displays them within the page like this:
You said it is to detect from the browser. print()
is a window
level function.
I hope the first two answers from this link helps you with your printing listening. how to detect window.print() finish
Regarding you download complete listener, you need to implement logic
if your download progress bar is at 100% when downloaded part of the document is not increasing.
then it means printing is completed. And this perfectly works for you as you are downloading pdf documents, which don't get downloaded in multiple files.
So, you set up a progress bar. You use that progress bar until the downloaded file keep incrementing in each interval (you set timeout here). Even after waiting for timeout interval, you don't have your downloaded file incremented, you define that as an end for your progress bar.
elementType.onclick = function() {
// if progress bar completes when file download stops
// call downloadcompleted() function
}
For the link click listener: Adding an onclick function to go to url in JavaScript?