Catalog
One . Introduction to zebra
Two . Explanation of printing principle
You need to master the following knowledge points
1. Print over the network
Network printing - Source code
2. Print through serial port
Serial printing - Source code
Serial printing - The label template
3、 ... and . More information
Zebra product | The printer 、 Barcode scanner, etc
Zebra API Documentation | Developer Portal
Zebra printers Commonly used in Product identification 、 Asset management 、 Document tracking 、 Material management 、 Management of incoming and outgoing goods And Inventory, etc Barcode label printing .
- master ZPL(II) Grammatical knowledge
- Can make ZPL The label template , Text , graphics , Bar code , Qr code etc. .
- Basic printer parameters will be set .
- Read printer configuration and status information .
- The printer has a network card installed , Have IP Address .
import imp
import socket
import time
from log import *
from config import *
g_config_printer = read_config("config/printer.json")
def sendto_printer(amount, id_number):
mysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
label = (b"""
^XA
^FO15,40^BY3
^BAN,300,Y,N,N
^FO75,30
^FD%s^SFddddddddddddD,1,F^FS
^FO111,341
^GB50,50,50,W,0^FS
^FO444,341
^GB50,50,50,W,0^FS
^PQ%s
^XZ
""" % (bytes(id_number, encoding='utf-8'), bytes(amount, encoding='utf-8')))
logger.info(label)
try:
# connecting to host
mysocket.connect((g_config_printer["ip"], g_config_printer["port"]))
mysocket.send(label) # using bytes
mysocket.close() # closing connection
except Exception as e:
logger.error( e)
if __name__ == "__main__":
sendto_printer(amount, str(time.time()))
import serial
# Designated serial port
serialPort="COM3"
# Specify the baud rate
baudRate=9600
# Open the serial port
ser=serial.Serial(serialPort, baudRate, timeout=3)
CMD = open('.//SerialPrinter.txt')
data = CMD.readline()
# Sending and receiving data
while data:
ser.write(data)
print(data)
data = CMD.readline()
ser.close()
^XA
^SEE:GB18030.DAT^FS
^CWZ,E:KAITI.FNT
^JMA^LL200^PW680^MD10^RP2^PON^LRN^LH0,0
^FO20,100
^AZN,72,72
^FD Test label Qq123^FS
^XZ
【 Factory scanning and printing & Scanning code and packing & Error tracking system 】 Complete case details (Python&PyQt Source code &Mysql database )_YYDataV Data visualization blog -CSDN Blog _pyqt Case study
The end of this sharing , Welcome to exchange . WeChat 6550523