create ZPL to print a PNG-image with JAVA

廉价感情. 提交于 2019-12-12 17:40:47

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!