Detect if a user prints something via javascript

Viewed 6240

I've got a problem with detecting a print event in javascript. For example, a user wats to print document and presses print in a web-page, then another window appers, e.g. to print from Adobe Reader, then appears another window of Adobe Reader where you can set properties, choose pages to print and what not...and there is the print button in this window. Can I actually detect when the user presses this print button inside this Adobe Reader window in browser using javascript?

I've already tried using onafterprint but maybe I didn't do this correctly or I'dont know.

it was something like this inside my main js file.

window.onbeforeprint = function() {
    console.log('This will be called before the user prints.');
};
window.onafterprint = function() {
    console.log('This will be called after the user prints');   
};

I took that from here: https://www.tjvantoll.com/2012/06/15/detecting-print-requests-with-javascript/

2 Answers
Related