Brother PTouch QL系列打印机具备USB接口和QR码打印功能。这是一个典型的型号:http://www.ptouchdirect.com/ptouch/new_ql570.html。我该如何准备输入格式并直接从我的程序中与它们通信?我对Windows,Mac和Linux平台感兴趣。任何语言都可以,Python库是最完美的。我不想生成输出(例如CSV)并要求用户将其加载到Brother提供的应用程序中。
lp
或lpr
命令)打印使用任何方便的文件格式。我使用 iText 库来打印 QR 条码。它可以生成条形码图片并将其放入 PDF 文件中,用户可以将其发送到打印机。该库基于 Java 平台,并且还提供了 .NET 版本。
有一个名为brotherprint的包,是pypi的一部分:
https://pypi.python.org/pypi/brotherprint/0.1.1
据说它可以处理发送套接字,但我还没有尝试过:
import re
'''Brother Python EscP Command Library
Description:
A collection of functions to more easily facilitate printing to the Brother QL label
printers without having to memorize the ESC/P commands. Also handles sending to sockets
for you.
'''
class BrotherPrint:
font_types = {'bitmap': 0,
'outline': 1}
def __init__(self, fsocket):
self.fsocket = fsocket
self.fonttype = self.font_types['bitmap']
查看:https://github.com/fozzle/python-brotherprint/blob/master/brotherprint/brotherprint.py