zoukankan      html  css  js  c++  java
  • 使用CUPS打印服务

    1. 测试环境

    Printer: Xprinter XP-58IIH
    指令支持: ESC/POS
    接口: USB, 蓝牙
    Linux系统: Arch Linux
    $ sudo pacman -Qi cups
    Name : cups
    Version : 2.2.11-1
    Description : The CUPS Printing System - daemon package
    Architecture : x86_64
    URL : https://www.cups.org/
    Licenses : GPL
    Groups : None
    Provides : None
    Depends On : acl pam libcups>=2.2.11 cups-filters bc dbus systemd
    libpaper hicolor-icon-theme
    Optional Deps : xdg-utils: xdg .desktop file support [installed]
    colord: for ICC color profile support [installed]
    Required By : None
    Optional For : None
    Conflicts With : None
    Replaces : None
    Installed Size : 13.92 MiB
    Packager : Andreas Radke <andyrtr@archlinux.org>
    Build Date : Sun 24 Mar 2019 06:39:26 PM CST
    Install Date : Sun 07 Apr 2019 05:07:53 PM CST
    Install Reason : Explicitly installed
    Install Script : Yes
    Validated By : Signature

    2. CUPS介绍

    https://www.ibm.com/developerworks/cn/linux/l-lpic1-108-4/index.html
    管理打印机和打印 Ian Shields 2018 年 3 月 14 日发布
    CUPS 原先为通用 UNIX 打印系统 (Common UNIX Printing System) 的首字母缩写,是 Linux 的打印机和打印作业管理器。
    System 也有一个打印守护程序。它的功能类似于 Berkeley LPD,但采用不同的命令集。您将会经常看到两种具有不同选项但完成相同任务的命令。
    例如,来自 Berkeley 实施的 lpr和来自 System V 实施的 lp 都可打印文件。
    CUPS 打印系统的核心是作为守护进程运行的 cupsd 打印服务器。

    2.1 CUPS的配置文件

    2.1.1 cupsd.conf

    CUPS 配置文件通常位于 /etc/cups/cupsd.conf 中。
    原先 cupsd.conf 中允许的文件、目录和用户配置指令,现在改为存储在 cups-files.conf 中。这样可防止某些类型的特权升级攻击。

    2.1.2 cups-files.conf

    $ sudo cat /etc/cups/cups-files.conf
    # Location of the file listing all of the local printers...
    #Printcap /etc/printcap

    2.1.3 printcap

    自动生成的 /etc/printcap 文件。这是 LPD 打印服务器的配置文件名称,部分应用仍使用它来确定可用的打印机及其属性。
    $ sudo cat /etc/printcap
    # This file was automatically generated by cupsd(8) from the
    # /etc/cups/printers.conf file. All changes to this file
    # will be lost.
    Xprint|Xprint:rm=tompc:rp=Xprint:

    2.1.4 printers.conf

    $ sudo cat /etc/cups/printers.conf
    # Printer configuration file for CUPS v2.2.11
    # Written by cupsd on 2019-04-09 14:41
    # DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
    <Printer Xprint>
    UUID urn:uuid:192cdccd-05bc-3ef7-4582-c6233773ef56
    Info Xprint
    Location pc
    MakeModel Zijiang ZJ-58
    DeviceURI usb://Unknown/Printer?serial=?
    State Idle
    StateTime 1554792072
    ConfigTime 1554792065
    Type 53252
    Accepting Yes
    Shared Yes
    JobSheets none none
    QuotaPeriod 0
    PageLimit 0
    KLimit 0
    OpPolicy default
    ErrorPolicy stop-printer
    </Printer>

    2.2 SPOOL假脱机

    https://zh.wikipedia.org/zh-hans/假脱机
    假脱机(外部设备联机并行操作,SPOOL,Simultaneous Peripheral Operations On-line)是一种数据缓冲,指传输数据的过程中,将数据存放在临时工作区中。
    最常见的假脱机的应用是打印缓存,即把打印任务加入到队列。
    根据文件系统层次结构标准 (FHS),假脱机文件默认情况下存储在 /var/spool 文件系统中。

    2.3 CUPS 支持各种打印机,包括:

    Local Printers本地连接:

    • 并行打印机和 USB 打印机

    Network Printers网络链接:

    • Backend Error Handler 后端错误处理程序
    • LPD/LPR 主机或打印机
    • AppSocket/HP JetDirect
    • 互联网打印协议 (http)
    • 互联网打印协议 (https)
    • 互联网打印协议 (ipp)
    • 互联网打印协议 (ipps)

    2.4 CUPS的beh

    Backend Error Handler beh 后端错误处理程序
    https://wiki.linuxfoundation.org/openprinting/database/backenderrorhandler
    下载 beh.txt 脚本:http://www.openprinting.org/download/files/beh
    当CUPS后端和打印机之间的通信出现错误时,CUPS禁用打印队列!!!
    对于桌面/家庭用户来说, 这经常发生,通常家用打印机只会在偶尔需要使用时才打开。
    而经常发送打印任务后,才发现打印机还没开,或网线没有插...这时候就需要从新启用打印服务...
    此类问题可以通过安装beh脚本解决,此脚本使得后端错误处理可配置:
    让队列根本不被禁用。简单的方法,但工作会丢失。
    重复给定次数。
    经常无限重复,直到工作最终通过。这是LPRng的标准,它消除了工作的损失。
    也可以配置两次尝试运行后端之间的时间间隔。
    对每个打印队列独立完成配置。因此,可以区别对待本地打印机和网络打印机。
    只需下载脚本,将其复制到CUPS后端目录(通常/usr/lib/cups/backend/),然后使用“ chmod 755 beh。
    然后重新启动它注册新后端的CUPS,通常使用“ killall -HUP cupsd”或“/etc/init.d/cups restart”。
    如果你做的都正确,那么在“ beh”的输出中必须有一行包含“ lpinfo -v”。
    beh是一个包装器,由CUPS调用代替通常的后端,beh现在称为后端。
    这种方式beh可以根据其配置重复调用后端,或者只是隐藏后端的错误状态,使其不被CUPS守护程序看到。

    2.5 使用beh

    要使用打印队列beh,请获取root并调用命令,如下所示:
    lpadmin -p <queue name> -E -v beh:/<dd>/<att>/<delay>/<originaluri>

    • <queue name>:打印队列的名称
    • <dd>:如果“ 1” beh始终以零状态退出,请不要禁用,因此当原始后端退出并出现错误时,队列永远不会被禁用。“ 0”将后端的最后一次调用(<att>重试后)的错误状态传送到CUPS,因此队列通常被禁用。
    • <att>:尝试,在出现错误时尝试调用后端的次数。“ 0”表示无限重试。在这种情况下<dd>变得毫无意义。
    • <delay>:两次尝试调用beckend之间的延迟,以秒为单位给出,并作为整数。没有意义,如果<att>是一个。
    • <originaluri>:您的队列之前拥有 的原始URI(使用“ lpstat -v”来显示您的队列的URI)。

    所有参数,特别是<dd>,<att>和<delay>一直被指定,即使其中一人是没有意义的,由于其他的设置。
    beh与除了每个后端工作hp从后端HPLIP。如果beh与hp后端一起使用,HP Toolbox将无法再找到打印机。
    示例URI:
    beh:/1/3/5/socket://printer:9100
    在主机名为“ printer” 的网络打印机上,尝试访问3次,尝试之间有5秒的延迟。如果作业仍然失败,则不会禁用队列(并丢弃作业)。
    beh:/0/10/60/socket://printer:9100
    每隔一分钟重试10次,在仍未成功时禁用队列。
    beh:/1/0/60/usb://Brother/HL-5040%20series
    在USB上的Brother HL-5040上无限次地尝试,直到打印机返回,间隔为一分钟。这样,当打印机关闭时,作业不会丢失,并且可以通过简单地关闭打印机来有意地延迟打印。桌面打印机和/或家庭用户的理想配置。

    2.6 安装cups,并激活

    这里将安装在 Arch Linux 系统上。其他Linux系统主要是安装命令有差异,其他命令基本相同。
    $ sudo pacman -S cups //安装在Arch Linux系统上使用pacman命令。
    $ sudo systemctl start org.cups.cupsd //启动
    $ sudo systemctl status org.cups.cupsd //查看状态
    $ sudo systemctl enable org.cups.cupsd //设置开启启动

    3. 打印机驱动

    lpinfo 命令还可帮助您识别可用设备类型和驱动程序。使用 -v 选项可列出受支持的设备,-m 选项可列出驱动程序。

    3.1 lpinfo -m列出已有驱动程序

    $ lpinfo -m |grep hp
    $ lpinfo -m |grep epson
    drv:///sample.drv/epson9.ppd Epson 9-Pin Series
    drv:///sample.drv/epson24.ppd Epson 24-Pin Series
    全部列出,不方便查看,加上过滤条件,如上,没找到hp的打印机驱动,但有2个Epson的驱动。如果使用类似方式找到里匹配你正在使用的打印机,可以跳过下一节(添加更多的驱动。)

    3.2 添加更多的驱动

    请访问 OpenPrinting.org(参阅相关主题),查看是否有用于您的特定打印机的驱动程序。
    Foomatic:Linux Foundation的OpenPrinting工作组的foomatic为许多打印机驱动程序提供PPD,包括free和nonfree。有关foomatic的功能的更多信息,请参阅Developer's View中的Foomatic。
    要使用foomatic,请安装foomatic-db-engine以及至少以下之一:

    • foomatic-db - foomatic-db-engine用于生成PPD文件的XML文件集合。
    • foomatic-db-ppds - 预建的PPD文件。(60Mb)
    • foomatic-db-nonfree - 来自打印机制造商的XML文件集合,由foomatic-db-engine用于生成PPD文件的非免费许可证。
    • foomatic-db-nonfree-ppds - 非免费许可下的预建PPD文件。

    $ sudo pacman -S foomatic-db-engine
    $ sudo pacman -S foomatic-db-ppds //安装好这个预建的PPD文件, 有(60Mb)多,有好几千个打印机驱动了。
    “PPD文件”(PostScript打印机描述文件)
    再使用过滤条件列出已添加的驱动,找到匹配的驱动后,就可以进入下一节了,如果还是没有,上面4选1,把试过没有的卸载掉,继续尝试其他的,也可以挨个儿全部安装,添加更多的驱动再找。
    $ lpinfo -m |grep 过滤关键字

    4. 打印相关命令:

    https://www.computerhope.com/unix/ulpadmin.htm
    https://www.computerhope.com/unix/ulp.htm
    https://www.computerhope.com/unix/ulpstat.htm

    4.1 有2个打印命令

    • lp - 在System V操作系统上打印文件。
    • lpr - 提交打印请求。

    *lpr 会以静默方式实现作业假脱机,而 lp 则会显示假脱机作业的编号
    *lp 具有与 lpr 相似的选项,但名称可能不同;例如,lpr 上的 -# 与 lp 上的 -n 等效
           lpr 的选项选项 及 用途

    1. -C、-J 或 -T 设置作业名。
    2. -P 选择特定打印机。
    3. -# 指定副本数量。请注意,这与您在 lp 命令中看到的 -n 选项不同。
    4. -m 作业完成时发送电子邮件。
    5. -l 指示已设置打印文件的格式以进行打印。与 -o raw 等效。
    6. -o 设置作业选项。
    7. -p 使用阴影标题设置文本文件格式。与 -o prettyprint 等效。
    8. -q 使作业暂挂(或排队),以便稍后打印。
    9. -r 实现文件假脱机以进行打印后,移除此文件。

    4.2 打印任务管理

    lpq - 列出可用打印机的状态,列出打印作业。
    lprm - 从打印队列中删除请求。

    4.3 查看打印机状态

    lpstat - 列出LP打印服务的状态。

    • -a 显示打印机的接受状态。
    • -c 显示打印类。
    • -p 显示打印状态:已启用或已禁用。
    • -s 显示默认的一个或多个打印机和类。等效于 -d、 -c 和 -v。请注意,必须将多个选项隔开,因为可为许多选项指定值。
    • -s 显示打印机及其设备。

    lpstat -d; lpstat -v HL-2280DW; lpstat -s; lpstat -a XP-610; lpstat -p -a;

    $ lpstat -s
    system default destination: XPRINT
    device for XPRINT: usb://Unknown/Printer?serial=?
    $ lpstat -p
    printer XPRINT disabled since Mon 08 Apr 2019 05:10:17 PM CST -
    reason unknown

    4.4 控制打印机状态

    可通过 cupsaccept 和 cupsreject 命令控制是启用还是禁用排队
    可通过 cupsenable 和 cupsdisable 命令控制是启用还是禁用打印
    #cupsdisable queue_name //停用打印机
    #cupsenable queue_name //激活打印机
    #cupsaccept queue_name //将打印机设置为接受作业

    4.5 打印机设置

    $ lpoptions -d xxx //设置默认打印机
    $ lpoptions -p xxx -l //列出选项 List the options
    $ lpoptions -p xxx -o option=value //设置一个选项 Set an option
    比如:$ lpoptions -p HP_DESKJET_940C -o PageSize=A4

    5. 添加打印机

    掌握了基本信息后,安装了cups,找到了打印机驱动,就可以使用 lpadmin 命令来配置打印机.
    命令行方式 适用于几乎所有打印机

    5.1 找到打印机

    重新插拔USB设备后运行,列出最近的设备变动信息。
    $ dmesg --color=always |tail

    以USB打印机为例,使用 lpinfo命令查找打印机的uri。
    $ sudo lpinfo -v
    ...
    direct usb://Unknown/Printer?serial=?
    这里找到就是USB打印机的uri了,不同的打印机,这里会很不一样。
    注:可以先不插USB,执行以上命令;再插上USB打印机,再执行以上命令,这样就很容易分辨了。
    $ /usr/lib/cups/backend/snmp ip_address #使用SNMP查找URI

    5.2 找到打印机驱动

    使用$ lpinfo -m命令加过滤找到打印机驱动model
    $ lpinfo -m |grep 58
    lsb/usr/cupsfilters/zj58.ppd Zijiang ZJ-58
    如果正好找到了,就可以跳到下一节添加打印机了。

    5.2.1 添加更多的驱动

    参照3.2 添加更多的驱动
    然后再lpinfo1 -m查找,大部分都能通过以上方式或打印机厂商网站找到。

    5.2.2 安装第三方驱动(20190412补充)

    如果以上方式都没有适合的驱动,正好买到了小众的打印机,有些国产或者山寨等,也可以向店家请教。
    比如这里找到了github上的驱动。
    https://github.com/klirichek/zj-58
    下载,参照readme的指导安装即可
    $ sudo pacman -S cmake //安装编译工具
    下载,解压缩.
    $ cd /home/toma/Downloads/xp/zj58 //进入解压缩的目录
    $ mkdir build //建立构建二进制用的目录
    $ cmake /home/toma/Downloads/xp/zj58 //编译
    $ sudo make install //安装
    ...
    [100%] Linking C executable rastertozj
    [100%] Built target rastertozj
    Install the project...
    -- Install configuration: "Release"
    -- Installing: /usr/lib/cups/filter/rastertozj
    -- Installing: /usr/share/cups/model/zjiang/zj58.ppd
    -- Installing: /usr/share/cups/model/zjiang/xp58.ppd
    -- Installing: /usr/share/cups/model/zjiang/tm20.ppd
    -- Installing: /usr/share/cups/model/zjiang/zj80.ppd
    $ lpinfo -m |grep xp58
    zjiang/xp58.ppd J-speed XP-58 

    5.3 添加打印机

    $ sudo lpadmin -p queue_name -E -v uri -m model
    queue_name, 改为打印机名称。
    uri,前面lpinfo找到的字符串。
    model,前面找到的打印机驱动,指定PPD文件。

    https://lists.cups.org/pipermail/cups/2004-December/031341.html
    有两种方法可以指定PPD:-m标准模型 或 -P绝对路径的ppd文件
    "-m ppdfile.ppd”或“-m subdir/ppdfile.ppd"这个“-m”参数
    指定标准的CUPS“模型”(通常位于“/usr/share/cups/model/”)或者在子目录中
    “在/usr/share/cups/model/subdir/”。就是使用lpinfo -m找到的ppd文件。
    注:指定标准模型或PPD文件,如上只需要使用文件名,或子目录文件名即可,不需要注明具体的路径。
    另注:查看当前ArchLinux系统的ppd文件在这里:/usr/share/ppd/cupsfilters/

    “-P /path/to/ppdfile.ppd”或“-P ../path/to/ppdfile.ppd”。这个“-P”
    参数采用绝对或相对路径来查找 ppdfile.ppd。这类是标准库里找不到,从其他地方获取的,需要手动指定,则需要绝对路径,比如:/home/toma/Download/zj58.ppd

    https://wiki.archlinux.org/index.php/CUPS 上的添加示例

    • #lpadmin -p HP_01 -E -v "usb://HP...uri" -m drv:///HP...ppd.gz //指定标准模型
    • #lpadmin -p AirPrint -E -v "ipp://10.0.1.25/ipp/print" -m everywhere #无驱动(Apple AirPrint或IPP Everywhere)
    • #lpadmin -p Print02 -m raw #Raw queue; 没有PPD或过滤器
    • #lpadmin -p Print03 -E -v "ipp://10.0.1.3/ipp/print" -m pxlmono.ppd #指定PPD而不是模型

    本机添加(错误尝试记录):
    $ sudo lpadmin -p Xprint -E -v "usb://Unknown/Printer?serial=?" -m zj58.ppd
    lpadmin: Unable to copy PPD file.
    注:zj58.ppd并不是标准库里的,我是从github上找到的,手动复制到标准模型的目录下,
    $ sudo cp zj58.ppd /usr/share/ppd/cupsfilters/zj58.ppd
    然后使用-m指定ppd文件来添加打印机,结果报错:“无法复制PPD文件”。
    这时就需要使用-P指定绝对路径的方式了:
    $ sudo lpadmin -p Xprint -E -v "usb://Unknown/Printer?serial=?" -P /usr/share/ppd/cupsfilters/zj58.ppd
    添加成功后,会将ppd文件复制到/etc/cups/ppd/Xprint.ppd
    单纯指定一个ppd文件,可以添加成功,查看打印机状态也OK,但发送打印任务永远都是stoped状态。

    正确的方式是标准库里的PPD模型,或者下载厂商提供的驱动程序,我这里使用的是第三方驱动,(20190412添加)
    5.2.2 安装第三方驱动
    这是再查找出 -v, -m 参数,然后添加打印机:
    $ sudo lpinfo -v
    direct usb://Unknown/Printer?serial=?
    $ lpinfo -m |grep xp58
    zjiang/xp58.ppd J-speed XP-58
    $ sudo lpadmin -p Xprint58 -E -v "usb://Unknown/Printer?serial=?" -m zjiang/xp58.ppd

    5.3.1 设置默认打印机

    $ lpstat -s
    no system default destination
    device for Xprint58: usb://Unknown/Printer?serial=?
    [toma@tompc build]$ lpstat -p
    printer Xprint58 is idle. enabled since Fri 12 Apr 2019 11:41:10 AM CST
    [toma@tompc build]$

    $ lpoptions -d Xprint58
    copies=1 device-uri=usb://Unknown/Printer?serial=? finishings=3 job-cancel-after=10800 job-hold-until=no-hold job-priority=50 job-sheets=none,none marker-change-time=0 number-up=1 printer-commands=none printer-info=Xprint58 printer-is-accepting-jobs=true printer-is-shared=true printer-is-temporary=false printer-location printer-make-and-model='J-speed XP-58' printer-state=3 printer-state-change-time=1555040470 printer-state-reasons=none printer-type=53252 printer-uri-supported=ipp://localhost/printers/Xprint58

    $ lpstat -p
    printer Xprint58 is idle. enabled since Fri 12 Apr 2019 11:41:10 AM CST
    [toma@tompc build]$ lpstat -s
    system default destination: Xprint58
    device for Xprint58: usb://Unknown/Printer?serial=?

    5.3.2 更改选项

    #列出选项
    $ lpoptions -p Xprint58 -l
    PageSize/Media Size: *X48MMY65MM X48MMY105MM X48MMY210MM X48MMY297MM X48MMY3276MM Custom.WIDTHxHEIGHT
    CutMedia/Cut Media: *None EndOfPage EndOfJob
    OptionCash1/Cash drawer 1: *False True
    OptionCash2/Cash drawer 2: *False True
    OptionCutter/Cutter: *False True
    FeedDist/Feed distance: 0feed3mm 1feed6mm *2feed9mm 3feed12mm 4feed15mm 5feed18mm 6feed21mm 7feed24mm 8feed27mm 9feed30mm 10feed33mm 11feed36mm 12feed39mm 13feed42mm 14feed45mm
    FeedWhere/When to feed: None AfterPage *AfterJob
    BlankSpace/Blank space at page's end: True *False
    CashDrawer1Setting/Cash Drawer 1: *None 1BeforePrinting 1AfterPrinting
    CashDrawer2Setting/Cash Drawer 2: *None 2BeforePrinting 2AfterPrinting
    CashDrawer1PulseOn/Cash Drawer 1 pulse ON time: None 10XMS 20XMS 30XMS *40XMS 50XMS 60XMS 70XMS 80XMS
    CashDrawer1PulseOff/Cash Drawer 1 pulse OFF time: None 10XMS 20XMS 30XMS 40XMS *50XMS 60XMS 70XMS 80XMS
    CashDrawer2PulseOn/Cash Drawer 2 pulse ON time: None 10XMS 20XMS 30XMS *40XMS 50XMS 60XMS 70XMS 80XMS
    CashDrawer2PulseOff/Cash Drawer 2 pulse OFF time: None 10XMS 20XMS 30XMS 40XMS *50XMS 60XMS 70XMS 80XMS
    Resolution/Resolution: *203x203dpi

    激活打印机
    #cupsenable Xprint58
    将打印机设置为接受作业
    #cupsaccept Xprint58

    5.3.3 检查状态

    $ lpstat -s
    system default destination: Xprint58
    device for Xprint58: usb://Unknown/Printer?serial=?
    $ lpstat -p
    printer Xprint58 is idle. enabled since Sun 07 Apr 2019 09:37:27 PM CST

    禁用打印机后再查看状况
    #cupsenable Xprint
    $ lpstat -p
    printer Xprint disabled since Sun 07 Apr 2019 09:54:03 PM CST -
    Unable to send data to printer.

    5.3.4 测试打印

    $ lpr file
    $ lpr -# 17 file # print the file 17 times
    $ echo 'Hello, world!' | lpr -p # print the result of a command. The -p switch adds a header.

    5.3.5 打印任务

    列出打印队列
    $ lpq
    $ lpq -a # on all queues
    移除打印任务
    # lprm # remove last entry only
    # lprm - # remove all entries

    5.4 添加打印机-图形界面

    部分厂商提供独立的打印驱动安装程序,参照厂商说明安装好驱动,然后打开CUPS的网页添加打印机即可。
    http://127.0.0.1:631

    5.5 删除打印机

    首先将其设置为拒绝所有传入的条目:
    $ sudo cupsreject XPRINT
    $ lpstat -p
    printer XPRINT disabled since Mon 08 Apr 2019 05:10:17 PM CST -
    Rejecting Jobs

    然后禁用它。
    $ sudo cupsdisable XPRINT
    $ lpstat -p
    printer XPRINT disabled since Mon 08 Apr 2019 05:10:17 PM CST -
    Paused

    最后删除它。
    $ sudo lpadmin -x XPRINT
    $ lpstat -p
    lpstat: No destinations added.
    $ lpstat -s
    no system default destination
    lpstat: No destinations added.
    lpstat: No destinations added.

    6. 其他参考(只有链接和部分摘要,具体请打开链接看原文)

    https://www.cups.org/faq.html
    https://www.cups.org/doc/options.html
    http://localhost:631/help
    https://en.wikipedia.org/wiki/CUPS

    6.1 本机使用的打印机Xprinter XP-58的第三方驱动

    Printer name is "Xprinter", model: XP-58IIH. Support USB and Bluetooth.
    https://github.com/klirichek/zj-58
    Zj-58, Zj-80 and other receipt printers
    CUPS filter for cheap thermal receipt printers as Zijiang ZJ-58, XPrinter XP-58, JZ-80 with cutter, Epson TM-T20, and may be any other printers understanding ESC/POS commands.
    Originally it was reverse-engineered filter for Zijiang zj-58 with it's specific PPD, but later it is revealed that it actually works with many other cheap 58mm printers, like Xprinter XP-58.
    https://github.com/klirichek/zj-58/blob/master/zj58.ppd

    6.2 异常问题检查

    https://wiki.ubuntu.com/DebuggingPrintingProblems
    Debugging Printing Problems

    打开终端/控制台并检查是否加载了usb内核模块:
    $ lsmod | grep usb

    检查USB子系统是否正确检测到打印机并确定其USB供应商/产品ID以及USB总线和设备地址:
    $ lsusb
    注意:如果关闭或拔下打印机电源,USB总线和设备地址会发生变化。如果需要,请重新运行此命令。

    检查打印机的设备文件是否已创建,所有权(“root lp”)和权限(非HP:“crw-rw-r--”,HP:“crw-rw-r - +”)是否正确设置:
    $ ls -l /dev/usb/lp*
    $ ls -l /dev/bus/usb/*/*

    6.3 开发人员观点中的Foomatic如何运作?(有流程图)

    http://www.openprinting.org/download/kpfeifle/LinuxKongress2002/Tutorial/IV.Foomatic-Developer/IV.tutorial-handout-foomatic-development.html

    6.4 其他Linux系统的参考

    https://wiki.archlinux.org/index.php/CUPS
    https://wiki.archlinux.org/index.php/CUPS/Printer-specific_problems
    https://wiki.gentoo.org/wiki/Printing
    https://wiki.debian.org/Printing
    https://wiki.debian.org/SystemPrinting

    6.5 openprinting.org的(绝望指南)

    http://www.openprinting.org/download/kpfeifle/LinuxKongress2002/Tutorial/VII.cups-help/VII.cups-help.html
    (VII。)故障排除 - CUPS-并寻求帮助HOWTO(绝望指南)
    https://www.cups.org/documentation.html

    6.6 查看错误日志

    http://127.0.0.1:631/admin/log/error_log?
    E [09/Apr/2019:10:23:28 +0800] [cups-driverd] Unable to open "/usr/share/cups/model/zj58.ppd" - No such file or directory
    /usr/share/cups/model/zj58.ppd

    E [09/Apr/2019:20:34:56 +0800] Xprint: File "/usr/lib/cups/filter/rastertozj" not available: No such file or directory

    /usr/lib/cups/filter/rastertozj

    6.7 OpenPrinting CUPS快速入门

    https://wiki.linuxfoundation.org/openprinting/database/foomatic
    https://wiki.linuxfoundation.org/openprinting/database/cupsdocumentation
    Foomatic计划分为三个部分:
    数据库
    该数据库包含许多XML文件,这些文件详细说明了如何执行给定的打印机驱动程序。有两个前端使用这些文件:(1)人类可读的前端生成所有“执行细节”页面上显示的信息; (2)PPD-O-Matic PPD生成器计算Adobe兼容的PPD文件,您需要配置打印队列。
    PPD文件
    数据库生成的PPD文件包含有关重要打印机功能,可用选项以及如何构建渲染器(通常为Ghostscript)命令行的所有信息,具体取决于用户对选项的选择。foomatic-rip读取它以了解如何执行打印作业。GUI前端读取它以构建用户可以调整选项的对话框。除了通常的东西,PPD文件包含以“* Foomatic ...”开头的各种额外行。这些包含驱动程序命令行的详细信息,选项是否接受任意数字(而不仅仅是PPD文件中列出的选项)等信息。CUPS和应用程序忽略了这些额外的行。
    过滤器
    过滤脚本'foomatic-rip'由CUPS调用,具有各种输入; 输入包括PPD文件名和用户选择的各种选项。foomatic-rip打开PPD,提取所有选项及其可能的设置,还提供命令行以使用适当的驱动程序执行Ghostscript。它解析PostScript打印文件以进行选项设置。这些选项设置可能已被CUPS或应用程序填入; foomatic-rip本身还会在打印数据流中插入其他PostScript代码,以便根据需要设置选项。它还将标准CUPS选项类型按摩为数据库使用的更通用的打印机/驱动程序特定格式。

    6.8 使用CUPS打印的基础知识

    https://wiki.linuxfoundation.org/openprinting/database/cupsprintingtutorial
    本教程介绍了使用CUPS打印的基础知识,包括
    设置本地(USB,并行)PostScript和非PostScript打印机
    多功能设备
    为以太网连接的打印机分配IP地址
    在网络中共享打印机
    高可用性 - 冗余CUPS队列和服务器
    使用Samba将打印机共享到Windows机器
    和更多 …

    6.9 用户角度的教程

    http://www.openprinting.org/download/kpfeifle/LinuxKongress2002/Tutorial/II.Foomatic-User/II.tutorial-handout-foomatic-user.html
    (II。)从用户的角度看起来很有用:
    在Foomatic的帮助下安装打印机
    设置打印机的一个大问题是使假脱机程序调用正确的过滤器并使用户可以控制打印机的功能。大多数GNU / Linux发行版使用自己的工具,这些工具通常不支持最新的打印机型号,也只能访问非常基本的驱动程序选项。
    为了改善这种情况,Printing-HOWTO的作者Grant Taylor建立了一个数据库,用于提供有关免费软件打印机驱动程序以及打印机以及如何使用免费软件支持它们的信息。这个名为Foomatic的数据库位于linuxprinting.org上而我目前正在维护它。现在,数据库列出了所有免费软件打印机驱动程序及其命令行和所有可用选项以及所有打印机,我们可以获取有关它们支持程度的信息。数据库是用XML实现的,Perl脚本可以自动创建配置文件,甚至可以为所有已知的免费缓冲器完成打印机队列:LPD,LPRng,GNUlpr,CUPS,PPR,PDQ和无后台打印。通过这些队列,用户可以访问所使用的打印机驱动程序的全部功能,并获得与假脱机程序无关的用户界面,以便他可以以相同的方式操作所有的假脱机程序。
    http://www.linuxprinting.org/
    http://www.openprinting.org/download/
    http://www.openprinting.org/download/kpfeifle/LinuxKongress2002/Tutorial/II.Foomatic-User/II.Foomatic-User.pdf
    https://wiki.linuxfoundation.org/openprinting/start
    https://wiki.linuxfoundation.org/openprinting/database/foomatic
    https://wiki.linuxfoundation.org/openprinting/database/aboutfoomatic
    Foomatic是一个数据库驱动的系统,用于在Unix下将免费软件打印机驱动程序与常见的解析器集成。
    它支持CUPS,LPRng,LPD,GNUlpr,Solaris LP,PPR,PDQ,CPS,以及我们已知的每个免费软件打印机驱动程序以及已知使用这些驱动程序的每个打印机的直接打印。

    https://en.opensuse.org/Concepts_printing
    https://en.opensuse.org/SDB:CUPS_in_a_Nutshell

    6.10 打印为PDF

    跨平台的办公软件LibreOffice自带PDF输出,所以大部分需有直接在这里就能实现了。
    以下是CUPS的cups-pdf的软件包,可以直接输出为PDF文件。
    https://wiki.archlinux.org/index.php/CUPS
    If you intend to "print" into a PDF document, also install the cups-pdf package. By default, pdf files are stored in /var/spool/cups-pdf/username/. The location can be changed in /etc/cups/cups-pdf.conf.
    $ sudo pacman -S cups-pdf
    http://distro.ibiblio.org/smeserver/contribs/rvandenaker/testing/smeserver-cups/documentation/howtos/cups-pdf-printer.html

  • 相关阅读:
    The connection to the server localhost:8080 was refused
    Error: client: etcd cluster is unavailable or misconfigured; error #0: dial tcp 127.0.0.1:4001: getsockopt: connection refused
    docker-machine on azure
    Spine学习二 -播放Spine动画
    第三人称角色控制器解析
    3D人物移动控制实现方案
    Transform与Vector3 的API
    Animator.SetFloat(string name,float value,float dampTime,float deltaTime)详解
    Unity坑之 加了Rigidbody后主角反而朝天上飞?
    使用代码给Unity中的动画片段绑定回调函数
  • 原文地址:https://www.cnblogs.com/sztom/p/10686925.html
Copyright © 2011-2022 走看看