Search code examples
zebra-printers

Zebra Stored Format - QR with [TAB] character from XML


We are in the midst of an Oracle ERP implementation and I have been tasked with redesigning our labels to work with the new system. Our product labeling needs to contain a QR code encoded with the Item and Lot number separated by a [TAB] character. Oracle will be sending XML files containing variable data to the printers for use with formats stored on the printers.

Hard coding works fine, I get a QR coded with 'FOO[TAB]BAR':

^XA
^FO50,50
^BQN,2,10^FH^FDQA,FOO_09BAR^FS
^PQ1,0,1,Y
^XZ

Strange things happen when I create a stored format on the printer:

^XA
^DFE:QR_TEST.ZPL
^MCY
^FO50,50
^BQN,2,10^FN1^FH^FDQA,$$QR_CODE$$^FS
^FO50,350
^AON,30,30^FN1^FD$$QR_CODE$$^FS
^XZ

And send the following XML file:

<?xml version="1.0" standalone="no" ?>
<!DOCTYPE labels SYSTEM "label.dtd">
<labels _FORMAT="QR_TEST.ZPL" _QUANTITY="1" _PRINTERNAME="" _JOBNAME="TEST">
<label>
<variable name="$$QR_CODE$$">FOO_09BAR</variable>
</label>
</labels>

Interestingly without the text field definition the label does not print. After adding the text field the label prints but the QR code produced drops 'FOO' and scans as only '_09BAR' while the text field prints 'FOO_09BAR'.

Confusing matters further, if I drop the '_09' out of the $$QR_CODE$$ variable definition, the text field prints 'FOOBAR' as expected but the QR code scans as 'BAR', so for whatever reason the QR is dropping the first three characters of data.

I've been chasing my tail for a day on this with no progress so am wondering if anybody here with more experience than I can shed some light on the problem.

My two questions are:

  1. Why is the QR code dropping the first three characters?
  2. How do I embed the [TAB] character in the QR code using variable data from XML?

Solution

  • For the benefit of anyone else trying to solve the same problem here's the solution that I arrived at. Unfortunately Zebra support was of no help as all they could do was to keep sending me pages from the manual I already had. They were unable to send me a working example.

    The solution involved two things:

    1. Select what Zebra calls "8-bit byte mode". The mode is set and a parameter indicating the number of characters to be printed is set within the data field. The manual states that it is set as Bxxxx where "xxxx = number of data characters is represented by two bytes of BCD code". In practice what works is an integer formatted to 4 digits, i.e. for 26 characters use B0026.
    2. The second thing to know is that the variable passed must encompass all data that falls between "^FD" and "^FS" including parameters.

    The format stored on the printer looks like this:

    ^XA
    ^DFE:QR_TEST.ZPL
    ^MCY
    ^FO50,50
    ^BQN,2,10^FN1^FH^FD$$QR_CODE$$^FS
    ^XZ
    

    Send the following XML file to the printer:

    <?xml version="1.0" standalone="no" ?>
    <!DOCTYPE labels SYSTEM "label.dtd">
    <labels _FORMAT="QR_TEST.ZPL" _QUANTITY="1" _PRINTERNAME="" _JOBNAME="TEST">
    <label>
    <variable name="$$QR_CODE$$">QM,B0007FOO[TAB]BAR</variable>
    </label>
    </labels>
    

    The variable $$QR_CODE$$ breaks down as:

    • Q = Error correction level High
    • M = Manual character mode
    • B = 8-bit byte mode
    • 0007 = Seven data characters to follow
    • FOO[TAB]BAR = Characters to encode in QR code. Note that [TAB] is a literal tab character, ASCII char 09

    The SQL that provides the variable value has to provide all of the above, but that is pretty straightforward. So far this has worked flawlessly with the combinations of item and lot numbers that I've tested so far ranging in length from 10 to 25 characters in length. I'll update this post if I run into any difficulty or learn anything new.