Printing multiple (different) labels in one ZPL commands

mbednarski picture mbednarski · Apr 1, 2014 · Viewed 9.4k times · Source

I have followig task:

I am generating sequence of consecutive barcodes eg: 117-1, 117-2, 117-3, 117-4...

I have to print labels with those barcodes: first label with first code, second label with second code and so on.

Currently I am printig labels one-by-one. Is it possible in ZPL to combine multiple labels to one command for printer? Something like:

^header
print first one
take next label
print second one
take next label
...
^footer

I am generating ZPL so there is no need to introduce variables in ZPL.

My current code for printing single label

    string zpl = string.Format(
    @"^XA
    ^LH5,5

    ^CF0,129
    ^FO20,10
    ^FB800,4,,C
    ^FD{0}
    ^FS

    ^FO160,150
    ^FB800,1,,C
    ^BY3
    ^BCN,150,N,N,N
    ^FD{0}
    ^FS
    ^XZ
    ", code.ToString());

Answer

Brimstedt picture Brimstedt · Jan 25, 2017

You can concatenate ZPL files to merge several labels into one.

Untested code would be something like this, if I understand your requirements:

String template = "^XA^LH5,5^CF0,129^FO20,10^FB800,4,,C^FD{0}^FS^FO160,150^FB800,1,,C^BY3^BCN,150,N,N,N^FD{0}^FS^XZ";

String zpl = String.format(template, code.toString());
      zpl += String.format(template, code2.toString());
      ...and so one, or use a loop