使用 CUPS 打印到 USB 标签打印机

使用 CUPS 打印到 USB 标签打印机

我正在尝试将一个简单的文本文件打印到连接到我的 Ubuntu 14.04 系统的 USB 标签打印机上。

文本文件很简单:

echo "Test Passed" > file.txt

我发现我的打印机如下:

lpinfo -v

...
direct usb://Brother/QL-570?serial-=J2Z376442
...

我创建了一台打印机,如下所示:

lpadmin -p Label -E -v usb://Brother/QL-570?serial-=J2Z376442

现在当我尝试打印时:

lp -d Label file.txt

我得到:

request id is Label-8 (1 file(s))

承诺/期待答复,但标签打印机上没有任何输出(是的,它已插入/在线)。

有人遇到过这种情况/有什么想法吗?

答案1

我为这个问题苦苦挣扎了两天多。对我来说答案很简单。需要安装 i386 版本的 cups 才能使打印机执行任何操作。

这是我的docker文件:

FROM ubuntu:latest

LABEL Pellet Norman

# Unrelated to CUPS. Just need to set the timezone to avoid the interfactive mode
ENV TZ=Europe/Zurich
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Cups installation
RUN mkdir -p /var/spool/lpd

RUN dpkg --add-architecture i386
RUN apt-get update &&\
    apt-get install -y cups cups-bsd &&\
    apt-get install -y libcups2:i386

# Some other stuff for me
RUN apt-get install -y apt-utils &&\
    apt-get install -y nano

# Copy the drivers
COPY pt9800pcncupswrapper-1.0.1-1.i386.deb /root/pt9800pcncupswrapper-1.0.1-1.i386.deb
COPY pt9800pcnlpr-1.0.1-1.i386.deb /root/pt9800pcnlpr-1.0.1-1.i386.deb
COPY ptp950cupswrapper-1.0.0-0.i386.deb /root/ptp950cupswrapper-1.0.0-0.i386.deb

# Install the drivers
RUN dpkg -i  /root/pt9800pcnlpr-1.0.1-1.i386.deb
RUN dpkg -i  /root/pt9800pcncupswrapper-1.0.1-1.i386.deb

# Copy the access control, etc, that was defined from the WSL implementation
COPY cupsd.conf /etc/cups/

# Add root to the lp group. But ok that's not really necessary
RUN usermod -a -G lp root

# Here's I'm copying the printer ppd files that I will use later to overwrite the config given by Brother
COPY printers /home/docker/printers

# A test document to print
COPY document.pdf /home/docker/document.pdf

# The setup script
COPY setup.sh /home/docker/setup.sh

#ADD cupsd.conf /etc/cups/cupsd.conf
ENTRYPOINT /home/docker/setup.sh && /bin/bash

启动脚本:

#!/bin/sh
service cups restart

lpadmin -p PT-9800PCN-2N25 -h 127.0.0.1:631 -E -v socket://IP_ADDRESS -P /usr/share/cups/model/Brother/brother_pt9800pcn_printer_en.ppd
cp -R /home/docker/printers/* /etc/cups/ppd
lpr -H localhost:631 -P PT-9800PCN-2N25  -o media=MY_CUSTOM_SIZE /home/docker/document.pdf

一旦 docker 运行,document.pdf 就会被打印出来!

我主要偶然发现了 libcups2:i386 丢失的二进制文件。

相关内容