简体   繁体   English

创建ZPL以使用JAVA打印PNG图像

[英]create ZPL to print a PNG-image with JAVA

I want to create a ZPL2-Code, that prints a given PNG-Image. 我想创建一个ZPL2-Code,打印给定的PNG图像。 I tried eg Labelary Online ( http://labelary.com ), but I am not able to create the correct image-coding. 我尝试了例如在线标签网站( http://labelary.com ),但无法创建正确的图像编码。 I converted my PNG to ab/w-image, converted the byte-array to a Hex-String and inserted it like this: 我将PNG转换为ab / w-image,将字节数组转换为Hex-String并按以下方式插入:

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. 这适用于Labelary-Online-Preview,但不适用于实际打印机。 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). (甚至没有十六进制字符串)。

I have used http://labelary.com as an inline image converter. 我已经将http://labelary.com用作嵌入式图像转换器。 I use the 'Add Image', then select the image data, and save that out to a *.grf file. 我使用“添加图像”,然后选择图像数据,然后将其保存到* .grf文件中。

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 . 如果您不想使用Labelary,也可以使用Zebra设置实用程序,然后按照以下文章将图像转换为* .grf: https ://km.zebra.com/kb/index?page=content&id = SO7892

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM