Can you detect when a PDF is printed or downloaded from the browser PDF viewer?

后端 未结 3 1480
我寻月下人不归
我寻月下人不归 2021-02-20 00:10

We have an AngularJS web app that loads PDF documents from the server and displays them within the page like this:

3条回答
  •  粉色の甜心
    2021-02-20 00:59

    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?

提交回复
热议问题