06-26-2013 09:53 AM
I am printing on a Zebra ZM400 using ZPL code. I can download images to the printer using Zebra's utilities, and I can recall those images to print on a label, but I need to be able to download images using ZPL code (using the ~DG command). The ~DG command needs the JPG image to be in ASCII format. I have other images that were already converted to ASCII (by someone else) that I am able to print, so I know everything I am doing works as expected, however my problem is I have new images that need to be converted to the ASCII format required and I am not sure how to do this.
So my purpose is to print an image on a Zebra printer, but my real question is how to convert a JPG image to ASCII format (for the Zebra printer).
Let me know if more information is needed.
Thank you
Solved! Go to Solution.
06-27-2013 10:46 AM
Hi Raydur,
Are you currently connecting with your Zebra ZM400 through LabVIEW? Are you trying to convert the JPG files to ASCII in LabVIEW, or do you want to convert the files before running your program? If you're only doing this for a few images, I think the easiest way to accomplish this would be with an online JPG to ASCII converter. There is no built-in LabVIEW function for converting from JPG to ASCII. If you wish to do this with LabVIEW, you would need to implement an application that can do this conversion.
Please let me know if you have any further information on your application and how you're trying to accomplish this conversion. Thanks!
06-27-2013 11:14 AM
Hi Emily, thanks for the reply.
I am controlling/printing to the ZM400 directly through LabVIEW. If there was a tool already available to do this, I think it would serve my needs. I did try to find a (free) conversion tool, but after extensive searching I came up empty (unfortunately, most results relate to converting a JPG to ASCII art, which is not what I need to do). Maybe I'm searching the wrong thing, or looking for too specific of a tool?
My internal desire to know how things work makes me want to create an application to convert the files from JPG to ASCII within LabVIEW, but I'm not familiar with the steps to do this so I'm not really sure where to start. Most information I could find was for programming languages that I am not familiar with and little plain english detail on the intracacies of the conversion.
I'd be happy to know how to do this manually (within LabVIEW, if relatively simple), or of any suggestions of a free tool available.
Thanks!
06-28-2013 01:31 PM
Hi Raydur,
I've been trying to do further research into printing JPG files on Zebra printers, but I'm still not entirely sure how you want this file to be formatted. Could you offer some further explanation as to how this was done before?
When you say that they can print JPG files if they're converted to ASCII format, do you mean just changing the format of the file to ASCII? In LabVIEW you could import a JPG file, read it as a binary file, then save it as a text file. This would take the binary of the JPG file and convert it to an ASCII file. Is this the format that your printer wants for printing images?
Thanks!
06-29-2013 09:53 PM
Hi Emily,
Unfortunately, I don't have much insight into how this was done before as the person who had previously completed a conversion no longer works for our company.
The ZM400 printer uses Zebra's ZPL II language to create/format labels and for printer setup/control. Instead of Download Graphic (~DG), I am now using the command Download Object (~DY), which can be found in the ZPL II programming guide (p 182). This allowed me to use a .PNG file instead of a JPG, which was easier to work with.
I was able to use a modified version of your suggested method to get this to work. The ~DY command takes a parameter (data) that is an "ASCII hexidecimal string defining the image", which is further defined as: "The data string defines the image and is an ASCII hexidecimal representation of the image. Each character represents a horizonal nibble of 4 dots." So the method you suggested is exactly what I needed to do, however I hadn't stated that it needs to be represented in hex ASCII .
I converted the binary read data (of the PNG) to a byte array, then did a (hex padded to two digits) Number to String conversion within a For loop to give the ASCII representation of the binary data. This gives a hexidecimal ASCII representation of the binary data. VI is attached.
Thanks for your help!
I did encounter another issue: PNG files took forever for the printer to load into memory when printing (compared to the same image in Zebra's .GRF format). I solved this by reading back the file saved on the printer as it's native .GRF format (using the ^HG command), and then re-saving that output (now in ZPL formatted code) back to the printer. I'm guessing there's a way to convert directly to the .GRF format, but for now this is working for my purposes.
Thanks again!
08-19-2013 04:15 AM
ZPL code and save it as an image file to know how to do?
^XA
^LH000,000^BY2,6,60^FS
^FO020,020^GB1170,570,2^FS
^FO775,080^A0,20,20^FDINV R1/MAT-21-1007^FS
^FO040,300^A0,30,30^FD(1K) 71896^FS
^FO040,330^B3N,N,50,N,N^FD1K718496^FS
^FO040,030^A0,30,30^FD(1P) R659TR7SAM ^FS
^FO040,120^A0,30,30^FD(1T) K8-31425^FS
^FO040,060^B3N,N,50,N,N^FD1PRF690TRSM^FS
^FO040,150^B3N,N,50,N,N^FD1TK0-3475^FS
^FO775,210^A0,30,30^FD(4L) KR^FS
^FO775,240^B3N,N,50,N,N^FD4LKR^FS
^FO775,120^A0,30,30^FD(D) 1330^FS
^FO775,150^B3N,N,50,N,N^FDD1330^FS
^FO040,210^A0,30,30^FD(Q) 2500^FS
^FO040,240^B3N,N,50,N,N^FDQ2500 ^FS
^FO770,540^A0,30,30^FDS/M:^FS
^FO850,540^A0,30,30^FDLCZ^FS
^FO440,480^A0,30,30^FDBox#: 1/ 1^FS
^FO670,480^A0,30,30^FDTYPE: DS-K9-23^FS
^FO440,510^A0,30,30^FDLOT#: LLZ ^FS
^FO440,540^A0,30,30^FDSHIP:^FS
^FO540,540^A0,40,40^FD 575-01-0^FS
^XZ
08-19-2013 05:09 PM
Hi gaon,
Could you please give a more detailed explanation of what you're trying to do? Are you trying to communicate with a Zebra printer from LabVIEW? What are you trying to save to file? If I have a clearer idea of what you're trying to accomplish hopefully we can get you pointed in the right direction.
Thanks!
08-19-2013 05:59 PM
@Raydur wrote:
Hi Emily,
Unfortunately, I don't have much insight into how this was done before as the person who had previously completed a conversion no longer works for our company.
The ZM400 printer uses Zebra's ZPL II language to create/format labels and for printer setup/control. Instead of Download Graphic (~DG), I am now using the command Download Object (~DY), which can be found in the ZPL II programming guide (p 182). This allowed me to use a .PNG file instead of a JPG, which was easier to work with.
I was able to use a modified version of your suggested method to get this to work. The ~DY command takes a parameter (data) that is an "ASCII hexidecimal string defining the image", which is further defined as: "The data string defines the image and is an ASCII hexidecimal representation of the image. Each character represents a horizonal nibble of 4 dots." So the method you suggested is exactly what I needed to do, however I hadn't stated that it needs to be represented in hex ASCII .
I converted the binary read data (of the PNG) to a byte array, then did a (hex padded to two digits) Number to String conversion within a For loop to give the ASCII representation of the binary data. This gives a hexidecimal ASCII representation of the binary data. VI is attached.
Thanks for your help!
I did encounter another issue: PNG files took forever for the printer to load into memory when printing (compared to the same image in Zebra's .GRF format). I solved this by reading back the file saved on the printer as it's native .GRF format (using the ^HG command), and then re-saving that output (now in ZPL formatted code) back to the printer. I'm guessing there's a way to convert directly to the .GRF format, but for now this is working for my purposes.
Thanks again!
The ~DY command is a simple ASCII hex string of the raw data. In addition, the native format for images on the printer are bitmap. though, it is not the same as a bmp file since the data does not contain the bmp header information. It is simply the raw bitmap of the image. Basically it is a simple binary representaion with each bit indicating if the pixel (dot) will be on or off. The printer uses the GRF extension for the raw bitmap data.
08-19-2013 06:04 PM
Gaon,
What specifically do you want to do? If you have the ZPL to print the label why do you want to get the image? Printing labels using ZPL is faster than using graphics. If you want to include a graphic in the label the image can be downloaded to the printer and then recalled for and used with a specific label. You need to provide more details in what specifically you want to do.
If you are asking how to communicate with the printer using LabVIEW it is fairly easy. Serial, parallel port and network (TCP) communications are very easy and can be done using VISA. USB communications can be accomplished using VISA but are a bit more challenging.
Mark
08-20-2013 12:50 AM
The following command would like to preview before printing.
Please note sequence.
1. pass commands to the print device
2. Print start
3. print complete
I'd like to change.
1. pass commands to the print device
2.Shows the contents to be printed.
3.Check the contents to be printed
4.Print start
5.print complete