也许有人能帮我解决我的斑马ZPL问题。ZPL手册对我没什么帮助。我想将二进制(使用ZPL B64)和压缩二进制(使用ZPL Z64)图像数据传输到打印机。
我找到了以下信息:
你们有人做过吗?
polynomial?
非常感谢。
发布于 2019-12-13 10:00:45
的ZPL手册并没有真正帮助我。
跟我说说!
为了正确计算它:
- Compress the picture bits using ZLIB (the picture must be `PixelFormat.Format1bppIndexed`, and the picture bits are best accessed with [`Bitmap.LockBits`](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.bitmap.lockbits?view=netframework-4.8)).
- Encode the compressed data into Base64. **No whitespace or line breaks allowed.**
- Convert the Base64 string to a byte array according to ASCII encoding (`System.Text.Encoding.ASCII.GetBytes(base64string)`).
- Calculate the CRC over that byte array. **The Initial CRC Value must be zero.**
发布于 2022-02-15 19:39:02
这两个页面包含有趣的Java代码,用于将图像文件编码为Z64的转换器:
http://www.jcgonzalez.com/img-to-zpl-online
https://gist.github.com/trevarj/1255e5cbc08fb3f79c3f255e25989a18
我编写了第一个链接的Java类的Python端口,形式为Python3类:https://github.com/ftheeten/python_zebra_adapter/blob/main/class_zebra.py
之后,您可以使用Pillow库生成要转换的图像。这种方法非常灵活,因为您可以使用任何有TTF文件的字体。
例如:
import socket
from PIL import ImageFont, ImageDraw, Image
import numpy as np
...
img=FUNCTION_GENERATING_A_PILLOW
zpl=Class_zpl()
zpl.set_compress(False)
zpl.set_blacklight_percentage(60)
str_label=zpl.process(img)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((PRINTER_IP, PORT_PRINTER))
s.sendall(str.encode(str_label))
#data = s.recv(1024)
s.close()
https://stackoverflow.com/questions/59319970
复制相似问题