ZPL 打印斜体粗体和下划线



我需要打印带有动态内容的ZPL。

我需要你的帮助。我是动态内容,帮助

这个词可以打印吗?请注意,内容是动态的。 请提供 ZPL 代码。

如果你想输入粗体,你可以使用这个

^FO340,128^FDbold^FS ^FO339,128^FDbold^FS

另一个选项(下划线、斜体和粗体的外部字体用法( http://labelary.com/docs.html

没有简单的方法可以在 ZPL 中将文本加粗或斜体。打印机的字体非常基本,不能那样更改。

复杂的字体设置(斜体、粗体、衬线(实际上作为压缩图像发送到 ZPL 打印机(您可以使用 ZebraDesigner 进行检查(。 该格式称为Z64,它基于LZ77。 这两个页面包含有趣的Java代码来编写转换器:

http://www.jcgonzalez.com/img-to-zpl-online

https://gist.github.com/trevarj/1255e5cbc08fb3f79c3f255e25989a18

。我仍然不确定转换的CRC部分将来是否会保持不变,因为这可能取决于供应商。

这是第一个脚本的 Python 端口:

import cv2
import base64
import matplotlib.pyplot as plt
import io
import numpy
blacklimit=int(50* 768/100)
compress=False
total=0
width_byte=0
mapCode =  dict()
LOCAL_PATH="C://DEV//printer//zebra_debug.txt"
'''
class StringBuilder(object):
def __init__(self):
self._stringio = io.StringIO()

def __str__(self):
return self._stringio.getvalue()

def getvalue(self):
return self._stringio.getvalue()

def append(self, *objects, sep=' ', end=''):
print(*objects, sep=sep, end=end, file=self._stringio)
'''
def init_map_code():
global mapCode
mapCode[1] = "G"
mapCode[2] = "H"
mapCode[3] = "I"
mapCode[4] = "J"
mapCode[5] = "K"
mapCode[6] = "L"
mapCode[7] = "M"
mapCode[8] = "N"
mapCode[9] = "O"
mapCode[10] = "P"
mapCode[11] = "Q"
mapCode[12] = "R"
mapCode[13] = "S"
mapCode[14] = "T"
mapCode[15] = "U"
mapCode[16] = "V"
mapCode[17] = "W"
mapCode[18] = "X"
mapCode[19] = "Y"
mapCode[20] = "g"
mapCode[40] = "h"
mapCode[60] = "i"
mapCode[80] = "j"
mapCode[100] = "k"
mapCode[120] = "l"
mapCode[140] = "m"
mapCode[160] = "n"
mapCode[180] = "o"
mapCode[200] = "p"
mapCode[220] = "q"
mapCode[240] = "r"
mapCode[260] = "s"
mapCode[280] = "t"
mapCode[300] = "u"
mapCode[320] = "v"
mapCode[340] = "w"
mapCode[360] = "x"
mapCode[380] = "y"
mapCode[400] = "z"

def numberToBase(n, b):
if n == 0:
return [0]
digits = []
while n:
digits.append(int(n % b))
n //= b
return digits[::-1]
def four_byte_binary(binary_str):

decimal=int(binary_str, 2)
if decimal>15:
returned=hex(decimal).upper()
returned=returned[2:]
else:
#returned=hex(decimal).upper()+"0"
returned=hex(decimal).upper()
if binary_str!="00000000":
print("cut="+returned)
returned=returned[2:]
returned="0"+returned
if binary_str!="00000000":
print("low10="+returned)
#
if binary_str!="00000000":
print(binary_str+"t"+str(decimal)+"t"+returned+"t")
return returned

def createBody(img):
global blacklimit
global width_byte
global total
height, width, colmap = img.shape 
print(height)
print(width)
print(colmap)
rgb = 0
index=0
aux_binary_char=['0', '0', '0', '0', '0', '0', '0', '0']
sb=[]
if(width%8>0):
width_byte=int((width/8)+1)
else:
width_byte=width/8
total=width_byte*height
print(height)
print("n")
print(width)
print("n")
i=0
for h in range(0, height):
for w in range(0, width):
color = img[h,w]
#print(color)
#print(w)

blue=color[0]
green=color[1]
red=color[2]
blue=blue  & 0xFF
green=green  & 0xFF
red=red  & 0xFF
"""
blue=np.uint8(blue)
green=np.unit8(green)
red=np.unit8(red)

"""
#print(bin(blue))
auxchar='1'
total_color=red+green+blue
if(total_color> blacklimit):
#print('above_black_limit')
auxchar='0'
aux_binary_char[index]=auxchar
index=index+1
if(index==8 or w==(width-1)):
if "".join(aux_binary_char) !="00000000":
print(i)
sb.append(four_byte_binary("".join(aux_binary_char)))
i=i+1
aux_binary_char=['0', '0', '0', '0', '0', '0', '0', '0']
index=0
#print(h)

sb.append("n")
#print(sb)
print(blacklimit)
return ''.join(sb)
def encode_hex_ascii(code):
global width_byte
global mapCode
max_linea=width_byte*2
sb_code=[]
sb_linea=[]
previous_line=1
counter=1
aux = code[0]
first_char=False
for i in range(1, len(code)):
if(first_char):
aux=code[i]
first_char=False
continue
if(code[i]=="n"):
if(counter>= max_linea and aux=='0'):
sb_linea.append(",")
elif(counter>= max_linea and aux=='F'):
sb_linea.append("!")  
elif(counter>20):
multi20=int((counter/20))*20
resto20=counter%20
sb_linea.append(mapCode[multi20])  
if(resto20!=0):
sb_linea.append(mapCode[resto20] +aux)  
else:
sb_linea.append(aux)
else:
sb_linea.append(mapCode[counter] +aux)

counter=1
first_char=True
if(''.join(sb_linea)==previous_line):
sb_code.append(":")
else:
sb_code.append(''.join(sb_linea))
previous_line=''.join(sb_linea)
sb_linea=[]
continue
if aux==code[i]:
counter=counter+1
else:
if counter>20:
multi20=int((counter/20))*20
resto20=counter%20
sb_linea.append(mapCode[multi20]) 
if resto20!=0:
sb_linea.append(mapCode[resto20] + aux)
else:
sb_linea.append(aux)
else:

sb_linea.append(mapCode[counter] + aux)
counter=1
aux=code[i]
return ''.join(sb_code)

def head_doc():
global total
global width_byte
return "^XA " + "^FO0,0^GFA,"+ str(int(total)) + ","+ str(int(total)) + "," + str(int(width_byte)) +", "

def foot_doc():
return  "^FS"+ "^XZ"    
def process(img):
global compress
init_map_code()
cuerpo=createBody(img)
print("CUERPOn")
print(cuerpo)
print("n")
if compress:
cuerpo=encode_hex_ascii(cuerpo)
print("COMPRESSn")
print(cuerpo)
print("n")
return head_doc() + cuerpo + foot_doc() 

img = cv2.imread("C:\Users\ftheeten\Pictures\out.jpg", cv2.IMREAD_COLOR )
compress=True
blacklimit ==int(50* 768/100)
test=process(img)
file=open(LOCAL_PATH, 'w')
file.write(test)
file.close()

相关内容

  • 没有找到相关文章

最新更新