【问题标题】:Printing Label from Brother QL-800 label printer从 Brother QL-800 标签打印机打印标签
【发布时间】:2019-08-26 12:37:23
【问题描述】:

我正在尝试使用 python 脚本和 Brother_ql 库从 Windows 10 打印标签。如何创建和打印标签?

使用 PIL,我创建了一个我想打印在标签上的图像。现在我想为我的 Brother 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)

【问题讨论】:

    标签: python python-3.x windows-10


    【解决方案1】:

    我知道这是一个有年头的问题,但我在互联网上的任何地方都没有找到任何文档,所以就在这里。我为自己解决这个问题玩得很开心。

    从这里阅读“后端”部分: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库文件“cli.py”中的“print_cmd”函数

    【讨论】:

      猜你喜欢
      • 2014-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多