创建 ZPL 以使用 JAVA 打印 PNG 图像 [英] create ZPL to print a PNG-image with JAVA

查看:255
本文介绍了创建 ZPL 以使用 JAVA 打印 PNG 图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个 ZPL2-Code,用于打印给定的 PNG 图像.我试过例如Labelary Online (http://labelary.com),但我无法创建正确的图像编码.我将 PNG 转换为黑白图像,将字节数组转换为十六进制字符串并像这样插入:

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");

这适用于 Labelary-Online-Preview,但不适用于真正的打印机.第二点是,当我在 Labelary-Website 上插入图像时,十六进制字符串看起来与我的有很大不同.(它甚至不是十六进制字符串).

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).

推荐答案

我用过 http://labelary.com作为内嵌图像转换器.我使用添加图像",然后选择图像数据,并将其保存到 *.grf 文件中.

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.

如果您不想使用 Labelary,也可以使用 Zebra Setup Utilities,并将图像转换为 *.grf,参考这篇文章:https://km.zebra.com/kb/index?page=content&id=SO7892.

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.

这篇关于创建 ZPL 以使用 JAVA 打印 PNG 图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆