Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include PNG in reciept on a LP2844Z (Zebra Printer) [duplicate]

I'm working on creating a HTML5 canvas based signature/drawing box. Currently we save the canvas on the server as a PNG, but can easily save the base64 string in the database. Now the question is how do we include the signature on the printed receipt.

Currently we use a ^GF field to handle printing images, but the question is what format the PNG file needs to be in for the printer. Can I simply include the Base64 encoded string? Or should I convert it to an ASCII Hex string? Or should I really be converting it into a bitmap first?

I'm not really finding any documentation on whether or not this specific printer handles PNG files, or even how to send them. The only information I've found says to send it as a B64 or Z64 bitmap, but I see references to sending a png everywhere.

like image 270
cDecker32 Avatar asked Mar 13 '12 21:03

cDecker32


People also ask

Can Zebra printers print PNG files?

Printing a graphic from a PNG file is best done using the Zebra Driver, Zebra Setup Utility. or ZebraNet Bridge. If you cannot use these methods we are providing an example of how this can be done using ZPL. Specifically the ~DY command.

How do you put a picture on a Zebra printer?

In the Picture window, click Choose Options under the Image section and select Upload to upload images from your computer.


1 Answers

The data that is you need to send isn't a PNG. You need to take the image and convert it to black and white and send the data to the printer. For example, if you have an image that is 40x50px you would take the image, and strip out the color information so you would have a total of 2000 bits of data. Then send your ZPL down like ^GFB,250,250,5,{2000 bits of data}.

I got 250 by taking 2000 bits / 8 (bits / byte) to get 250 bytes. I got 5 by dividing 40 by 8. The number of rows will be calculated automatically.

Something that I find useful when dealing with Zebra printers is to think in terms of bits. All graphics are done on a bit level.

Remember that the image you are going to send down will change size depending on the DPI of the printer. A 203 DPI printer will show my example at about .2in x .25in. On a 300 DPI printer it will show at about .13in by .16in. This is because the printer will just place raw data onto the format and the number of px is the number of dots the image will be.

Hope this help!

References: [1] ZPL Manuel on page 208(^GF page2).

like image 140
Ethan Avatar answered Sep 20 '22 15:09

Ethan