Code: Select all
// Function to handle actual printing (this will only be called if validation passes)
function printThermalBill() {
// Existing code to print the bill
const billContent = document.getElementById('billDisplay').innerHTML;
const printWindow = window.open('', '', 'width=600,height=600');
printWindow.document.write(`
Print Bill
${billContent}
`);
printWindow.print();
printWindow.document.close();
printWindow.close();
// Close the print window after printing
printWindow.onafterprint = function () {
printWindow.close();
};
document.getElementById("billForm").reset();
}
@media print {
@page {
size: 10.5cm 15.5cm;
margin: 0; /* Remove margins */
background: red;
}
body {
margin: 0;
padding: 0;
}
.bill-display {
width: 10.5cm;
height: 15.5cm;
overflow: hidden;
}
#title, h3{
padding-bottom:0px;
padding-bottom:0px;
margin-bottom:0px;
margin-bottom:0px;
font-size:30px;
text-align:center;
}
#address{
font-size:15px;
}
#hr{
padding-bottom:0px;
padding-bottom:0px;
margin-bottom:0px;
margin-bottom:0px;
font-size:30px;
text-align:center;
}
}