0
votes

I am trying to print a monochrome png file using "zpl" and "zebra" modules on Python. My labels have 4 inches in width and 1-inch in height. I tried to take a ZPL code from zpl libraries. It gives me the right zpl. I am entering that zpl to Labelary ZPL Viewer and it views the content of it but the printer isn't printing anything when I send that ZPL to the printer. Also, I am using zpl. output for sending it to the printer. The printer's LED flashes one time and then nothing happens. I've also tried to download Zebra Setup Utility and I sent this zpl to a printer from there and the result was the same. Here is the code that I am using to print. I need to handle that situation immediately so I'd be appreciated to any ideas.

from PIL import Image
import zpl
from zebra import Zebra
class Print:

 def __init__(self):
  self.zebra = Zebra()
  self.printers = self.zebra.getqueues()


 def print(self, queue, height, width):
    z = Zebra(queue)
    label = zpl.Label(height, width, 8)
    label.write_graphic(Image.open("barcodes/toPrinter.png"), width)
    z.output(label.dumpZPL())
    label.preview()

Here is my ZPL :

^XA^FO0,0^GFA,41412,20726,102,0000000000000000000000and rest of image data...^FS^XZ

1
The picture data of the ^GF command normally needs to be a 1-bit bitmap image!Delphi Coder

1 Answers

0
votes

PNG images have inconsistent support in most zebra printers. For example, the ^GF command appears to only support GRF images on many firmware versions. The most portable way to work with PNG images is to use the ~DY command to download and save the image to the printer. Then use ^IL to render the image (note that ^IL always positions at 0,0). Or use the ^IM command to position the PNG using ^FO.