I have a task of developing python script to print labels using the networked Zebra ZT410.
So far, I can print Chinese Characters correctly using "Zebra Setup Utilities" with ZPL commands:
^XA
^CW1,E:SIMSUN.TTF
^SEE:GB18030.DAT^CI26
^FO200,10^A1N,36,20^FDHTM1汉字^FS
^XZ
Now, I edited python code according the simple code on URL https://www.zebra.cn/us/en/support-downloads/knowledge-articles/ait/Network-Printing-Python-Example.html
# -*- coding: utf-8 -*-
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('168.168.183.199', 9100))
zpl = '''
^XA
^CW1,E:SIMSUN.TTF
^SEE:GB18030.DAT^CI26
^FO200,10^A1N,36,20^FDHTM1汉字^FS
^XZ
'''
s.send(zpl.encode())
s.close()
However, the Chinese characters on label is messy code as launching this script.
Are there anyone can give me advice on how to fixing this python code?
By the way, my printer is ZT410-300dpi,V75.20.21Z,12,4096KB and its details listed below:
- DIR R:*.*
- 4171776 bytes free R: RAM
- DIR E:*.*
* E:GB18030.DAT 95760 P
* E:SIMSUN.TTF 11519056 P 1
* E:TT0003M_.TTF 169188 P
- 55322112 bytes free E: ONBOARD FLASH
- DIR B:*.*
- DIR A:*.*
- DIR Z:*.*
* Z:0.TTF 125904 P 0
* Z:A.FNT 6839 P A
* Z:ALERTCFG.NRD 5186 P
* Z:AZTEC.BAR 0 P
* Z:B.FNT 7746 P B
* Z:BLUEBCK.BMP 230454 P
* Z:BLUEBCKDARK.BMP 230454 P
* Z:BLUETOOTH.WML 7938 P
* Z:BLUETOOTH420.BMP 400 P
* Z:BLUETOOTH52.BMP 480 P
* Z:BLUETOOTHCOLOR.WML 9373 P
* Z:BLUETOOTH_ICON.BMP 128 P
* Z:BLUETOOTH_NOT_AVAILABLE_ICON.BMP 128 P
* Z:CODABAR.BAR 0 P
* Z:CODABLK.BAR 0 P
* Z:CODE11.BAR 0 P
* Z:CODE128.BAR 0 P
* Z:CODE39.BAR 0 P
* Z:CODE49.BAR 0 P
* Z:CODE93.BAR 0 P
* Z:D.FNT 10648 P CD
* Z:DATA_BLANK_ICON.BMP 128 P
* Z:DATA_ICON.BMP 128 P
* Z:DISPLYQR.WML 2996 P
* Z:DISPLYQRCOLOR.WML 3189 P
* Z:DOWN_ARROW_COLOR.BMP 166 P
I figure it out, just replace s.send(zpl.encode())
with s.send(zpl.encode(encoding='GB18030'))
# -*- coding: utf-8 -*-
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('168.168.183.199', 9100))
zpl = '''
^XA
^CW1,E:SIMSUN.TTF
^SEE:GB18030.DAT^CI26
^FO200,10^A1N,36,20^FDHTM1汉字^FS
^XZ
'''
s.send(zpl.encode(encoding='gb18030'))
s.close()