User Tools

Site Tools



LPD and the OpenPrinting Database

We support LPD, LPRng, GNUlpr, and similar spoolers through the PPD-O-Matic PPD file generator and companion foomatic-filters backend filter package. What follows is quick-start information on setting up your printer with this pair, followed by some details on how it all works.

Note that LPD is ancient, and the foomatic-rip system for it has some quirks. But it does cover all the basics: option specification, network and local printing, easy use of most drivers, etc. You will observe that this 'quick' start has many more steps as either CUPS or PDQ…

Quick Start

This system will work with any LPD that can pass either a job title (lpr option -J via filter option -j) or arbitrary options (lpr option -o, via filter environment variable LPOPTS or LPRng's lpr option -Z, via filter option -Z) to a filter. This appears to cover most GNU/Linux LPD versions, and probably includes LPD versions on the BSD side as well. It also works well with LPRng.

The best way to find out is perhaps just to give it a shot.

The foomatic-rip system does not only allow printing of PostScript files, but also printing of plain text, PDF, images, TeX/LaTeX, DVI, and perhaps other file formats. For plain text you must have one of the converters “a2ps”, “enscript”, or “mpage” installed on your machine, for the other formats both “a2ps” (to detect the format) and ImageMagick (for images), GhostScript 6.51 or newer (for PDF) and/or TeX and LaTeX (for TeX, LaTeX, and DVI) must be installed. Most distributions provide these programs, but not necessarily all of them are installed by default. foomatic-rip will auto-detect the installed converters and automatically choose the best one. Converter packages as APS Filter or Magic Filters are usually not needed (and not supported by the current version of Foomatic).

If you have a Postscript printer, you can make use of the PPD file provided by the printer's manufacturer. You can use also these PPDs with foomatic-rip, simply use them instead of the PPD-O-Matic PPD from this site. See the "Postscript" driver page and the instructions on how to use PPD files for more information.

More detailed instructions with examples and screenshots you will find in the tutorial chapter “Foomatic from the User's Point of View: Installing a Printer” (PDF). Note that the instructions in the tutorial are for the former Foomatic 2.0.x.

1.If your printer is not a native PostScript printer, you will need the driver that you wish to use installed (foomatic-rip and the PPD file only provide a way to connect LPD to your driver). There are several styles of driver; the ones suitable for your printer will be referenced from your printer's page in the database:
* Ghostscript built-in
* Ghostscript is present on most free and many commercial Unix systems. It is not part of Mac OS X as shipped by Apple. Ghostscript contains many “compiled-in” drivers.
You can see the available Ghostscript drivers on your system by running 'gs -h'. If the driver you need is not listed, you need to obtain a new Ghostscript package which includes this driver, or compile Ghostscript yourself. GPL GhostScript includes all known free software built-in drivers and Linux distributions ship it with all drivers actually compiled. Currently such drivers are not developed any more by third parties, as adding these drivers is awkward and there are plenty of interfaces for modular drivers: CUPS Raster, IJS, OpenPrinting Vector, filters, ….
* CUPS Raster
* CUPS has a native driver style called “CUPS Raster”. These are executable programs, installed into CUPS' filter directory, which CUPS drives using a set of filters and Ghostscript. Such drivers are relatively easy to get going with CUPS, so are usually the best choice for CUPS users. With foomatic-rip one can use them also with other printing systems, though. You can see which CUPS Raster drivers are installed by examining the filters in /usr/lib/cups/filter; usually CUPS Raster drivers have names beginning with “rasterto”. Each CUPS Raster driver program will also have one or more PPD files in /usr/share/ppd or /usr/share/cups/model, each containing a reference to the proper CUPS Raster program.
* IJS is a plug-in interface to connect raster driver modules with Ghostscript (or a renderer in general) based on pipes. It was introduced for HP's HPIJS driver but currently it also used by several other drivers. The driver executables are usually installed into the standard search path for programs (/usr/bin or /usr/local/bin).
* OpenPrinting Vector
* This driver concept is developed by the Japanese members of the OpenPrinting project. It is a plugin interface for Ghostscript and other renderers which supports high-level (vector) graphics. This way modular drivers for printers with proprietary high-level page description languages can be created. Such printers are common on the Japanese market.
* Filter
* Some drivers are simply a filter into which generic bitmap output of Ghostscript is piped. This was one of the first solutions to make printer drivers without compiling them into Ghostscript. The filter executables are usually installed into the standard search path for programs (/usr/bin or /usr/local/bin).
* Uniprint
* A few drivers are Uniprint drivers. These consist simply of a upp file containing various parameters; most are included with Ghostscript. Others you will need to obtain and place in your ghostscript library directory (one of the directories listed under “Search path:” at the end of the “gs -h” output).
2.You will need a PPD file for your printer/driver, in case of a PostScript printer the one which came with the printer, for other printers running with a free software printer driver you should get one from the OpenPrinting database. To do this, you need to look up your printer's page in the database. When you want to use the driver which is recommended for your printer, click on the “download PPD” link in the summary box at the top of the page. For other drivers and some info about the drivers, go to the driver list at the bottom of the page. If a driver has no “download PPD” link, there is no info to generate a PPD in this driver entry, see the text of the driver entry, sometimes these drivers are covered by the PPD of another driver or the PPDs come with the driver.
3.Save the PPD file somewhere reasonable (perhaps in the spool directory you intend to use, or perhaps in /usr/local/lib/). Make sure the PPD file is world-readable with 'chmod a+r filename'.
4.Install the foomatic-filters package.

(If you are using a PostScript printer with a PPD from your printer vendor, you probably do not need Foomatic and should skip this step). Usually, your Linux distribution ships the foomatic-filters package (you have /usr/bin/foomatic-rip then). If not, get the foomatic-filters package from here. You need a C compiler and the Ghostscript shared library to build it. See the USAGE file in the foomatic-filters package for more information.
5.If you do not have a text(and other files)-to-PostScript converter installed (see above), install one. This is used to print option documentation for your printer or non-PostScript files, so it's nice to have it right. If you have more than one converter installed and the one automatically chosen by foomatic-rip is not the desired one, edit the “textfilter:” line in the /etc/foomatic/filter.conf file inserting the name of one of the supported converters (“a2ps”, “enscript”, “mpage”) after the colon. Do not forget to remove the “#” in the beginning of the line.
6.Configure a print queue in /etc/printcap with your favorite text editor. It will look like this; change the names to fit your setup:
For regular LPD, or VA's GNUlpr:
queue1|The printer in room 403:\\\     :lp=/dev/lp0:\\\     :af=/path/to/ppd/file:\\\     :if=/path/to/foomatic-rip:\\\     :sd=/path/to/spool/directory:\\\     :mx#0:sh:

For LPRng:

queue1|The printer in room 403:\\\     :lp=/dev/lp0: \\\     :force_localhost: \\\     :if=/path/to/foomatic-rip: \\\     :ppd=/path/to/ppdfile.ppd: \\\     :sd=/path/to/spool/directory: \\\     :mx#0:sh:

7.The spool directory will typically be a directory located under /var/spool/lpd and named for the queue. You must create this directory; do mkdir /var/spool/lpd/queue1 (change queue1 to be your printer queue's name, of course).
8.If your printer is remote, you can use foomatic-rip's internal mechanism for Windows, Netware, AppSocket, and LPD protocols. To do this, specify /dev/null for the lp= device name and edit the PPD file inserting a line
*FoomaticRIPPostPipe: "| <command>"

preferrably right after '*PPD-Adobe: “4.3”'. You can put the line nearly everywhere into the PPD file, but note that when you have two or more, only the last one is valid. '<command>' is a command into which you want to re-direct the output data of foomatic-rip. Due to the restrictions of PPD files '<', '>', and '“' are not allowed in the '<command>', replace them as follows (as in HTML or XML):

Character   Replacement\\ -----------------------\\     <       &lt;\\     >       &gt;\\     "       &quot;\\     '       &apos;\\     &       &amp;

For a TCP/Socket/JetDirect printer with the host name “printer” listening on port 9100 you need this:

*FoomaticRIPPostPipe: "| /usr/bin/nc -w 1 printer 9100"

Note the ”-w 1“ in the “nc” command line, it makes “nc” exiting immediately after the data is tranferred to the printer.

*FoomaticRIPPostPipe: "| rlpr -Plp@printserver"

directs your jobs to the LPD printer queue “lp” on the machine named “printserver”. Be sure that the tools you are using, as rlpr, nprint (printer on Novell server), smbprint (printer on Windows server), nc/netcat (TCP/Socket printer), or whatever you use are installed.

9.Save the printcap file and restart lpd with '/etc/init.d/lpd stop' and '/etc/init.d/lpd start', or just run 'lpc reload all'. (For many systems, the init.d script will be /etc/rc.d/init.d/lpd instead).
10.You should now be up and running. You can print documentation for your printer's options with:
For stock LPD:
lpr -Pqueue1 -Jdocs /proc/cpuinfo

For VA's GNUlpr:

lpr -Pqueue1 -o docs /proc/cpuinfo

For LPRng:

lpr -Pqueue1 -Z docs /proc/cpuinfo

The documentation will include an example of how to specify options (which, of course, you just figured out by trial and error!). Instead of /proc/cpuinfo you can specify any (preferrably short) file except /dev/null, it must be given to prevent lpr from waiting for data on standard input. foomatic-rip ignores the file and prints the documentation page instead.

13.To get your printouts well-centered and to be able to make use of the full imageable area (the area of the page where the printer can print, most printers cannot print up to the borders of the paper) of your printer, you should adjust the printout. With a driver made especially for your printer this is usually not necessary, but some printers, as for example PCL laser printers from other manufacturers than HP since need this adjustment since the GhostScript PCL drivers are mainly tested on HP printers.
Download the alignment page '''' (when you click on the link, the page will be displayed, please choose “File”
“Save As…” in your browser's menues to write the file to your disk) and print it. Follow the instructions on the page to do the adjustment.
14.If you want to print out of PPD-aware applications as Star Office, Open Office, GIMP, … or from a client (Windows, MacOS), use the same PPD file as you already have used for setting up your printer queue and follow the appropriate instructions.

Printing with LPD, LPRng, or GNUlpr

To actually use this now that you've set it up, you use the lpr command; given our example setup above,

$ lpr -Pqueue1 \
      -J'duplex pagesize=legal resolution=150 pjlresolution=150' \

would, assuming a LaserJet 4 or similar printer, print the file on legal paper using the duplexer at 150 dpi. Your printer will probably have different options; see your docs sheet. For systems with VA's GNUlpr, you would specify the above as

$ lpr -Pqueue1 -o duplex -o pagesize=legal -o resolution=150 \
               -o pjlresolution=150

And under LPRng, you'd use:

$ lpr -Pqueue1 -Z duplex -Z pagesize=legal -Z resolution=150 \
               -Z pjlresolution=150


$ lpr -Pqueue1 -Z duplex,pagesize=legal,resolution=150,pjlresolution=150 \

Options can also be supplied only to selected pages. To make an option setting acting only on certain pages one only needs to preceed the option by a page specification separated by a colon:

$ lpr -P foo1 -J'1:InputSlot=Letterhead InputSlot=Standard' file
$ lpr -P foo1 -J'even:Watermark=on odd:ColorMode=Gray' file
$ lpr -P foo1 -J'1,6-10,15,20-:MediaType=YellowPaper' file

$ lpr -P foo1 -o 1:InputSlot=Letterhead -o InputSlot=Standard file
$ lpr -P foo1 -o even:Watermark=on -o odd:ColorMode=Gray file
$ lpr -P foo1 -o 1,6-10,15,20-:MediaType=YellowPaper file

$ lp  -d foo1 -o 1:InputSlot=Letterhead -o InputSlot=Standard file
$ lp  -d foo1 -o even:Watermark=on -o odd:ColorMode=Gray file
$ lp  -d foo1 -o 1,6-10,15,20-:MediaType=YellowPaper file

$ lpr -P foo1 -Z 1:InputSlot=Letterhead -Z InputSlot=Standard file
$ lpr -P foo1 -Z even:Watermark=on -Z odd:ColorMode=Gray file
$ lpr -P foo1 -Z 1,6-10,15,20-:MediaType=YellowPaper file

The syntax is ”even“, ”odd“, or giving comma-separated page numbers or page ranges. Option settings with page selection override option settings for the whole document on the appropriate pages. More specific (less pages selected) settings override less specific settings on the appropriate pages.

The first lines in the examples print the first page on letter head paper and the rest on standard paper. The second lines print the even-numbered pages with watermark and the odd-numbered pages in grayscale. The third lines print the first, the 6th to the 10th, the 15th, the 20th, and all later pages on yellow paper, the rest on standard paper.

Page-specific option settings cannot be set as default in the PPD files.

With some printer/driver combos it is also possible to use arbitrary, custom page sizes (as long as they fit into the printer). Then you have a “Custom” setting for the “PageSize” option which you can use as follows:

$ lpr -P foo1 -JPageSize=Custom.20x30cm
$ lpr -P foo1 -o PageSize=Custom.20x30cm
$ lp  -d foo1 -o PageSize=Custom.20x30cm
$ lpr -P foo1 -Z PageSize=Custom.20x30cm

You give always at first the width, then the height and in the end one of the units ”pt“ (PostScript points, 1/72 inch), ”in“ (inches), ”cm“ (centimeters), or ”mm“ (millimeters). If you leave out the unit, ”pt“ will be used as default. The numbers do not need to be integers, something like ”4.3×5.5in“ is allowed.

You can also use the graphical printing interface GPR to print with LPRng, GNUlpr, or stock LPD. See the PPD-O-Matic instructions for how to set it up.

With most drivers, you can also use the media=…, sides=…, and duplex standard CUPS/IPP options as documented in the user manual. Named paper types, trays, and sizes known to your printer driver will be picked out of a media= specifier just fine.

If it doesn't work, turn on the debug flag in /etc/foomatic/filter.conf and examine the debugging output in the file /tmp/foomatic-rip.log. Do not forget to remove the ”#“ in the beginning of the line. And feel free to contact us for help.

How does it work?

There are three parts to the Foomatic scheme:

  • The Database
  • The database contains a number of XML files which detail exactly how to execute a given printer driver. There are two front-ends which use these files: the human-readable one generates the information shown on all “Execution Details” pages, the PPD-O-Matic PPD generator computes an Adobe-compliant PPD file which you need to configure your print queue and PPD-aware applications/clients.
  • The PPD File
  • The PPD file generated by the database contains all inforation about important printer capabilities, available options and how to build the renderer's (usually Ghostscript's) command line depending on the user's choices for the options. foomatic-rip reads it to know how to execute the print job. GUI frontends read it to build dialog boxes in which the user can adjust the options. Besides the usual stuff the PPD file contains various extra lines beginning with “*Foomatic…”. These contain details of the driver command line, the information whether an option accepts arbitrary numbers and not only the choices listed in the PPD file, and more. frontends and application programs ignore these extra lines.
  • The Backend Filter
  • The if= filter 'foomatic-rip' is called by LPD with various inputs, including an accounting file name (used instead to hold the PPD filename), and a job name (used instead to hold job options) or a set of options in the environment variable LPOPTS. foomatic-rip opens the PPD file, extracts the encapsulated execution data found there, and combines it with the user-provided option values to this to compute the proper command to execute for filtering. It parses the PostScript input for option settings which were stuffed in by frontends or by application programs and it also stuffs in PostScript code by itself, if needed. It also massages a set of standardized option types lifted from CUPS into the more generic printer/driver-specific format used by the database.

We added a bunch of special code to pick out the media= and sides= options. These now map sensibly to the PageSize, MediaType, and InputSlot enumerated selections, plus the boolean Duplex argument, if present. It's all a bit ugly if a driver supports an option that happens to be named the same as an existing standard ipp/cups option.

You can't really do accounting when using foomatic-rip with LPD or GNUlpr; the af= accounting filename is used for something else. With LPRng this problem does not occur.

The option passing is really awkward without the VA Linux hacked GNUlpr. You can obtain this version of LPD from SourceForge. There are rpms and tarballs there. But note that the development of this project has stopped.

Maintainership of LPRng was overtaken by new developers. See the new LPRng project page.

openprinting/database/lpddocumentation.txt · Last modified: 2016/07/19 01:20 (external edit)