python-3.x 使用Brother QL-800标签打印机打印标签

xt0899hw  于 2023-03-24  发布在  Python
关注(0)|答案(1)|浏览(258)

我尝试使用python脚本和brother_ql库从windows 10打印标签。如何创建和打印标签?
使用PIL我已经创建了一个图像,我想有一个标签打印。现在我想创建一个标签,我的兄弟QL-800标签打印机。

from brother_ql import BrotherQLRaster, create_label
from brother_ql.backends import backend_factory, guess_backend
from brother_ql.devicedependent import models, label_type_specs, 
label_sizes
from PIL import Image

LABEL_SIZES = [(name, label_type_specs[name]['name']) for name in 
label_sizes]
model = [m for m in models]
printer_model = model[9]  #QL-800
label_type = LABEL_SIZES[12]  #('29x90', '29mm x 90mm die-cut')

im = Image.open('tempQR.png', 'r')
im = im.resize((306, 991))
qlr = BrotherQLRaster(printer_model)

label = create_label(qlr, im, label_size='29x90', threshold=70, cut=True, 
rotate=0)
0sgqnhkj

0sgqnhkj1#

我知道这是一个一年前的问题,但我还没有找到任何文件张贴在互联网上的任何地方,所以在这里它是。我有一个有趣的时间弄清楚这个自己。
从这里阅读“后端”部分:http://brother-ql.net/readme.html,下载并运行windows usb驱动过滤器。如果你还没有,值得阅读整个页面。
我已经在Windows 10和运行Raspbian的Raspberry pi 4上测试了此代码。

from PIL import Image
from brother_ql.conversion import convert
from brother_ql.backends.helpers import send
from brother_ql.raster import BrotherQLRaster

im = Image.open('tempQR.png')
im.resize((306, 991)) 

backend = 'pyusb'    # 'pyusb', 'linux_kernal', 'network'
model = 'QL-800' # your printer model.
printer = 'usb://0x04f9:0x209b'    # Get these values from the Windows usb driver filter.  Linux/Raspberry Pi uses '/dev/usb/lp0'.

qlr = BrotherQLRaster(model)
qlr.exception_on_warning = True

instructions = convert(

        qlr=qlr, 
        images=[im],    #  Takes a list of file names or PIL objects.
        label='29x90', 
        rotate='90',    # 'Auto', '0', '90', '270'
        threshold=70.0,    # Black and white threshold in percent.
        dither=False, 
        compress=False, 
        red=False,    # Only True if using Red/Black 62 mm label tape.
        dpi_600=False, 
        hq=True,    # False for low quality.
        cut=True

)

send(instructions=instructions, printer_identifier=printer, backend_identifier=backend, blocking=True)

这基本上是来自brother_ql库文件“www.example.com”的“print_cmd”函数cli.py。

相关问题