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.
Related
In our space we use an ACUCOBOL-GT written program which pushes variables such as PHY NAME to a written format. The program then replaces said PHY NAME with the actual name of the pharmacy and then cups pushes the data onto the label, producing an readable output. We use zebra printers with EPL written label formats to print out these pharmacy medication labels.
Recently I wrote a format using ZPL to produce the same label as Im able to customize the data better than with the old EPL.
The only issue Im running into is that now with the ZPL the data prints onto the label between quotation marks.
So instead of it being eg Montagu Pharmacy it prints out as "Montagu Pharmacy ".
an example of the old EPL code is as follow : PHY NAME A010,025,0,4,1,1,N,
and the output of said code is as follow : A010,025,0,4,1,1,N,"MONTAGU PHARMACY "
on the output before printing it shows the quotes as well but as soon as you send it to the printer it removes the quotes and prints without them.
Here is an example of the ZPL code : PHY NAME ^FO100,025,0^A0N,18,30^FD
and here is the output of said code : PHY NAME ^FO100,025,0^A0N,18,30^FD"Montagu Pharmacy "
on the output before printing it shows the quotes and when it prints out onto the label it prints the text along with the quotes.
I understand that the ACUCOBOL-GT program creates the data with the quotations but the EPL never printed them out but the ZPL does.
Is there anything Im doing wrong or that I can do to remove the quotes so that it can print out normally as before.
I would really appreciate any assistance.
Kind regards
Hans Steyn
This is because in EPL the "DATA" to be printed is surrounded by quotes("), while in ZPL it is not, so quotes are printed. You need to remove the quotes as follows:
PHY NAME ^FO100,025,0^A0N,18,30^FDMontagu Pharmacy
References:
EPL (A command)
https://www.servopack.de/support/zebra/EPL2_Manual.pdf
page 41
ZPL (^FD command)
https://www.zebra.com/content/dam/zebra/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf
page 172
EDIT 1
As per your comment, AFAIK there is no way to remove the quotes after the command reaches the printer. So the only way is to have your supplier's software send the command to some custom tool/software you have that will strip the quotes then relay the message to the printer.
[supplier software] -> [custom software] -> [Printer]
I don't know their software, but they could generate a text file that your custom tool would load and remove the quotes for example with a regex like this, that even allows for escaped quotes in the middle of the name if there are any (arrows):
This being said, it is quite surprising that removing quotes requires massive development, especially because they already seem able to generate both EPL and ZPL.
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.
Can't print the label correctly. There is some extra spaces in the ZPL text field.
There are some spaces between the text fields in line 2 and line 4.
Please kindly help.
^XA^LL496
^PW711
^FT16,50^A0N,20,19^FDL-01,02,03^FS
^FT16,100^A0N,20,19^FDU-01,02,03^FS
^FT16,150^A0N,23,24^FDUSER ID:admin^FS
^FT16,200^A0N,23,24^FDPromise Date:02/15/16^FS
^FT16,250^A0N,23,24^FDDate of Request: 11/14/19 01:48PM^FS
^PQ1,0,1,Y^XZ
Result:
L-01,02,03
U- 01,02,03 <-- Extra space
USER ID:admin
Promise Date:02/15/16 <- Extra space here
Date of Request: 11/14/19 01:48PM
My Zebra printer : Zebra Z4Mplus 203DPI
I have found this message from internet :
http://support.efficientbi.com/knowledge-base/extra-spaces-in-label-text-appear-when-sending-zpl-commands-direct-to-windows-generic-printer-driver-zebra-problem/
"When testing sending ZPL print commands direct to a Zebra printer using Generic Windows print driver, it we noticed that sometimes extra spaces would appear in the sample label. After some research, it was determined that it appears the Generic Windows print driver will cause these extra spaces to be inserted when the ZPL code is sent WITHOUT CRLF breaks."
I am using the "Generic Windows print driver" for my Zebra printing.
Here is the link that I used :
JavaScript: Send raw text to printer - no server requests/method calls, able to work offline, purely clientside
The output format totally mess up in the Zebra printing. On the other hand, the Labelary looks good to me though.
I am using the Java Vaadin framework and call the javaScript to print the ZPL command to use the "Generic Windows print driver". It worked but the format did not look to me. Extra spaces everywhere and some text did not show up at all but it looks OK in Labelary though.
I tried to print the label in client machines with Zebra printer for my Java Vaadin server side application and I finally able to make it printing but don't know why the format looks totally unpredictable.
My label size is : 3.5 inches X 2 inches label.
I can print the whole field now but still got extra space on the output.
^XA^LL496
^PW711
^FT16,209^A0N,20,19^FH^FDL-01,02,03^FS
^FT16,169^A0N,20,19^FH^FDU-01,02,03^FS
^FT16,249^A0N,23,24^FH^FDUSER ID:admin^FS
^FT16,289^A0N,23,24^FH^FDPromise Date: 02/15/16^FS
^FT16,329^A0N,23,24^FH^FDRequest: 11/14/19 01:48 PM^FS
^FT16,369^A0N,23,24^FH^FDMatl: ST30^FS
^FT7,101^A0N,113,112^FH^FDX^FS
^BY4,2.5,59^FT131,87^B3N,N,,Y,N
^FD2246284^FS
^PQ1,0,1,Y^XZ
Here is the image: There are some extra spaces in the print label from Zebra printer.
enter image description here
I know it's an old question.
I had similair problem printing through cups, turned out the default options had margins set in them. Setting them to zero and Long Line Handling to 'Wrap at Right Edge' fixed my problem:
Finally I am able to get rid of this extra spaces by adding \ +\n string at he end of each java script statement.
We need two \\ characters, the first \ character as the escape character to make it working.
Finally I am able to get rid of this extra spaces by adding \ +\n string at he end of each java script statement. We need two \ characters, the first \ character as the escape character to make it working.
I have a system currently set up that creates a barcode for a UPC on a label. This works for single items, but sometimes I have more than one item that tries to feed into that barcode, and when that happens it is set to have no value.
However, instead of there being no barcode, there is actually a small barcode that scans in as 0. How do I ensure that no barcode appears?
^FT350,698^BY2,,75
^BCN,75,N,N,N^FD$ItemBarCode$^FS
"$ItemBarCode$" is an item from a populated table that I do not control, and there can be as many items as needed. The customer requires no barcode when there are multiple items and requires a barcode when there is one. Their sample does not use a typical UPC style barcode.
You say you don't have control over the data in the table, but do you have control over the content/format of $ItemBarCode$?
Have the variable contain the ^FD prefix and ^FS suffix (and remove from the ZPL code). When the variable is blank/empty, nothing will print.
According to the software developer consultant, the solution is to create a customization in the system's code that allows for a logic line to fix this error. This is not something that can be fixed within ZPL itself, rather, there will be two separate labels. For instance,
if single item then print X
if multiple items then print Y
I have same situation. My solution is input barcode command in single line with its data and terminator ^FD and ^FS. So during parsing label file line by line, if data is zero or error than remove entire line. And its work for me
i have string like this
31/12/2002
HINDUSTHAN MOTORS LIMITED
THREE LACS SEVENTY SEVEN THOUSAND THREE HUNDRED
EIGHTY SEVEN ONLY
**377387.00
I want to print it in pre-printed cheque.
how to print this pre-formatted text in java.
I have text file which contains the above pre formatted text
my problem is the extension of the file is different (.kris format)
when I open the file in text doc the formatted text becomes one single line.
So, one single line printing in the printer is not acceptable.
I want to send above text to the printer by using the above fixed format.
1.Download blank cheque template in word format (This is the toughest task I would say if you are searching for free template).
2.Replace labels in it by blank spaces(Make sure that blank spaces occupy same number of spaces as labels).
3.In place of values put some identifiers.for ex: in your case,in place of **377387.00 put **$amount,$date in place of date.
4.Save word as pdf.
5.Now with itext in java replace $ values by your actual values.(itext library in java is used to handle pdfs).
Take print and check if it comes properly on blank cheque else do some minor changes to re-align them.