I generate an invoice bill and print it after placing an order. It is printing on desktop perfectly, but on mobile devices or tablet devices it prints the whole page.
How can I solve this issue?
This is the printing button:
<input type="button"
class="btn btn-primary non-printable"
onclick="printDiv('printableInvoice')"
value="Proceed, If thermal printer is ready."/>
This is the JavaScript function:
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
location.reload();
}