0

Last few days, I am facing a problem with printing barcode labels by using a GPrinter GP-3120TUC model printer. Basically, I am generating the barcode during runtime by the JSBarcode javascript plugin.

enter image description here

And then, print that barcode by window.print() method. The issue is, I am unable to adjust the barcode paper size with the window paper. so, please have look and give me a better way to solve it.

enter image description here

The jsbarcode plugin cdn is:

<script src="https://cdn.jsdelivr.net/npm/jsbarcode@3.11.5/dist/JsBarcode.all.min.js"></script>

The script I used to generate barcode is:

<script>
    function GenerateBarCode(sku) {
            $('#barcode_modal').modal('show');
             $('#close').click(function() {
                $('#barcode_modal').modal('toggle');
             });

            JsBarcode("#barcode_id", sku, {
            format: "CODE128",
            width:0.97,
            height:73,
            fontSize:20,
            displayValue: true,
            lineColor: "#000000"
        });
    }
</script>

Then, the script I used to print that barcode is:

<script>
    function print_barcode(BarCodePrintDiv) {
    var body =document.body.innerHTML;
    var data =document.getElementById(BarCodePrintDiv).innerHTML;
    document.body.innerHTML = data;
    window.print();
    document.body.innerHTML = body;
  }
 </script>

0 Answers0