Page Printing

Asked

Viewed 312 times

6

Good morning, I wonder if there is any way to count how many times a given page (html) has been printed. I know we can count the times a modal was opened with the click of the button, in this same modal I have a button to print (the content of it), but I need to count how many times that content was actually printed. That’s possible?

1 answer

3

Not.

You can only count how many times the user has clicked on your print button. If that’s enough: just as you increment the modal window counter, you can increment the print button click counter. You can do something like this:

HTML:

<button id="botaoPraImprimir" type="button">Imprimir</button>
<input type="hidden" id="contadorDeImpressoes" value="0"> 

Javascript, com jQuery:

var $contadorImpressoes = $("#contadorImpressoes");
$("#botaoPraImprimir").on("click", function () {
    let valorAtual = parseInt($contadorImpressoes).val();
    $contadorImpressoes.val(valorAtual + 1);
});

Note that this will count how many times the print button of your modal was printed. So you know how many times the user had the intent to print.

The print button of the browser’s print dialog is not accessible via code - and there is no browser print event that you can capture or intercept. You can’t count how many times a document has been fact-printed, nor how many copies were made.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.