I am attempting to print payment receipt using thermal POS printer using Print.js library. I can successfully print the page using the printjs. But the print comes with extra margins as per A4 page.
Is there any way to print it to fit to 58mm with to page margins?
Also it would be very helpful if any alternatives to print using JavaScript are given. Following is my work.
HTML & JS
<button id="print-receipt">print to pos</button>
<div id="invoice-print-div" class="hidden">
<div class="text-center" style="width:58mm;background-color:red;">
<h4>alpha</h4>
<table border="0">
<tr>
<th>Item</th>
<th>Qty</th>
<th>Price</th>
</tr>
<tr>
<td>abc</td>
<td>1</td>
<td>120</td>
</tr>
<tr>
<td>pqr</td>
<td>2</td>
<td>240</td>
</tr>
<tr>
<td>xyz</td>
<td>4</td>
<td>360</td>
</tr>
</table>
</div>
</div>
<script>
$("#print-receipt").on("click", function() {
printJS("invoice-print-div", "html");
});
</script>