Configuring Xsane to work with a networked HP Printer

Issues related to hardware problems
Post Reply
Posts: 9
Joined: 2016/04/06 20:08:05

Configuring Xsane to work with a networked HP Printer

Post by DaveHighland » 2018/06/12 07:46:58

The Problem:
I have a new computer running Centos-7.5.1804, with an HP Officejet 4620 All-In-One (AIO) printer connected via WiFi to my home LAN. ("AIO" simply means the device is a printer, scanner, fax, and copier "all in one".) I am using Gnome-Classic for my desktop. While configuring the system, I was able to use the Applications/System Settings/Printers/Add dialog to add the HP 4620 as a printer, and that worked like a charm. However, nothing I tried would get Xsane (Applications/Graphics/Xsane) to find the HP 4620 as a scanner device. I even tried the hp-setup program, but it still failed to find the printer: neither as a "Network/Ethernet/Wireless" connection, nor as a "Wireless/802.11" device requiring a temporary USB connection during initial setup.

The Solution:
After scouring the web for ideas, I found a website ( published by Synology, a Taiwanese corporation that markets network-attached storage (NAS) appliances. Because of their NAS focus, some of the advice on that website isn't directly applicable to your average Centos 7 desktop, but the article gave me some valuable clues.

Here are the steps I took to get Xsane to work with a networked HP-4620 all-in-one printer. I haven't verified that this works with other HP AIO printers, but I suspect it will, so I'm passing along the info:

Step 1. In a terminal window, execute the following command to verify that the required packages are installed. This command does not require admin privileges. If any of these packages are not installed, use the "sudo yum install" command to install them:

yum list installed sane-backends libsane-hpaio dbus python hplip cups

Step 2. Use the following command to find the IP address(es) of your host computer. The output that this command produces on my system is shown below the command as an example.

hostname -I

Step 3. Make a backup of the /etc/sane.d/saned.conf text file. Then edit the original /etc/sane.d/saned.conf text file with admin privileges (for example using the terminal command "sudo gedit /etc/sane.d/saned.conf"). Add the lines shown below to the "Access list" section, but substitute the IP address(es) you discovered when you ran the command in Step 2, and modify the comment as appropriate. Adding a host IP address to the access list section of the saned.conf file gives the corresponding host computer the required permission to access a sane device.

# Added the following two lines 2018-06-08:

Step 4. Make a backup of the /etc/sane.d/dll.conf text file. Then edit the original /etc/sane.d/dll.conf text file with admin privileges. At or near the top of the file, locate the "net" line. If this line is commented out (as in "#net"), then delete the hash mark. The "net" line needs to be enabled in order to allow a scanner to be accessed through the network rather than through a USB or SCSI connection. Then, immediately following the "net" line, add the following lines, modifying the comment as appropriate. The "hpaio" line enables the hpaio sane backend. Although another backend that is listed in this file may be a close match to your printer (e.g., "hp4200"), that backend is usually not sufficient to allow sane to access the scanner in your HP All-In-One printer.

# Added the following line 2018-06-08:

Step 5. Restart your computer to allow the above changes to take effect.

Step 6. Verify that your HP printer is connected to your WiFi network, then navigate through the menus on the printer's front panel to determine the IP address that has been assigned to your printer. Write it down. In the example commands that follow, I will show my HP 4620 IP address, which is

Step 7. Execute the following command to determine the Uniform Resource Identifier (URI) of your HP printer, substituting your own printer's IP address. A URI is a way to unambiguously name a resource, in this case your printer. If the following command succeeds, then you will have a resource name that allows Xsane to access your printer.


On my system, the above command produces the following output:

CUPS URI: hp:/net/Officejet_4620_series?ip=
SANE URI: hpaio:/net/Officejet_4620_series?ip=
HP Fax URI: hpfax:/net/Officejet_4620_series?ip=

We are only interested in the second line, the one that begins "SANE URI: ". Write down the URI appearing on the rest of that line.

Step 8. In a terminal window, execute the following command to launch Xsane, substituting the URI that you wrote down in Step 7.

xsane hpaio:/net/Officejet_4620_series?ip=

If everything worked as it did on my system, Xsane should launch and find your printer, and you should be able to scan documents from both the flat-bed and the automatic document feeder.

One quirk: On my system, when Xsane launches, the window title says, "...unknown Officejet...". I don't know why, because the URI unambiguously identifies my HP printer. I'm just happy that it all worked.

If you want to launch Xsane from the Gnome Classic Applications menu, you'll have to modify the properties of the Xsane menu item using "Applications/Sundry/Main Menu". Another quirk: The menu editor won't allow spaces in the "Command" text box. I got around this by using a bash script. I created a text file with the following two lines (substitute your own URI, of course):

xsane hpaio:/net/Officejet_4620_series?ip=

I saved the file in a directory and gave it a name ending in ".sh", and I changed the file permissions to allow it to be executed. Then I typed the full path and name of this file in the "Command" text box of the menu item properties dialog. NOTE: It is critical that the full path and file name contain no spaces; otherwise the menu editor won't allow you to save the altered menu item.

I hope this post helps at least one other person get Xsane running with their HP printer. Good Luck!

Post Reply