(II.) Foomatic from the User's Point of View:
Installing a Printer

Presented by Till Kamppeter, maintainer of linuxprinting.org, leader of the Foomatic project, author of XPP, and responsible for the printing part of Mandrake Linux

What we will demonstrate: We will install an additional printer on our CUPS server. We let the audience choose one, look it up on Linuxprinting.org, download its PPD file, "cupsomatic" etc. We also show how to set up an HP OfficeJet printer for printing, scanning, and photo card access. In the end we take the card of a digital camera of someone in the audience, read a photo into on of our machines, and print it.

Installing a printer with the help of Foomatic

One big problem in setting up a printer is to make the spooler calling the correct filters and to give the user the possibility to control the capabilities of the printer. Most GNU/Linux distributions use their own tools which often do not support the latest printer models and also only give access to very basic driver options.

To improve this situation, Grant Taylor, the author of the Printing-HOWTO has set up a database for information about free software printer drivers as well as for printers and how they are supported with free software. This database, called Foomatic is located on linuxprinting.org and I am currently maintaining it. Now the database lists all free software printer drivers with their command lines and all available options and also all printers for which we could gain information about how well they are supported. The database is implemented in XML and there are Perl scripts which automatically create configuration files and even complete printer queues for all known free spoolers: LPD, LPRng, GNUlpr, CUPS, PPR, PDQ, and spooler-less printing. With these queues the user will have access to the full functionality of the used printer driver and he gets a spooler-independent user interface so that he can operate all spoolers the same way.

To make use of Foomatic you have two possibilities:

In the following it will be shown step-by-step how to set up a printer with both methods.

Configuring a printer using the linuxprinting.org web site

1. Looking up the printer on linuxprinting.org

Choose Printer Listings in the menu on the left hand side of the home page (http://www.linuxprinting.org/) and then you will get the possibility to choose your printer model to go directly to its database entry or to choose a printer manufacturer from which you want to see an overview page (Fig. 1).

Tip: When you don't find the exact name of your printer model but there is a name which defers only by some trailing letters (you have the HP DeskJet 990Cxi and listed is the HP DeskJet 990C) then take this entry, in most cases the hardware is the same but only the Windows toys coming with the printer differ. Only be careful when buying a printer with an "L" in the end of its name, this often means "Light" and then the printer has reduced capabilities, especially often the PCL emulation is left out and so it will not work with free software.

[ Overview of HP printers on linuxprinting.org ]

Fig. 1: Overview page for HP's printers, sorted by the support quality. It also contains the menus to choose a printer model or another manufacturer

When you are on the database entry page of your printer (Fig. 2) read the text there and check how well your printer works with free software. The support quality is rated from "Perfectly" (the printer works to its full extent) to "Paperweight" (the printer does not work at all). If your printer is rated as "Paperweight" you don't need to go on with the next steps (but linuxprinting.org will help you when you are buying another printer).

[ Database entry page for the HP DeskJet 990C ]

Fig. 2: The database entry page for the "Perfectly" working HP DeskJet 990C

Choosing a driver for your printer

Every non-"Paperweight" printer entry has a list of drivers which support this printer (Fig. 3). There is also one "recommended" driver from which we expect that it gives the best output quality. So usually it is the best to use this recommended driver. Read the comments of the drivers and click on the links to get to the drivers's database entry pages (Fig. 4). Use the "Back" button of your browser to get back to the printer's page.

[ Driver listing for HP DeskJet 990C ]

Fig. 3: The drivers which support the HP DeskJet 990C

[ Driver database entry for GIMP-Print with the IJS interface ]

Fig. 4: A driver database entry: "gimp-print-ijs"

Is your desired driver installed on your system?

Before you choose a driver, you must find out whether it is installed on your system. If the driver's "Type" is "GhostScript", the driver has to be built into GhostScript. To find out whether your GhostScript has it, enter

   gs -h

on the command line. You will get an output like this:

   GNU Ghostscript 6.53 (2002-02-05)
   Copyright (C) 2002 artofcode LLC, Benicia, CA.  All rights reserved.
   Usage: gs [switches] [file1.ps file2.ps ...]
   Most frequently used switches: (you can use # in place of =)
    -dNOPAUSE           no pause after page   | -q       `quiet', fewer messages
    -g<width>x<height>  page size in pixels   | -r<res>  pixels/inch resolution
    -sDEVICE=<devname>  select device         | -dBATCH  exit after last file
    -sOutputFile=<file> select output file: - for stdout, |command for pipe,
                                         embed %d or %ld for page #
   Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PDF
   Available devices:
      bmpmono bmpgray bmpsep1 bmpsep8 bmp16 bmp256 bmp16m bmp32b imagen iwhi
      iwlo iwlq lbp8 lips3 m8510 necp6 oki182 ln03 dl2100 okiibm oki4w ibmpro
      omni hpijs DJ630 DJ6xx DJ6xxP DJ8xx DJ9xx DJ9xxVIP AP21xx ap3250 appledmp
      epson epsonc eps9mid eps9high la50 la70 la75 la75plus escp hl7x0 hl1240
      hl1250 gdi deskjet djet500 laserjet ljetplus ljet2p ljet3 ljet3d ljet4
      ljet4d lj5mono lj5gray paintjet pjetxl cdeskjet cdjcolor cdjmono cdj550
      pj pjxl pjxl300 pcl3 hpdjplus hpdjportable hpdj310 hpdj320 hpdj340
      hpdj400 hpdj500 hpdj500c hpdj510 hpdj520 hpdj540 hpdj550c hpdj560c
      hpdj600 hpdj660c hpdj670c hpdj680c hpdj690c hpdj850c hpdj855c hpdj870c
      hpdj890c hpdj1120c uniprint ijs cp50 declj250 dnj650c lj4dith lj250 lq850
      lp8000 lp2563 oce9050 bj10e bj200 bjc600 bjc800 bjcmono bjcgray bjccmyk
      bjccolor cdj500 cdj670 cdj850 cdj890 cdj1600 cdj880 cdj970 jetp3852 st800
      xes stcolor stp alc8500 alc2000 epl5900 epl5800 epl2050 epl2050p epl2120
      md2k md5k lex5700 lex7000 lx5000 lxm3200 lxm5700m faxg3 faxg32d faxg4
      cfax r4081 sj48 t4693d2 t4693d4 t4693d8 tek4696 dfaxlow dfaxhigh sxlcrt
      pcxmono pcxgray pcx16 pcx256 pcx24b pcxcmyk pbm pbmraw pgm pgmraw pgnm
      pgnmraw pnm pnmraw ppm ppmraw pkm pkmraw pksm pksmraw tiffcrle tiffg3
      tiffg32d tiffg4 tifflzw tiffpack tiff12nc tiff24nc psmono psgray psrgb
      bit bitrgb bitcmyk pngmono pnggray png16 png256 png16m jpeg jpeggray
      pdfwrite bbox pswrite epswrite pxlmono pxlcolor chp2200 cljet5 cljet5c
      nullpage x11 x11alpha x11cmyk x11cmyk2 x11cmyk4 x11cmyk8 x11gray2
      x11gray4 x11mono
   Search path:
      . : /usr/share/ghostscript/6.53/lib : /usr/share/ghostscript/6.53 :
      /usr/share/fonts/default/ghostscript : /usr/share/fonts/default/Type1 :
   For more information, see /usr/share/doc/ghostscript-6.53/Use.htm.
   Report bugs to bug-gs@ghostscript.com, using the form in Bug-form.htm.

Check whether your desired driver is in the list of "Available devices". If so, your driver is available on your system, if not, you can either download the driver from the driver's home page (you find the line on the driver's database entry page) and compile GhostScript with it. Or, and this is the easier solution, you download and install ESP GhostScript 7.05.4 or newer which contains all "GhostScript" drivers listed on linuxprinting.org. Make sure that it has access to the GhostScript fonts, either by installing also the appropriate "ghostscript-fonts" package or by making it using the same font paths as your distribution's GhostScript. For that you use the "--with-fontpath" option when running the "./configure" command. The font paths of your current GhostScript you find in the end of the output of "gs -h", in the "Search path" section. In our example you have to compile ESP GhostScript with (please put the fontpath in 'configure' all in one line, with just a colon (":") separating the different items):

   ./configure --with-fontpath=/usr/share/fonts/default/ghostscript:i \
                               /usr/share/fonts/default/Type1:        \
                               /usr/share/ghostscript/fonts           \
   make install

If your driver is of the type "Filter" the driver is a separate executable which either converts bitmap output of GhostScript to the printer's input format (as the "pnm2ppa" driver for the HP PPA DeskJets) or is called by GhostScript as a plug-in (as HP's "hpijs" driver for their PCL inkjet and laser printers). To find out whether your desired driver is installed check whether there is an executable program with that name with the "which" command:

   $ which hpijs

If the driver is missing, download it from the driver's home page and install it. Such filters are usually easy to compile and install.

Getting the configuration file for your spooler

Now, where you have decided which driver you want to use, you need to download a configuration file for your printer/driver/spooler combo. Go to the "Printing system interfaces" section (Fig. 5) of the driver database entry page of your chosen driver. Now you find a drop-down menu box for every known printer spooler (CUPS, LPRng, LPD, GNUlpr, PPR, PDQ, and spooler-less printing). Choose your printer model in the menu for your spooler (CUPS is default for Mandrake and Conectiva, LPRng for SuSE and RedHat, sooner or later probably all will use CUPS as default) and click the appropriate "Generate ..." button. Now you see the configuration file. Wait until it is completely downloaded and then save it using "File"/"Save As ..." in your browser's menus. A suggestion for a file name you find in the comments in the beginning of the file. Do not cut and paste it with your mouse. Note that this file is not the driver, it is only a description about how the driver is used, readable by your spooler.

[ Configuration file selectors in the database entry for HPIJS ]

Fig. 5: Choosing a configuration file for the "hpijs" driver.

Setting up a printer queue

Now click the "Back" button of your browser to get back to driver's page. In the already mentioned "Printing system interfaces" section click on the "documentation" link for your spooler and proceed as described there.

Here we will take CUPS as example spooler to show how to set up the printer queue.

We assume that you have installed CUPS with packages of your distribution, if you have installed it from source, all CUPS-related directories begin with "/usr/local" instead of "/usr".

Assuming that you have an HP DeskJet 990C and want to use it with the "hpijs" driver you have now downloaded a PPD-O-Matic PPD file named HP-DeskJet_990C-hpijs-ppd.ppd. Log in as "root" and copy this file into the /usr/share/cups/model/ directory. Make sure that the file is world-readable:

   chmod a+r /usr/share/cups/model/HP-DeskJet_990C-hpijs-ppd.ppd

Now download the filter script cupsomatic from http://www.linuxprinting.org/cupsomatic. Copy it into the /usr/lib/cups/filter/ directory and make it world-readable and -executable:

   chmod a+rx /usr/lib/cups/filter/cupsomatic

Check the definitions and paths in the beginning of the cupsomatic script whether they fit to your system and adapt them if needed.

To work around some problems which GhostScript has with certain PostScript files (especially from Windows clients), download also the foomatic-gswrapper from http://www.linuxprinting.org/foomatic-gswrapper, put it into the /usr/local/bin/ directory and make it also world-readable and -executable:

   chmod a+rx /usr/local/bin/foomatic-gswrapper

If you want to be able to print a page listing all available printer and driver options for your printer/driver pair, you need one of the text-to-PostScript converters "a2ps", "enscript", or "mpage" installed on your system. cupsomatic will auto-detect them and choose one automatically.

Now make the CUPS daemon aware of your new PPD file by giving it a little kick so that it rebuilds its internal PPD database:

   killall -HUP cupsd

After a moment (when "lpstat -t" works again) you can set up a print queue, either on the command line

   lpadmin -p DJ990 -E -v usb:/dev/usb/lp0 -m HP-DeskJet_990C-hpijs-ppd.ppd -o PageSize=A4

(the "-o PageSize=A4" sets the correct default paper size for Europe) or via any graphical CUPS administration frontend, as the KDE Printing Manager or the web interface of CUPS, reachable via http://localhost:631/. Choose "DeskJet 990C, Foomatic + hpijs" as your printer model (Fig. 6).

[ Initial screen for adding a printer in the web interface of CUPS ]

Fig. 6: Choosing the printer model in the web interface of CUPS

Configuring options

To configure the printer's options one can either use a graphical interface, as the KDE Printing Manager or the web interface of CUPS or the command line.

The easier way are graphical tools. On the main page of the web interface one clicks on "Manage Printers" and in the printer list on and then on the "Configure Printer" button of the desired printer entry. When asked for login and password one logs in as "root" and gets the printer options screen as in Fig. 7. Here one adjusts the options and clicks on "Continue".

To adjust options on the command line one prints the printer's help page at first

   lpr -P DJ990 -o docs ~/.bashrc

The file name is only to make "lpr" not waiting for an input on the console. The file will not be printed when the "-o docs" option is given. A not so nice options listing one gets also with

   lpoptions -p DJ990 -l

Now one can set system- and network-wide defaults with

   lpadmin -p DJ990 -o Resolution=600ColorCMYK -o Duplex=DuplexNoTumble

local system-wide defaults with

   lpoptions -p DJ990 -o Resolution=600ColorCMYK -o Duplex=DuplexNoTumble

given as "root" and personal defaults with the same command given as normal user.

[ Screen to adjust the printer's options in the web interface ]

Fig. 7: Adjusting the printer's options

Configuring a printer using the Foomatic package

Alternatively, one can download the Foomatic package with the complete database and an easy-to-use command line interface to the local system. Then one can easily set up and maintain printer queues, print, and manage jobs with the same command line interface for all known spoolers.

Installing Foomatic

To do this you must have Perl and libxml2 installed on your system. These packages are part of every modern GNU/Linux distribution. Note that you have also to install the "perl-devel" and "libxml2-devel" packages to be able to compile Foomatic.

If all is installed the installation of Foomatic is the usual Unix-Triathlon:

   make install

Then you can start installing your printer queue.

Determining the printer database ID

The command line to configure the printer requires the printer database ID, which for older printer entries is a number. This comes from the old PostGreSQL database which was used on linuxprinting.org in the beginning. To determine the ID one enters

   foomatic-configure -O | less

and find in the output:

    <model>DeskJet 990C</model>

The printer ID is between the "<id>" tags, the model name between the "<model>" tags and the driver names between the "<driver>" tags. Then the command line to add the queue must be (with the default paper size set to A4):

   foomatic-configure -s cups -n DJ990 -c file:/dev/usb/lp0
                      -p 530418 -d hpijs -o PageSize=A4

This does all needed steps: It generates the PPD file, sets up the queue and also configures the printer options given on the command line. And for other spoolers the command line is exactly the same, only the spooler name has to be changed. So the hassle with editing configuration files and writing scripts for the LPDish spoolers has an end now.

One can even copy the Foomatic queues from ones old spooler to the new spooler:

   foomatic-configure -s cups -n LJ4050 -C lprng lp

This does not only copy the queue itself but also all its option settings. So you don't loose all the fine-tuning which you did on your printers.

For printing and job management there is the "foomatic-printjob" command:

   foomatic-printjob -s cups -P DJ990 -o PageSize=A4
                     -oResolution=1200PhotoCMYK file.ps
   foomatic-printjob -s cups -P DJ990 -Q
   foomatic-printjob -s cups -P DJ990 -R 25

For more information, see the USAGE file which comes with the Foomatic package.

Installing a multi-function device from HP

A very nice thing are multi-function devices: Not needing much more space than a usual printer they are printer, scanner, copier, fax machine, and sometimes also photo memory card reader and many of them do even all their work in color. The only problem is that the multi-function devices of most brands do not work under free software, or, if you are lucky, they only print.

The big exception is HP: They support David Paschal's HPOJ low-level driver project which gives access to all components of the devices. Currently you can print, scan, and access to photo memory cards of digital cameras, on all appropriately equipped devices. The development for fax support will be started soon.

HPOJ sets up an extra daemon to which the printer spooler sends its jobs and to which SANE connects for scanning and the "mtools" for photo memory card access. You can even print, scan, and transfer data between your PC and a photo card at the same time.

The instructions below are for HPOJ 0,9. Please check the documentation of you HPOJ version when you use an older one, you find the documentation usually in the /usr/share/doc/hpoj/ directory.

Installing HPOJ

Many distributions, as Mandrake, SUSE Linux, and Debian already contain HPOJ packages. In this case simply install these packages with the package installation tools of your distribution. If there are no packages for your distribution, you have to compile HPOJ as described in its documentation. Make sure that you have installed SANE, CUPS, and libsnmp before you start to compile.

Install also HPIJS, most devices work best with HPIJS as printer driver.

Basic setup of HPOJ

Configuring the daemons of HPOJ is easy thanks to an interactive text mode setup tool which auto-detects all locally connected multi-function devices and walks you step-by-step through the setup.

You invoke the tool with:

   ptal-init setup

At first you will get a list of already configured devices and the possibility to delete them. You have also to delete a device when you want to modify its configuration. Then you will be asked whether you want to have the parallel ports scanned and HPOJ auto-detects all connected parallel devices for you and asks you whether you want to use them with HPOJ. The same is done with USB devices. Network devices are not auto-detected. You have to supply their host names or IPs when you get asked for them in the end of the configuration procedure. After the configuration the daemons are automatically started and a list of the configured devices is shown. Do not close the terminal window, you will need the list.

Setting up a print queue

At first restart the CUPS daemon with

   killall -HUP cupsd

so that CUPS registers your multi-function device(s).

The setup of the print queue(s) works as shown earlier, only the backend/destination device has now the URI "ptal:/<HPOJ name of the device>". So to get a queue for an HP PSC 950 you enter:

   lpadmin -p PSC950 -E -v ptal:/mlc:usb:PSC_900_Series -m HP-PSC_950-hpijs-ppd.ppd

The HPOJ device name you find in the list shown at the end of the HPOJ configuration with "ptal-init setup". It is also shown whenever you restart HPOJ ("ptal-init restart"). The PPD file is downloaded from linuxprinting.org.

You find the device also in the backend device menus of the graphical CUPS interfaces, as shown with the web interface in Fig. 8.

[ Backend device entry for the HPOJ-driven HP PSC-950 ]

Fig. 8: Configuring a print queue for the HP PSC-950

Scanning with SANE

To set up scanning you only need to add a line containing only "hpoj" to the /etc/sane.d/dll.conf file, so that SANE knows to look for scanners using the "hpoj" SANE driver.

Then you can use all standard scanning tools as for example the graphical environment "xsane".

Photo memory card access with the MTools

To access photo cards one has to add the two lines

   drive p: file=":0" remote

to the /etc/mtools.conf file. Then the photo card is visible as DOS drive p:, One can see directories with

   mdir p:
   mdir p:/DCIM/100OLYMP/

transfer photos with

   mcopy p:/DCIM/100OLYMP/P6080001.JPG photos/linuxtag2002/

and do other things which are possible with the MTools. There is also the graphical frontend MToolsFM, downloadable on http://www.core-coutainville.org/MToolsFM/.