There are many howtos on the net on setting up printers and spoolers and stuff. The main problem about them is that the vast majority of people seems to be using c*ps, and nobody seems to care about how to do things right. Before I present a walktrough, let me explain shortly, what that the "right thing" might be.
Doing things right may be achieved using magicfilter. magicfilter reads some first bytes (the 'magic') of printing data, then determines the way to process it, before it is sent to the printer. As a use case consider printing a pdf file, when your printer only understands postscript. But magicfilter alone, with the common filtering rules, does not care about printer specific options too well. Often manufacurers ship a 'printer description' file (ppd). This is where foomatic-rip comes in. This program takes a postscript file and a ppd together with some job-specific options and outputs something -- not necessarily postscript -- the printer understands. foomatic-rip does poor to none, probably undocumented, magic filtering. So what we want to do is as simple as putting the pieces together.
First of all install lprng, magicfilter and foomatic-rip: apt-get install magicfilter lprng foomatic-filters. Get a description file for your printer. A possible resource is http://www.linuxprinting.org, check out the manufacturers homepage as well. Put this file into /etc/manufacturer_model_something.ppd. The ppd file contains your printing default. so for example change a line line *DefaultDuplex: None to *DefaultDuplex: DuplexNoTumble, if it seems to make sense to you. Next choose a magicfilter filter as template. For example cp /etc/magicfilter/ps600-filter /etc/magicfilter/manufacturer_model-filter. In this file, replace the lines that read
# PostScript 0 %! text 0 \004%! textwith something like
# PostScript 0 %! filter /usr/bin/foomatic-rip --lprng -v --ppd /etc/manufacturer_model_something.ppd -Z$ZOPT 0 \004%! filter /usr/bin/foomatic-rip --lprng -v --ppd /etc/manufacturer_model_something.ppd -Z$ZOPT(broken(?) versions of foomatic-rip (like once shipped with squeeze(?)) require (something like)
# PostScript 0 %! filter /usr/bin/foomatic-rip --lprng -v -Z$OPT, /etc/manufacturer_model_something.ppd 0 \004%! filter /usr/bin/foomatic-rip --lprng -v -Z$OPT, /etc/manufacturer_model_something.ppdfor some reason). Configure lprng to use this filter by setting
:if=/etc/magicfilter/manufacturer_model-filter:in the corresponding stanza of/etc/printcap. Your printcap may look like this:
lp|printer1|Dell:\ :sd=/var/spool/lpd/printer1:rm=printer1:rp=printer1:lpr_bounce:\ :sh:pw#80:pl#72:px#1440:mx#0:\ :if=/etc/magicfilter/dell5100-filter:\ :af=/var/log/lp-acct:lf=/var/log/lp-errs:Dont forget to chmod 644 /etc/manufacturer_model_something.ppd and chmod 755 /etc/magicfilter/manufacturer_model-filter if necessary. Restart lprng /etc/init.d/lprng restart.
That's it. Now you should be able to print arbitrary files and pass options to foomatic-rip unsing -Z. Depending on the ppd, for example lpr -ZDuplex=DuplexNoTumble path/to/some_paper.pdf prints out as expected.
Notice: At least in lenny there's a rather annoying bug in libgtk2.0-0, which disallows printing from applications like iceweasel, sylpheed etc. depending on wheter you have a clean install or upgraded. Just in case: Adding the line gtk-print-backends = "file,lpr" to /etc/gtk-2.0/gtkrc works around this.