<HTML ><HEAD ><TITLE >How it all works</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.49"><LINK REL="HOME" TITLE="The Printing HOWTO" HREF="index.html"><LINK REL="PREVIOUS" TITLE="Spooling software" HREF="spoolers.html"><LINK REL="NEXT" TITLE="How to set things up" HREF="setup.html"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >The Printing HOWTO</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="spoolers.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="setup.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="BACKGROUND" >7. How it all works</A ></H1 ><A NAME="AEN1586" ></A ><P > In order to get printing working well, you need to understand how your spooling software works. All systems work in essentially the same way, although the exact order might vary a bit, and some systems skip a step or two: <DIV CLASS="FIGURE" ><A NAME="SPOOL-ILLUSTRATION" ></A ><P ><B >Figure 10. Spooling Illustration</B ></P ><P ><IMG SRC="spool-illustration.gif"></P ></DIV > <P ></P ><OL TYPE="1" ><LI ><P >The user submits a job along with his selection of options. The job data is usually, but not always, Postscript. </P ></LI ><LI ><P >The spooling system copies the job and the options over the network in the general direction of the printer. </P ></LI ><LI ><P >The spooling system waits for the printer to be available. </P ></LI ><A NAME="AEN1600" ></A ><LI ><A NAME="BACKGROUND-FILTERING" ></A ><P >The spooling system applies the user's selected options to the job, and translates the job data into the printer's native language, which is usually not Postscript. This step is called <I CLASS="EMPHASIS" >filtering</I >; most of the work in setting things up lies in getting the proper filtering to happen. </P ></LI ><LI ><P >The job is done. The spooling system will usually do assorted cleanup things at this point. If there was an error along the way, the spooler will usually notify the user somehow (for example, by email). </P ></LI ></OL > </P ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="PDQ-OVERVIEW" >7.1. PDQ</A ></H2 ><A NAME="AEN1608" ></A ><P > Pdq stands for "Print, Don't Queue", and the way it works reflects this design. The following sequence of events happens when you use PDQ to print: <P ></P ><UL ><LI ><P >You run pdq or xpdq, specifying a file. </P ></LI ><LI ><P >You specify a printer. </P ></LI ><LI ><P >You specify the settings for the various options and arguments defined in the printer's PDQ driver file (duplex, copies, print quality, and so forth). </P ></LI ><LI ><P >PDQ analyzes the contents of what you printed, and follows the instructions in the PDQ driver file which tell it how to process your data for this printer with your options. </P ></LI ><LI ><P >PDQ sends the processed data to the printer according to the interface defined for that printer (straight to <TT CLASS="FILENAME" >/dev/lp0</TT >, or to an LPD daemon on the network, over the network to an Apple or Microsoft system, or even to a fax machine). </P ></LI ><LI ><P >If PDQ can't send the data to the printer right away, it spawns a background process to wait and try again until it succeeds or hits a time limit. </P ></LI ></UL > At all times during this process, and afterwards, the state of each print job can be seen and inspected using xpdq. Jobs that failed are shown in red and can be resent. </P ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="LPD-OVERVIEW" >7.2. LPD</A ></H2 ><A NAME="AEN1629" ></A ><P > Lpd stands for Line Printer Daemon, and refers in different contexts to both the daemon and the whole collection of programs which run print spooling. These are: <P ></P ><DL ><DT ><B CLASS="COMMAND" ><A HREF="http://www.linuxprinting.org/man/lpd.8.html" TARGET="_top" >lpd</A ></B ></DT ><DD ><P >The spooling daemon. One of these runs to control everything on a machine, AND one is run per printer while the printer is printing. </P ></DD ><DT ><A NAME="LPR-IN-LPD-OVERVIEW" ><B CLASS="COMMAND" ><A HREF="http://www.linuxprinting.org/man/lpr.1.html" TARGET="_top" >lpr</A ></B ></A ></DT ><DD ><P >The user spooling command. Lpr contacts lpd and injects a new print job into the spool. </P ></DD ><DT ><A NAME="LPQ-IN-LPD" ><B CLASS="COMMAND" ><A HREF="http://www.linuxprinting.org/man/lpq.1.html" TARGET="_top" >lpq</A ></B ></A ></DT ><DD ><P >Lists the jobs in a print queue. </P ></DD ><DT ><A NAME="LPC-IN-LPD" ><B CLASS="COMMAND" ><A HREF="http://www.linuxprinting.org/man/lpc.8.html" TARGET="_top" >lpc</A ></B ></A ></DT ><DD ><P >The Lpd system control command. With lpc you can stop, start, reorder, etc, the print queues. </P ></DD ><DT ><A NAME="LPRM-IN-LPD" ><B CLASS="COMMAND" ><A HREF="http://www.linuxprinting.org/man/lprm.1.html" TARGET="_top" >lprm</A ></B ></A ></DT ><DD ><P ><B CLASS="COMMAND" >lprm</B > removes a job from the print spool. </P ></DD ></DL > </P ><P > So how does it fit together? The following things happen: <P ></P ><OL TYPE="1" ><LI ><P >At boot time, <B CLASS="COMMAND" >lpd</B > is run. It waits for connections and manages printer queues. </P ><P > </P ></LI ><LI ><P >A user submits a job with the <B CLASS="COMMAND" >lpr</B > command or, alternatively, with an lpr front-end like GPR, PDQ, etc. <B CLASS="COMMAND" >Lpr</B > contacts <B CLASS="COMMAND" >lpd</B > over the network and submits both the user's data file (containing the print data) and a control file (containing user options). </P ><P > </P ></LI ><LI ><P >When the printer becomes available, the main <B CLASS="COMMAND" >lpd</B > spawns a child <B CLASS="COMMAND" >lpd</B > to handle the print job. </P ></LI ><LI ><P >The child <B CLASS="COMMAND" >lpd</B > executes the appropriate filter(s) (as specified in the <TT CLASS="OPTION" >if</TT > attribute in <TT CLASS="FILENAME" >/etc/printcap</TT >) for this job and sends the resulting data on to the printer. </P ></LI ></OL > </P ><P > The lp system was originally designed when most printers were line printers - that is, people mostly printed plain ascii. By placing all sorts of magic in the <TT CLASS="OPTION" >if</TT > filter, modern printing needs can be met with <B CLASS="COMMAND" >lpd</B > (well, more or less; many other systems do a better job). </P ><P > There are many programs useful for writing LPD filters. Among them are: <P ></P ><DL ><DT ><B CLASS="COMMAND" >gs</B ></DT ><DD ><P >Ghostscript is a host-based Postscript interpreter (aka a Raster Image Processor or RIP). It accepts Postscript and produces output in various printer languages or a number of graphics formats. Ghostscript is covered in <A HREF="ghostscript.html" >Section 10</A >. </P ></DD ><DT ><B CLASS="COMMAND" >ppdfilt</B ></DT ><DD ><P ><B CLASS="COMMAND" ><A HREF="http://sourceforge.net/project/?group_id=1658" TARGET="_top" >ppdfilt</A ></B > is a standalone version of a CUPS component. It filters Postscript, executing a few basic transformations on it (n-up printing, multiple copies, etc) and adding in user option statements according to a Postscript Printer Definition (PPD) file usually included with Postscript printers. </P ><P > <B CLASS="COMMAND" >ppdfilt</B > is best used together with an option-accepting LPD system (like the VA Linux LPD, or LPRng) and a filter script which parses user-provided options into the equivalent <B CLASS="COMMAND" >ppdfilt</B > command. VA Linux and HP provide a modified rhs-printfilters package which does exactly this; it produces nice results if you have a Postscript printer. See <A HREF="setup.html#LPD-FOR-POSTSCRIPT-PRINTERS" >Section 8.2.2</A > for information on this system. </P ></DD ><DT ><B CLASS="COMMAND" >ps2ps</B ></DT ><DD ><P ><B CLASS="COMMAND" >ps2ps</B > is a utility script included with Ghostscript. It filters Postscript into more streamlined Postscript, possibly at a lower Language Level. This is useful if you have an older Postscript printer; most modern software produces modern Postscript. </P ></DD ><DT ><B CLASS="COMMAND" >mpage</B ></DT ><DD ><P ><B CLASS="COMMAND" >mpage</B > is a utility which accepts text or Postscript, and generates n-up output—that is, output with several page images on each piece of paper. There are actually several programs which do this, including <B CLASS="COMMAND" >enscript</B >, <B CLASS="COMMAND" >nenscript</B >, and <B CLASS="COMMAND" >a2ps</B >. </P ></DD ><DT ><B CLASS="COMMAND" >a2ps</B ></DT ><DD ><P ><B CLASS="COMMAND" >a2ps</B >, aka any-to-ps, is a program which accepts a variety of file types and converts them to Postscript for printing. </P ></DD ></DL > </P ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="spoolers.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="setup.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Spooling software</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" > </TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >How to set things up</TD ></TR ></TABLE ></DIV ></BODY ></HTML >