Setting up scanning

This file documents the procedure to set up scanning with the HP OfficeJet Linux driver (hpoj) package.

First check your model

Important: There are currently two different scanning solutions available, but only one of them will work, depending on what HP all-in-one model you have. In general: See the Supported devices page for the most up-to-date list of models and which of the above methods (if any) may be used for scanning.

Note: Some models have "Scan" or "Scan To" buttons on their front panel to initiate scans from the device, possibly to a choice of destinations. This functionality is not currently supported. For now, you must initiate all scans from the computer using the appropriate software, either SANE (described below) or "ptal-hp scan".

Setting up scanning with SANE

SANE version 1.0.4 and later do not need to be patched for OfficeJet support, because the necessary changes have been incorporated into the SANE codebase starting with 1.0.4.

Important: If you already have SANE installed (particularly if from an RPM, as is the case with RedHat, Linux-Mandrake and probably other distributions as well), then you should uninstall it and follow the procedure below, since it probably was not compiled for OfficeJet support.

    Preparation:

  1. Follow the instructions to compile and install the hpoj software and set up basic device connectivity if you haven't already.

  2. Download from ftp://ftp.mostang.com/pub/sane/ the sane-backends-x.y.z.tar.gz and sane-frontends-x.y.z.tar.gz packages.
    It is recommended that you download the latest version available. Substitute the version you selected for x.y.z in the rest of this document.

    (Optional) Download the enhanced xsane frontend from the same place.

    (Optional) As an alternative to downloading released SANE packages, you may access the latest development code from the SANE CVS repository. See http://www.student.uit.no/~pere/linux/sane/cvs-server.html for more information. The "cvs checkout" command produces a top-level sane directory with sane-backends and sane-frontends subdirectories. When using "cvs update" with SANE CVS, you may need to append the -d switch to pick up new subdirectories that may have been added.

  3. Unpack the SANE source code packages.
    If necessary, cd into the directory containing sane-*-x.y.z.tar.gz.
    Issue the following two commands:
    	tar xvfz sane-backends-x.y.z.tar.gz
    	tar xvfz sane-frontends-x.y.z.tar.gz
    

    sane-backends:

  4. cd into the sane-backends-x.y.z directory.
    Read the README file.

  5. Run the ./configure script. If necessary, use the following parameters: If you re-run the configure script, then you might need to delete the config.cache file if the cache contains stale information.

  6. Examine the sane-backends ./configure output and check for the following lines:
    	checking for ptal.h... yes
    	checking for ptalInit in -lptal... yes
    
    If neither line appears, then verify you're using the most recent version of SANE.
    If either line says no, then verify you've properly compiled and installed the hpoj software, and try re-running the SANE ./configure script with the --with-ptal=DIR switch (see above).

  7. (Optional) If you'd like to speed up the compilation and installation of SANE, then edit the file backend/Makefile. Around line 55, change the definition of PRELOADABLE_BACKENDS (which continues over several lines using the backslash character) to just:
    	PRELOADABLE_BACKENDS = hp net
    
    plus any other backends you will need. If you choose to do this, then you will also need to edit tools/Makefile to remove umax_pp from the line where DESTINATIONS is defined to prevent a compilation error.

  8. Compile sane-backends.
    Issue the command make. Ensure it completed successfully.

  9. Install sane-backends.
    Log in as root if necessary, and issue the command "make install".

    sane-frontends:

  10. cd into the sane-frontends-x.y.z directory. Read the README and INSTALL files.

  11. Run the ./configure script.

  12. Compile sane-frontends. Issue the command make. Ensure it completed successfully.

  13. Install sane-frontends. Log in as root if necessary, and issue the command "make install".

    Configure hp backend:

  14. Read the sane-hp manual page.
    By default this is installed as /usr/local/man/man5/sane-hp.5. An online version is also available.

  15. Edit /usr/local/etc/sane.d/dll.conf.
    You may comment out all lines except hp and any other backends you specifically wish to keep, such as net.

  16. Edit /usr/local/etc/sane.d/hp.conf according to the sane-hp manual page:

    For the case of an OfficeJet connected to a parallel port, add something like the following two lines, depending on how you named the device when you started ptal-mlcd:

    	mlc:par:0
    	option connect-ptal
    
    If you're using USB, then add something like the following two lines, again taking into account how you named the device for ptal-mlcd:
    	mlc:usb:OfficeJet_G85
    	option connect-ptal
    
    If your peripheral is connected to an HP JetDirect print server, then add something like the following two lines:
    	hpjd:my-jdex.my-domain.com
    	option connect-ptal
    
    Note: The sane-hp manual page prior to SANE version 1.0.5 refers to the old PTAL device naming convention for hpoj-0.7 and earlier, which was of the form mlc:mlcpp0. Follow the instructions above instead.

    Try it out:

  17. Ensure the device is connected and powered on and that the hpoj low-level drivers are loaded appropriately.

  18. Perform a "test" scan.
    If you have a single HP device, issue the command
    	scanimage --test
    
    If you have multiple HP devices, try them all. To specify a particular device, such as mlc:par:0, use a command such as:
    	scanimage -d hp:mlc:par:0 --test
    
    Note: Scrollfed models, such as the OfficeJet K and V series, may or may not handle this test properly, but it doesn't hurt to try.

  19. Run xscanimage or xsane and scan to your heart's content! :-)

    Important: Scrollfed models, such as the OfficeJet K and V series, require extra steps to scan or preview-scan successfully, which are explained in the sane-hp manual page. Note that you may have to configure the frontend application to show "advanced options" in order to get to the "Change document" and "Unload" buttons.

  20. (Optional) If you'd like to set up xscanimage or xsane to run as a Gimp plugin, then invoke something like one of the following commands, adjusting as necessary for the directory in which the application is installed and the version of Gimp you're using:
    	ln -s /usr/local/bin/xscanimage ~/.gimp/plug-ins
    	ln -s /usr/local/bin/xsane ~/.gimp-1.2/plug-ins
    
    See http://www.xsane.org/doc/sane-xsane-gimp-doc.html for more information.
If you have problems, in some cases it may be helpful to enable debug output, which is fully enabled with the following commands:
	export SANE_DEBUG_HP=128
	export PTAL_DEBUG=2
The debug output is sent to standard error. To capture this to a file named log.txt, add 2>log.txt to the command line. Put it before the ampersand if running xscanimage or xsane in the background.

Next steps

You may now set up printing if you haven't already, or return to the index.