Linux安装HP打印机驱动

我的写字桌有点小,再放了两个显示器后,已经觉得很满,如果再放个打印机的话就几乎占满了全部的空间。于是我想这将打印机放在屋子中另外的地方,通过一个树莓派做服务器,实现我的任何设备都能连接到我的打印机。

树莓派虽然是ARM架构,但是对于一般用户来讲涉及不到那么底层架构上的区别,可以当作普通的Linux设备来用。通常来讲最近发行版可以自动识别并安装主流打印机的驱动,我之前有台Brother就是这样的。这次本来我也这么想,插上后也能在USB识别到设备,可是在配置CUPS(一款Linux下作为远程打印机的服务器软件)时候不能正确识别具体型号,我手动从CUPS中HP品牌下选型号发现找不到我的打印机系列。我能猜出来大致的原因,我的打印机实在太老了,主流驱动库没有包含我的硬件设备,我查了一下亚马逊,这款设备在2012年1月就已经上架了,现在过去了12年,真是难以置信。我之前也知道很老了但是没想到这么老,设备用的56&57墨盒,现在都没多少地方在销售在使用了。

CUPS上写着如果自动选择有问题的话,可以手动上传PPD格式的驱动,我查了一下这个就是一个文本形式的打印机描述文件,描述了打印机支持的性能,以及支持的工作方式。有了这个文件,电脑就可以与打印机通信开始工作了。维基百科使用的CUPS做的例子,也是很惊喜。

https://en.wikipedia.org/wiki/PostScript_Printer_Description

我想网上查找一个对应的PPD自己上传一下,查了半天发现这个文件很少有提供,可能实在太小众了。然后找到openprinting页面,汇集了几乎所有打印机Linux驱动,其中找到到了hplib这一个驱动,看介绍是HP公司自己出的官方Linux驱动,还是专门CUPS优化的,涵盖了几乎所有的HP设备在Linux下的文件,真是巧了。只不过没有商业上的保证和支持了,风险自负。这无所谓,这只是HP摆脱不必要的麻烦罢了。点开看具体支持的型号,真的是居多,我从中也看到我的硬件型号也包含在内。

安装也很简单,直接从Linux软件仓库安装就可以了。

sudo apt update
sudo apt install hplib

安装过程的后两行也看到,这个驱动升级了电脑中的PPD文件。这之后返回CUPS就可以正确找到驱动了。

pi@raspberrypi:~ $ sudo apt install hplip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  hplip-data libhpmud0 libsane-hpaio printer-driver-hpcups printer-driver-postscript-hp python3-renderpm
  python3-reportlab python3-reportlab-accel
Suggested packages:
  hplip-doc hplip-gui python3-notify2 system-config-printer python3-renderpm-dbg pdf-viewer python3-egenix-mxtexttools
  python-reportlab-doc
The following NEW packages will be installed:
  hplip hplip-data libhpmud0 libsane-hpaio printer-driver-hpcups printer-driver-postscript-hp python3-renderpm
  python3-reportlab python3-reportlab-accel
0 upgraded, 9 newly installed, 0 to remove and 51 not upgraded.
Need to get 9,467 kB of archives.
After this operation, 19.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirror.chaoticum.net/rpi/raspbian buster/main armhf hplip-data all 3.18.12+dfsg0-2 [6,742 kB]
Get:2 http://mirror.chaoticum.net/rpi/raspbian buster/main armhf libhpmud0 armhf 3.18.12+dfsg0-2+b1 [169 kB]
Get:3 http://mirror.chaoticum.net/rpi/raspbian buster/main armhf libsane-hpaio armhf 3.18.12+dfsg0-2+b1 [199 kB]
Get:4 http://mirror.chaoticum.net/rpi/raspbian buster/main armhf printer-driver-hpcups armhf 3.18.12+dfsg0-2+b1 [328 kB]
Get:5 http://mirror.chaoticum.net/rpi/raspbian buster/main armhf python3-reportlab-accel armhf 3.5.13-1 [33.3 kB]
Get:6 http://mirror.chaoticum.net/rpi/raspbian buster/main armhf python3-reportlab all 3.5.13-1 [541 kB]
Get:7 http://mirror.chaoticum.net/rpi/raspbian buster/main armhf hplip armhf 3.18.12+dfsg0-2+b1 [276 kB]
Get:8 http://mirror.chaoticum.net/rpi/raspbian buster/main armhf printer-driver-postscript-hp armhf 3.18.12+dfsg0-2+b1 [1,115 kB]
Get:9 http://mirror.chaoticum.net/rpi/raspbian buster/main armhf python3-renderpm armhf 3.5.13-1 [63.9 kB]
Fetched 9,467 kB in 5s (2,031 kB/s)
Selecting previously unselected package hplip-data.
(Reading database ... 161134 files and directories currently installed.)
Preparing to unpack .../0-hplip-data_3.18.12+dfsg0-2_all.deb ...
Unpacking hplip-data (3.18.12+dfsg0-2) ...
Selecting previously unselected package libhpmud0:armhf.
Preparing to unpack .../1-libhpmud0_3.18.12+dfsg0-2+b1_armhf.deb ...
Unpacking libhpmud0:armhf (3.18.12+dfsg0-2+b1) ...
Selecting previously unselected package libsane-hpaio:armhf.
Preparing to unpack .../2-libsane-hpaio_3.18.12+dfsg0-2+b1_armhf.deb ...
Unpacking libsane-hpaio:armhf (3.18.12+dfsg0-2+b1) ...
Selecting previously unselected package printer-driver-hpcups.
Preparing to unpack .../3-printer-driver-hpcups_3.18.12+dfsg0-2+b1_armhf.deb ...
Unpacking printer-driver-hpcups (3.18.12+dfsg0-2+b1) ...
Selecting previously unselected package python3-reportlab-accel:armhf.
Preparing to unpack .../4-python3-reportlab-accel_3.5.13-1_armhf.deb ...
Unpacking python3-reportlab-accel:armhf (3.5.13-1) ...
Selecting previously unselected package python3-reportlab.
Preparing to unpack .../5-python3-reportlab_3.5.13-1_all.deb ...
Unpacking python3-reportlab (3.5.13-1) ...
Selecting previously unselected package hplip.
Preparing to unpack .../6-hplip_3.18.12+dfsg0-2+b1_armhf.deb ...
Unpacking hplip (3.18.12+dfsg0-2+b1) ...
Selecting previously unselected package printer-driver-postscript-hp.
Preparing to unpack .../7-printer-driver-postscript-hp_3.18.12+dfsg0-2+b1_armhf.deb ...
Unpacking printer-driver-postscript-hp (3.18.12+dfsg0-2+b1) ...
Selecting previously unselected package python3-renderpm:armhf.
Preparing to unpack .../8-python3-renderpm_3.5.13-1_armhf.deb ...
Unpacking python3-renderpm:armhf (3.5.13-1) ...
Setting up python3-renderpm:armhf (3.5.13-1) ...
Setting up hplip-data (3.18.12+dfsg0-2) ...
Setting up printer-driver-postscript-hp (3.18.12+dfsg0-2+b1) ...
Setting up python3-reportlab-accel:armhf (3.5.13-1) ...
Setting up python3-reportlab (3.5.13-1) ...
Setting up libhpmud0:armhf (3.18.12+dfsg0-2+b1) ...
Setting up libsane-hpaio:armhf (3.18.12+dfsg0-2+b1) ...
Setting up printer-driver-hpcups (3.18.12+dfsg0-2+b1) ...
Setting up hplip (3.18.12+dfsg0-2+b1) ...
Creating/updating hplip user account...
Processing triggers for libc-bin (2.28-10+rpi1) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for dbus (1.12.16-1) ...
Processing triggers for cups (2.2.10-6+deb10u2) ...
Updating PPD files for hpcups ...
Updating PPD files for postscript-hp ...

这个教程不仅适用于我这种比较老的型号,也是其他情况linux配合CUPS没有正确识别打印机的情况。对于惠普可以试下sudo apt install hplib,大概率一个命令解决了。其他品牌的,可以在那个openprinting页面找对应型号的驱动,按照知道通过命令安装。

Reference:

https://wiki.linuxfoundation.org/openprinting/database/cupsdocumentation

http://www.openprinting.org/drivers/

http://www.openprinting.org/driver/hplip

http://www.openprinting.org/printer/HP/HP-PSC_1205

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.