只用过HP的打印机,用过两个,分别是:HP_p2055dn, 和 HP_LaserJet_Professional_M1216nfh 别的不知道。以下内容仅试用于HP打印机。
第一:装HP,打印机工具
pacman -S hplip
这个包,自带配置工具和打印机驱动。
其实,装这个就能用了,然后使用自带工具hp-toolbox,hp-setup之类的一设置。
不过在几年前使用第一台打印机2055的时候,我还不太懂,所以学习了一个开放的打印机接入服务cups(到底是干啥的,我也并不太知道),cups支持所有主流的打印机。
所以我当时使用的cups来添加打印机。理论上你可以用cups来添加管理所有的打印机,但是非HP的,应该是需要另装驱动的,我不清楚。
第二:基于以上,安装cups
pacman -S cups
第三:启动cups服务:
>>> systemctl start org.cups.cupsd
第四:使用浏览器访问cups服务: http://localhost:631/
在页面里可以找到添加打印机的向导,然后跑到打印机旁边,找到品牌,型号标签,然后记下来。使用socket://172.168.10.98/ 添加打印机。并选择品牌,然后选择对应型号的驱动。最后完成向导。
然后,打印测试页。在job里查看是否成功。如果错了,80%是驱动选错了。重来该步骤,直到成功!
第五:理论上,在第四步骤里边,你就已经成功了。如果你来到了第五步,说明你没有成功。
如果你的打印机不是HP,请关闭该页,去google重新search。然后,最终你一定成功,欢迎回来留言,分享经验 :)
如果你的打印机是HP的,并且是m1216nfh,那么恭喜你和我的问题一样,请继续阅读。
我遇到的问题:添加成功,打印失败,说:filter failed
查看了详细日志文件 /var/log/cups/error_log
W [/Nov/::: +] CreateProfile failed: org.freedesktop.ColorManager.AlreadyExists:profile id \'hp-m1216nfh-Gray..\' already exists
W [/Nov/::: +] CreateProfile failed: org.freedesktop.ColorManager.AlreadyExists:profile id \'hp-m1216nfh-RGB..\' already exists
E [/Nov/::: +] [Job ] Job stopped due to filter errors; please consult the error_log file for details.
D [/Nov/::: +] [Job ] The following messages were recorded from :: PM to :: PM
D [/Nov/::: +] [Job ] Adding start banner page "none".
D [/Nov/::: +] [Job ] Adding end banner page "none".
D [/Nov/::: +] [Job ] File of type application/vnd.cups-pdf-banner queued by "root".
D [/Nov/::: +] [Job ] hold_until=
D [/Nov/::: +] [Job ] Queued on "hp-m1216nfh" by "root".
D [/Nov/::: +] [Job ] time-at-processing=
D [/Nov/::: +] [Job ] filters for job:
D [/Nov/::: +] [Job ] bannertopdf (application/vnd.cups-pdf-banner to application/pdf, cost )
D [/Nov/::: +] [Job ] pdftopdf (application/pdf to application/vnd.cups-pdf, cost )
D [/Nov/::: +] [Job ] gstoraster (application/vnd.cups-pdf to application/vnd.cups-raster, cost )
D [/Nov/::: +] [Job ] hpcups (application/vnd.cups-raster to printer/hp-m1216nfh, cost )
D [/Nov/::: +] [Job ] job-sheets=none,none
D [/Nov/::: +] [Job ] argv[]="hp-m1216nfh"
D [/Nov/::: +] [Job ] argv[]=""
D [/Nov/::: +] [Job ] argv[]="root"
D [/Nov/::: +] [Job ] argv[]="Test Page"
D [/Nov/::: +] [Job ] argv[]=""
D [/Nov/::: +] [Job ] argv[]="job-uuid=urn:uuid:fb232c3c-f68d-3701-7b64-7f034da35129 job-originating-host-name=localhost date-time-at-creation= date-time-at-processing= time-at-creation=1478851985 time-at-processing=1478851985"
D [/Nov/::: +] [Job ] argv[]="/var/spool/cups/d00023-001"
D [/Nov/::: +] [Job ] envp[]="CUPS_CACHEDIR=/var/cache/cups"
D [/Nov/::: +] [Job ] envp[]="CUPS_DATADIR=/usr/share/cups"
D [/Nov/::: +] [Job ] envp[]="CUPS_DOCROOT=/usr/share/cups/doc"
D [/Nov/::: +] [Job ] envp[]="CUPS_FONTPATH=/usr/share/cups/fonts"
D [/Nov/::: +] [Job ] envp[]="CUPS_REQUESTROOT=/var/spool/cups"
D [/Nov/::: +] [Job ] envp[]="CUPS_SERVERBIN=/usr/lib/cups"
D [/Nov/::: +] [Job ] envp[]="CUPS_SERVERROOT=/etc/cups"
D [/Nov/::: +] [Job ] envp[]="CUPS_STATEDIR=/run/cups"
D [/Nov/::: +] [Job ] envp[]="HOME=/var/spool/cups/tmp"
D [/Nov/::: +] [Job ] envp[]="PATH=/usr/lib/cups/filter:/usr/bin:/usr/bin:/bin:/usr/bin"
D [/Nov/::: +] [Job ] envp[]="SERVER_ADMIN=root@T7"
D [/Nov/::: +] [Job ] envp[]="SOFTWARE=CUPS/2.2.1"
D [/Nov/::: +] [Job ] envp[]="TMPDIR=/var/spool/cups/tmp"
D [/Nov/::: +] [Job ] envp[]="USER=root"
D [/Nov/::: +] [Job ] envp[]="CUPS_MAX_MESSAGE=2047"
D [/Nov/::: +] [Job ] envp[]="CUPS_SERVER=/run/cups/cups.sock"
D [/Nov/::: +] [Job ] envp[]="CUPS_ENCRYPTION=IfRequested"
D [/Nov/::: +] [Job ] envp[]="IPP_PORT=631"
D [/Nov/::: +] [Job ] envp[]="CHARSET=utf-8"
D [/Nov/::: +] [Job ] envp[]="LANG=en_US.UTF-8"
D [/Nov/::: +] [Job ] envp[]="PPD=/etc/cups/ppd/hp-m1216nfh.ppd"
D [/Nov/::: +] [Job ] envp[]="RIP_MAX_CACHE=128m"
D [/Nov/::: +] [Job ] envp[]="CONTENT_TYPE=application/vnd.cups-pdf-banner"
D [/Nov/::: +] [Job ] envp[]="DEVICE_URI=socket://172.168.10.98"
D [/Nov/::: +] [Job ] envp[]="PRINTER_INFO=HLYT-Printer-Black"
D [/Nov/::: +] [Job ] envp[]="PRINTER_LOCATION=HLYT"
D [/Nov/::: +] [Job ] envp[]="PRINTER=hp-m1216nfh"
D [/Nov/::: +] [Job ] envp[]="PRINTER_STATE_REASONS=none"
D [/Nov/::: +] [Job ] envp[]="CUPS_FILETYPE=document"
D [/Nov/::: +] [Job ] envp[]="FINAL_CONTENT_TYPE=application/vnd.cups-raster"
D [/Nov/::: +] [Job ] envp[]="AUTH_I****"
D [/Nov/::: +] [Job ] Started filter /usr/lib/cups/filter/bannertopdf (PID )
D [/Nov/::: +] [Job ] Started filter /usr/lib/cups/filter/pdftopdf (PID )
D [/Nov/::: +] [Job ] Started filter /usr/lib/cups/filter/gstoraster (PID )
D [/Nov/::: +] [Job ] Started filter /usr/lib/cups/filter/hpcups (PID )
D [/Nov/::: +] [Job ] Started backend /usr/lib/cups/backend/socket (PID )
D [/Nov/::: +] [Job ] pdftopdf: Last filter determined by the PPD: hpcups; FINAL_CONTENT_TYPE: application/vnd.cups-raster => pdftopdf will not log pages in page_log.
D [/Nov/::: +] [Job ] PDF template file doesn\'t have form. It\'s okay.
D [/Nov/::: +] [Job ] OUTFORMAT=\"(null)\", so output format will be CUPS/PWG Raster
D [/Nov/::: +] [Job ] PID (/usr/lib/cups/filter/bannertopdf) exited with no errors.
D [/Nov/::: +] [Job ] STATE: +connecting-to-device
D [/Nov/::: +] [Job ] Looking up \"172.168.10.98\"...
D [/Nov/::: +] [Job ] PID (/usr/lib/cups/filter/pdftopdf) exited with no errors.
D [/Nov/::: +] [Job ] Color Manager: Calibration Mode/Off
D [/Nov/::: +] [Job ] Calling FindDeviceById(cups-hp-m1216nfh)
D [/Nov/::: +] [Job ] Found device /org/freedesktop/ColorManager/devices/cups_hp_m1216nfh
D [/Nov/::: +] [Job ] Calling org.freedesktop.ColorManager.Device.Get(ProfilingInhibitors)
D [/Nov/::: +] [Job ] Calling FindDeviceById(cups-hp-m1216nfh)
D [/Nov/::: +] [Job ] Found device /org/freedesktop/ColorManager/devices/cups_hp_m1216nfh
D [/Nov/::: +] [Job ] Calling GetProfileForQualifiers(Gray.Plain....)
D [/Nov/::: +] [Job ] Failed to send: org.freedesktop.ColorManager.Device.NothingMatched:nothing matched expression \'Gray.Plain.,Gray.Plain.*,Gray.*.,Gray.*.*,*\'
D [/Nov/::: +] [Job ] Failed to get profile filename for cups-hp-m1216nfh
D [/Nov/::: +] [Job ] Color Manager: no profiles specified in PPD
D [/Nov/::: +] [Job ] Set job-printer-state-message to "Color Manager: no profiles specified in PPD", current level=INFO
D [/Nov/::: +] [Job ] Color Manager: ICC Profile: None
D [/Nov/::: +] [Job ] Ghostscript using Any-Part-of-Pixel method to fill paths.
D [/Nov/::: +] [Job ] Ghostscript command line: gs -dQUIET -dPARANOIDSAFER -dNOPAUSE -dBATCH -dNOINTERPOLATE -dNOMEDIAATTRS -sstdout=%stderr -sOutputFile=%stdout -sDEVICE=cups -sMediaType=Plain -sOutputType= -r600x600 -dMediaPosition= -dDEVICEWIDTHPOINTS= -dDEVICEHEIGHTPOINTS= -dcupsBitsPerColor= -dcupsColorOrder= -dcupsColorSpace= -dcupsRowCount= -dcupsRowStep= -dcupsInteger0= -scupsPageSizeName=Letter -I/usr/share/cups/fonts -c \'<</.HWMargins[12.000000 12.000000 12.000000 12.000000] /Margins[0 0]>>setpagedevice\' -f -_
D [/Nov/::: +] [Job ] envp[]=\"CUPS_CACHEDIR=/var/cache/cups\"
D [/Nov/::: +] [Job ] envp[]=\"CUPS_DATADIR=/usr/share/cups\"
D [/Nov/::: +] [Job ] envp[]=\"CUPS_DOCROOT=/usr/share/cups/doc\"
D [/Nov/::: +] [Job ] envp[]=\"CUPS_FONTPATH=/usr/share/cups/fonts\"
D [/Nov/::: +] [Job ] envp[]=\"CUPS_REQUESTROOT=/var/spool/cups\"
D [/Nov/::: +] [Job ] envp[]=\"CUPS_SERVERBIN=/usr/lib/cups\"
D [/Nov/::: +] [Job ] envp[]=\"CUPS_SERVERROOT=/etc/cups\"
D [/Nov/::: +] [Job ] envp[]=\"CUPS_STATEDIR=/run/cups\"
D [/Nov/::: +] [Job ] envp[]=\"HOME=/var/spool/cups/tmp\"
D [/Nov/::: +] [Job ] envp[]=\"PATH=/usr/lib/cups/filter:/usr/bin:/usr/bin:/bin:/usr/bin\"
D [/Nov/::: +] [Job ] envp[]=\"SERVER_ADMIN=root@T7\"
D [/Nov/::: +] [Job ] envp[]=\"SOFTWARE=CUPS/2.2.1\"
D [/Nov/::: +] [Job ] envp[]=\"TMPDIR=/var/spool/cups/tmp\"
D [/Nov/::: +] [Job ] envp[]=\"USER=root\"
D [/Nov/::: +] [Job ] envp[]=\"CUPS_MAX_MESSAGE=2047\"
D [/Nov/::: +] [Job ] envp[]=\"CUPS_SERVER=/run/cups/cups.sock\"
D [/Nov/::: +] [Job ] envp[]=\"CUPS_ENCRYPTION=IfRequested\"
D [/Nov/::: +] [Job ] envp[]=\"IPP_PORT=631\"
D [/Nov/::: +] [Job ] envp[]=\"CHARSET=utf-8\"
D [/Nov/::: +] [Job ] envp[]=\"LANG=en_US.UTF-8\"
D [/Nov/::: +] [Job ] envp[]=\"PPD=/etc/cups/ppd/hp-m1216nfh.ppd\"
D [/Nov/::: +] [Job ] envp[]=\"RIP_MAX_CACHE=128m\"
D [/Nov/::: +] [Job ] envp[]=\"CONTENT_TYPE=application/vnd.cups-pdf-banner\"
D [/Nov/::: +] [Job ] envp[]=\"DEVICE_URI=socket://172.168.10.98\"
D [/Nov/::: +] [Job ] envp[]=\"PRINTER_INFO=HLYT-Printer-Black\"
D [/Nov/::: +] [Job ] envp[]=\"PRINTER_LOCATION=HLYT\"
D [/Nov/::: +] [Job ] envp[]=\"PRINTER=hp-m1216nfh\"
D [/Nov/::: +] [Job ] envp[]=\"PRINTER_STATE_REASONS=none\"
D [/Nov/::: +] [Job ] envp[]=\"CUPS_FILETYPE=document\"
D [/Nov/::: +] [Job ] envp[]=\"FINAL_CONTENT_TYPE=application/vnd.cups-raster\"
D [/Nov/::: +] [Job ] envp[]=\"AUTH_INFO_REQUIRED=none\"
D [/Nov/::: +] [Job ] Start rendering...
D [/Nov/::: +] [Job ] Set job-printer-state-message to "Start rendering...", current level=INFO
D [/Nov/::: +] [Job ] Processing page ...
D [/Nov/::: +] [Job ] Set job-printer-state-message to "Processing page 1...", current level=INFO
D [/Nov/::: +] [Job ] STATE: +hplip.plugin-error
D [/Nov/::: +] [Job ] prnt/hpcups/HPCupsFilter.cpp : m_Job initialization failed with error =
D [/Nov/::: +] [Job ] PID (/usr/lib/cups/filter/hpcups) stopped with status .
D [/Nov/::: +] [Job ] Hint: Try setting the LogLevel to "debug" to find out more.
D [/Nov/::: +] [Job ] hrDeviceDesc=\"HP LaserJet Professional M1216nfh MFP\"
D [/Nov/::: +] [Job ] prtGeneralCurrentLocalization type is , expected !
D [/Nov/::: +] [Job ] backendWaitLoop(snmp_fd=, addr=0x55740d4f2128, side_cb=0x55740bc95230)
D [/Nov/::: +] [Job ] Connecting to 172.168.10.98:
D [/Nov/::: +] [Job ] Connecting to printer.
D [/Nov/::: +] [Job ] STATE: -connecting-to-device
D [/Nov/::: +] [Job ] Connected to printer.
D [/Nov/::: +] [Job ] Connected to 172.168.10.98:...
D [/Nov/::: +] [Job ] backendRunLoop(print_fd=, device_fd=, snmp_fd=, addr=0x55740d4f2128, use_bc=, side_cb=0x55740bc95230)
D [/Nov/::: +] [Job ] STATE: +cups-waiting-for-job-completed
D [/Nov/::: +] [Job ] Waiting for printer to finish.
D [/Nov/::: +] [Job ] PID (/usr/lib/cups/backend/socket) exited with no errors.
D [/Nov/::: +] [Job ] Processing page ...
D [/Nov/::: +] [Job ] Rendering completed
D [/Nov/::: +] [Job ] PID (/usr/lib/cups/filter/gstoraster) exited with no errors.
D [/Nov/::: +] [Job ] End of messages
D [/Nov/::: +] [Job ] printer-state=(idle)
D [/Nov/::: +] [Job ] printer-state-message="Rendering completed"
D [/Nov/::: +] [Job ] printer-state-reasons=hplip.plugin-error
error_log
第六:直接使用hplip的工具安装,不使用cups
hp-setup -i 172.168.10.98
不需要指定驱动,自动识别,自动安装。
完成向导,打印测试页,好用!
总结:HP的打印机,就用HP的工具装,节约时间。: )
-------------------------------------------
后续:
因为并不知道为什么cups不好使,而小伙伴们都说重来没遇见过不好使的时候,所以我又尝试调查了一下,希望找到原因。
hp-setup之后,使用hp-check命令,可以查看到所以打印机的信息。成功添加的打印机使用了一个新生产的ppd,
/etc/cups/ppd/HP_LaserJet_Professional_M1216nfh_MFP.ppd
与原ppd比较如下:
(T7) ~/Src/tss/tss_sys
>>> diff
3c3
< *%%%% Created by the CUPS PPD Compiler CUPS v2.1.3.
---
> *%%%% Created by the CUPS PPD Compiler CUPS v2.2.1.
29c29
< *cupsVersion: 2.1
---
> *cupsVersion: 2.2
(T7) ~/Src/tss/tss_sys
>>>
所以,我一度以为是ppd里边这两行区别导致的问题,只要有了新ppd,就可以正常使用了(另外,这个新PPD是从哪来的?)
之后,我使用这个新ppd用cups重新加载了一次,未修复,现象与之前保持一致。
----------------------------------- Update @ 2016-11-30 ----------------------------------
即使安装好了打印机,并且一切使用正常,cupsd服务也是必然要开的。不然应用程序并不能正确的找到打印机。
可以每次使用打印机之前启动,或者保持常开。(目前我,选择每次打印前手动开,因为我并不常常打印)
[tong@T7:~/Src/tss/tss_sys/daemon/pktdump]
% systemctl enable org.cups.cupsd
[tong@T7:~/Src/tss/tss_sys/daemon/pktdump]
%
---------------------------------- Update @ 2016-12-12 ------------------------------------
上次把org.cups.cupsd服务disable掉了,今天start之后发现依然打印不了,enable之,下次再打。
/home/tong/tunnels [tong@T7] [:]
> sudo systemctl status org.cups.cupsd
● org.cups.cupsd.service - CUPS Scheduler
Loaded: loaded (/usr/lib/systemd/system/org.cups.cupsd.service; disabled; vendor preset: disabled)
Active: active (running) since Mon -- :: CST; 38s ago
Docs: man:cupsd()
Main PID: (cupsd)
Status: "Scheduler is running..."
Tasks: (limit: )
CGroup: /system.slice/org.cups.cupsd.service
└─ /usr/bin/cupsd -l Dec :: T7 systemd[]: Starting CUPS Scheduler...
Dec :: T7 systemd[]: Started CUPS Scheduler.
Dec 12 17:41:43 T7 hpcups[11469]: prnt/hpcups/HPCupsFilter.cpp 528: DEBUG: ppdOpenFile failed for /etc/cups/ppd/HP_LaserJet_Professional_M1216nfh_MFP.ppd
Dec 12 17:41:43 T7 hp[11470]: prnt/backend/hp.c 919: ERROR: null print job total=0 /home/tong/tunnels [tong@T7] [:]
> ll /etc/cups/ppd/HP_LaserJet_Professional_M1216nfh_MFP.ppd
-rw-r----- root root 11K Nov : /etc/cups/ppd/HP_LaserJet_Professional_M1216nfh_MFP.ppd /home/tong/tunnels [tong@T7] [:]
>
----------------------- Updated @ 2016-12-30 ----------------------
原来是因为打印机改了地址。再disable一次,重启之后下次有机会再试。