问题
I want to create a ZPL2-Code, that prints a given PNG-Image. I tried e.g. Labelary Online (http://labelary.com), but I am not able to create the correct image-coding. I converted my PNG to a b/w-image, converted the byte-array to a Hex-String and inserted it like this:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bwImage, "png", baos);
byte[] bytes = baos.toByteArray();
System.out.println("^XA^GFA," + bytes.length + "," + bytes.length + "," + bytes.length / 8 + "," + getHexString(bytes) + "^XZ");
This works for the Labelary-Online-Preview, but not with real printer. A second point is, that when I insert an image on the Labelary-Website the Hex-String looks a lot different then mine. (It is even no Hex-String).
回答1:
I have used http://labelary.com as an inline image converter. I use the 'Add Image', then select the image data, and save that out to a *.grf file.
If you don't want to use Labelary, you can also use the Zebra Setup Utilities, and convert the image to *.grf, following this article: https://km.zebra.com/kb/index?page=content&id=SO7892.
来源:https://stackoverflow.com/questions/37658816/create-zpl-to-print-a-png-image-with-java