Detect print PopUp opening or a Dowload

0

I was wondering if anyone knows some way to detect the opening of that default print popup for running a javascript.

My problem: I needed to run a script when the user downloaded or printed a PDF that is being displayed to him as follows inside my page:

It would have to use these two standard options of the embedded viewer. Does anyone know how I would capture these events with javascript? (Remembering that the viewer code is external, I could not capture the button ids.)

    
asked by anonymous 30.10.2018 / 20:56

1 answer

0

Christian I confess that I did not quite understand what you want to do, but I left an example for you to see how you can perform an action before printing using the onbeforeprint javascript native method:

function Antes() {
  window.onbeforeprint = function() {
     alert('Antes de imprimir!')
  }
}

function Imprimir() { 
  window.print()
}
<button onclick="Antes();Imprimir()">Imprimir</button>
    
30.10.2018 / 22:17