Line feed problems with ZPL QR Code on Zebra Printer - zebra-printers

I'm having some issues with the using line feeds / carriage returns in ZPL with my Zebra LP2844z in CUPS (Raspberry pi).
According to Zebra's documentation and example, I just need to enable hex command using the FH switch, and use the hex encoded "_OD_0A" for a carriage return.
https://www.zebra.com/us/en/support-downloads/knowledge-articles/including-carraige-return-line-feed-in-qr-barcode-using-zpl.html
This example works fine until I try and add more lines:
^XA
^FO100,100
^BQN,2,10
^FH
^FDMM,B0024First Line _0D_0A Second Line _0D_0A Third Line _0D_0A Fourth Line _0D_0A ^FS
^XZ
This results in the following generated QR code:
And contains the following text:
First Line
Second LinTHIRD LINE UFOURTH LINE U
Something was going wrong at what appeared to be around the 24th byte which I realised coincides with the bytes "represented" (as mentioned in the documentation).
I then increased this further and found that I need to change the bytes representation in the "FDMM,B0nnn" switch for every byte in the string. If I increase it over what appears to be an arbitrary number (let's say 100 bytes) it messes up the QR code text again.
That might work for static text where I know the length of the string in bytes. However, I want to create these barcodes dynamically and each string will have a different byte length.
How can I handle it?

I was having the same problem. This is what I have done:
^XA^MUM
^FT50,50^BQN,2,1^FH_^FDMM,AFirst Line,B0002_0d_0a,ASecond Line,B0002_0d_0a,AThird Line,B0002_0d_0a,AAll the lines that you need^FS
^MUM^XZ
This is the document that I have used to know what I need to do:
https://support.zebra.com/cpws/docs/general/B_Switch_to_Add_Special_Characters_QR_BarCode.pdf
I hope it will be helpful for you also.

Related

Is there a 'reserved field identifier' or similar, in ZPL?

I've been doing some work with ZPL recently for printing manufacturing barcode labels etc.
We have several fields on a custom label format that get replaced with real world data, by searching for a specific string of text in the raw ZPL, and then replacing it with the correct application data. E.g. field1 just gets replaced by whatever we actually need to print there, before the TCP packet is constructed and put onto the network to perform the actual print.
This works just fine (so far), but I'm concerned what if some of our field data ever matches the format of a ZPL command for example, what happens.
Page 48 of the huge ZPL specification document shows what we are doing too, where xxxxxxxxxxx is the data to be replaced.
^XA
^FO50,50^ADN,36,20^FDxxxxxxxxxxx
^FS
^XZ
Is there no formal 'reserved field' format/identifier of sorts, or doing what we're doing the only option?
E.g. search and replace field1 in the ZPL below.
^XA
^FO50,50^ADN,36,20^FDfield1
^FS
^XZ
If what you have to replace in the ZPL code is the content of a field (text or barcode), you can try a different approach and use the ^FN command which is used as a placeholder for variable fields and it is usually used to store and recall templates from the printer memory.

How to append Serialized Numbers in ZPL II for a barcode?

I'm trying to create a series of labels with a 128 Barcode that has as its information two serialized numbers that increment with every label printed. I can create the counters no problem but I can't append the information so it prints as the Barcode.
^FX Third section with bar code.
^BY10,2
^FO70,740^BC N,130,Y,N,N,A^FDto sort^FS
^FX Serial Numbers
^CF0,90
^FO70,940^FDSeals:^FS
^CFB,70
^FO300,940^SN2647001,100,^FS
^CF0,90
^FO780,940^FDTo:^FS
^CFB,70
^FO920,940^SN2647100,100^FS
^FX Labels
^PQ5
Take a look at the ^SF command. It uses ^FD to seed the serialization, and a mask for formatting. For your example usage:
^FD2647001-2647000^SFddddddd%ddddddd,100%0000100^FS

How to create a new line in combination with ^FH?

I've been trying to get ZPL working with a combination of ^FH and new lines. For some reason when I use the following code
^FH\^FD<RECEIVERNAME>\&<RECEIVERSTREET>\&<RECEIVERHOUSENUMBER>^FS
It ends up as
<RECEIVERNAME>&<RECEIVERSTREET>&<RECEIVERHOUSENUMBER>
I cannot seem to figure out how to stop ^FH from converting the new line to a symbol.
Hex for a new line is 0a, and hex for carriage return is 0d.
Neither of them work with http://labelary.com/ so I'm guessing that they are not supported for what you are using them for.
Line break characters (0x0d and/or 0x0a) like any other nonprintable characters are not supported in the commands ^FD, ^FV and ^SN, as stated in the ZPL Programming Guide. See the description of the ^FD command for reference.

GS1-128 barcode with ZPL does not put the AI in ()

i was expecting this command
^FO15,240^BY3,2:1^BCN,100,Y,N,Y,^FD>:>842011118888^FS
to generate a
(420) 11118888
interpretation line, instead it generates
~n42011118888
anyone have idea how to generate the expected output?
TIA!
Joey
If the firmware is up to date, D mode can be used.
^BCo,h,f,g,e,m
^XA
^FO15,240
^BY3,2:1
^BCN,100,Y,N,Y,D
^FD(420)11118888^FS
^XZ
D = UCC/EAN Mode (x.11.x and newer firmware)
This allows dealing with UCC/EAN with and without chained
application identifiers. The code starts in the appropriate subset
followed by FNC1 to indicate a UCC/EAN 128 bar code. The printer
automatically strips out parentheses and spaces for encoding, but
prints them in the human-readable section. The printer automatically
determines if a check digit is required, calculate it, and print it.
Automatically sizes the human readable.
The ^BC command's "interpretation line" feature does not support auto-insertion of the parentheses. (I think it's safe to assume this is partly because it has no way of determining what your data identifier is by just looking at the data provided - it could be 420, could be 4, could be any other portion of the data starting from the first character.)
My recommendation is that you create a separate text field which handles the logic for the parentheses, and place it just above or below the barcode itself. This is the way I've always approached these in the past - I prefer this method because I have direct control over the font, font size, and formatting of the interpretation line.

ZPL - Barcode Missing a digit when printed

I am trying to print a Code 128 barcode on a label using the following the piece of ZPL with a Zebra ZP 450 printer:
^BY3^BCN,112,N^FO090,660^FD>;>89102100^FS
I'm expecting the barcode to scan as "9102100". However, when I scan the printed barcode, it reads as "910210" -- cutting off the final digit.
If I change the last digit, it is still cut off. But if I add more digits onto the end, e.g. "9102100357", the barcode correctly reads as "9102100357".
Why am I "losing" a digit in this particular case?
The >; inside of your ^FD block is telling the code 128 barcode to go into a subset (subset C in this case) which forces the data in the barcode to be numeric pairs (00 - 99). Any data that is not supplied in numeric pairs is ignored. If you put a letter in there, it will ignore that pair. In your case 9102100 has an odd number of numbers, so it ignores the last one. If for example, you add another 0, it will put all the letters in the barcode.
The ;> which puts the barcode in Subset C is not the default. Subset B or :> is the default which will allow any character to be encoded in the barcode. So you can replace the ;> with :>, or just remove the ;> entirely, and it will print out properly.
Check out the ^BC documentation in the ZPL programming manual for more information about Code 128 subsets and data validation
See pg 92 of the ZPL Programming Guide.
This issue may have been fixed in the firmware update, see below:
Example: This is an example with the mode parameter set to D*:
^XA
^PON
^LH0,0
^BY2,2.5,145
^FO218,343
^BCB,,Y,N,N,D
^FD(91)0005886>8(10)0000410549>8(99)05^FS
^XZ
D* — When trying to print the last Application Identifier with an odd number of characters, a problem
existed when printing EAN128 bar codes using Mode D. The problem was fixed in firmware version
V60.13.0.6."

Resources