Tagged: cups

Getting HP Laser Jet Pro 200 color MFP working with Gentoo

Configuring a printer was never successful for me in the past. At one point, I was able to set it up on Slackware but when I did a test print, it came out either skewed or enlarged for some reasons. I couldn't figure out why it behaved that way, so I gave up.

Now, due to the COVID-19 pandemic, my kids are home-schooling and it had become unavoidable that I need to set up a printer on my Gentoo system. After struggling for close to a week, I finally found a way to configure it correctly and was able to print documents. For my future note, I've describe how to set it up on Gentoo.

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

User and lp Group:

User need to be part of lp group to be able to print. If User needs to edit via cups web interface, he needs to be part of lpadmin. # gpasswd -a [USER] lp # gpasswd -a [USER] lpadmin

Configure cups:

cups need to be re-configed with zeroconf USE flag. # echo "net-print/cups zeroconf" > /etc/portage/package.use/cups # emerge --ask net-print/cups

Install hplip:

There is a Gentoo Wiki in HPLIP. To sum up, net-print/hplip needs to be installed with the snmp, static-ppds, hpijs and scanner USE flags.# echo "net-print/hplip snmp static-ppds hpijs scanner" > /etc/portage/package.use/hplip # emerge --ask net-print/hplip

Copy PPD:

PPD (PostScript Printer Description)is a file that describes the features and capabilities of the target printer. All PPD files are located in /usr/share/HP/ by default. They are gunzip'ed, so it needs to be decompressed and copied to /etc/cups/ppd/.

My printer is HP LaserJet Pro 200 color MFP M276nw. The closest PPD file I can file is hp-laserjet_200_colormfp_m276-ps.ppd.gz and that's the one I'm going to use. # cd /usr/share/ppd/HP/ # gunzip -d /usr/share/ppd/HP/hp-laserjet_200_colormfp_m276-ps.ppd.gz # cp -d hp-laserjet_200_colormfp_m276-ps.ppd /etc/cups/ppd/

Keyserver for gpg keys:

My printer needs a binary plugin for it to work according to HP's site. To install it, hp-plugin needs to be executed as a regular user with the -i option for the interactive mode.

However, it fails with error: Unable to recieve key from keyserver. This issue stumped me for a few days and I was almost about to give up installing the printer. Then I found a solution in a forum where it suggests to update one of python files with hard-coded keyserver name. Once the keyserver name was changed to something working, the installation of binary plugin went successfully.# nvim /usr/share/hplip/base/validation.py ========== ... class GPG_Verification(DigiSign_Verification): def __init__(self, pgp_site = 'pgp.mit.edu', key = 0x...) Change above where it says "pgp.mit.edu" to something working. For me, changing it to "ha.pool.sks-keyservers.net" worked. def __init__(self, pgp_site = 'ha.pool.sks-keyservers.net', key = 0x...) ... $ hp-plugin -i ... Done.

CUPS and HTTP Interface:

I tried many ways to install my printer from hp-setup with GUI and command line options but they all failed at the end, saying something like "No device found that support this feature." or "No installed printers found (or) Invalid printer device selected".

I stumbled again...

Then, I remembered that CUPS has HTTP Interface where you can add and manage printers. I was a bit skeptical about this but tried anyway.

  1. Start CUPS daemon and make it persistent after each reboot:# rc-service cupsd start # rc-update add cupsd default
  2. Go to http://localhost:631/ in a browser
  3. Go to "Administration" and click on "Add Printer"
  4. Choose "HP LaserJet 200 colorMFP M276nw (HP LaserJet 200 colorMFP M276nw)" and continue
  5. Make sure the connection is set to socket://[ip_address]|HP LaserJet 200 colorMFP M276nw and continue again
  6. Choose the correct model and also click on "Choose File" for PPD File
  7. Select the PPD file copied to /etc/cups/ppd/ and click on "Add printer"
  8. Click on "Set Default Options"
  9. Choose "Print Test Page" option from the "Maintenance" menu

If everything goes well, it starts printing a test page. If it fails for some reasons, I'd delete the printer at the step 4 and choose something else and repeat until it works.

That's all!
-gibb