如何用Python调用Zebra Designer For Developers生成PRN文件?
自动生成Zebra PRN文件的Python实现需求
- 正在开发基于NiceLabel的动态标签打印程序,标签的内容与布局会持续变动
- 当前已实现标签打印功能,但标签布局更新后需手动生成新的PRN文件,这与使用Python的初衷——消除人为错误相违背
- 需求:通过Python向Zebra Designer For Developers发送命令行指令,实现自动生成PRN文件
当前开发代码
## Imports from configparser import ConfigParser from zebra import Zebra ## Testing Variables NUM = "128077-00S" SER_NUM = "3132J908A6" MODEL = "EM000" ## Get Config File config = ConfigParser() config.read('config.ini') ## Set Config Variables printer = config['printer_setup'].get('printer') prnFile = config['label_setup'].get('label') ## Read Label File labelFile = open(prnFile) label = labelFile.read() labelFile.close() ## Printing z = Zebra() try: z.getqueues().index(printer) except ValueError: print("Printer Not Found: " + printer) input("\nPress enter to continue...") else: z.setqueue(printer) out = label out = out.replace("NUM", NUM) out = out.replace("SER_NUM", SER_NUM) out = out.replace("MODEL", MODEL) z.output(out) print("Label Printed Successfully!") input("\nPress enter to continue...")
内容的提问来源于stack exchange,提问作者F Casian
相关产品推荐
相关产品推荐

