I know this question has an Already been asked but I am using Different and Short Approach.
I have print button for printing Invoice in my web page
<button class="print" onclick="window.print()">Print</button>
The Problem is it prints the whole document including print button
is their any way to exclude print button from printing in document
Checkout this Link : https://www.thoughtco.com/how-to-add-a-print-button-4072006