0

I'm sending address data to a zebra label printer from a webpage. Basically each address is in multiple html input fields. On clicking the print button the routine uses a for loop to pickup each input field's data by its ID and send it to the printer using zpl commands. If I send 24 labels it's fine, anything above that only prints out 24 labels. I'm wondering if there's a data or time limit?

Have added an alert instead of sending the data to the printer and get the correct amount of alerts popping up so I know there's nothing wrong with the code

$('#filterlabel').click(function() {
  var ttllabels = $('#ttllabels').html();
  if (confirm("Print " + ttllabels + " address labels?") == true) {
    var i;
    for (i = 0; i < ttllabels; i++) {
      var accdelno = $("#accdelno-" + i).val();
      var custname = $("#custname-" + i).val();
      var address1 = $("#address1-" + i).val();
      var postcode = $("#postcode-" + i).val();
      var y = 24;
      var qty = 1;
      var zpl = "^XA";
      /* if (contact.length > 0) {zpl = zpl + "^FS^FO20,"+y+"^A0N,36,36^FDATTN: " + contact;y = y + 40;} */
      if (custname.length > 0) {
        zpl = zpl + "^FS^FO20," + y + "^A0N,36,36^FD" + custname;
        y = y + 40;
      }
      if (address1.length > 0) {
        zpl = zpl + "^FS^FO20," + y + "^A0N,36,36^FD" + address1;
        y = y + 40;
      }
      if (postcode.length > 0) {
        zpl = zpl + "^FS^FO20," + y + "^A0N,36,36^FD" + postcode;
        y = y + 40;
      }
      zpl = zpl + "^PQ" + qty + "^XZ";
      var zebraPrinterUrl = "http://192.168.88.202/pstprnt";
      var request = new XMLHttpRequest();
      request.open("POST", zebraPrinterUrl, true);
      request.setRequestHeader("Content-Length", zpl.length);
      request.send(zpl);
    }
  } else {
    return false;
  }
});

Only produces 24 labels each time
If I send 10 , I get 10
If I send 36 , I get 24
If I send 25 , I get 24

CR15 BRN
  • 33
  • 1
  • 5
  • I've printed hundreds of individually unique labels with one transmission from Oracle EBS after generating ZPL using BI Publisher eText. I've never had a problem. – EdHayes3 Jul 31 '19 at 15:03

1 Answers1

0

Might have something to do with the way you are sending the ZPL.

Try using a different method. There's a few options I found. Take a look at these:

JavaScript: Send raw text to printer - no server requests/method calls, able to work offline, purely clientside

https://www.neodynamic.com/articles/How-to-print-raw-Zebra-ZPL-commands-from-Javascript/

EdHayes3
  • 1,777
  • 2
  • 16
  • 31