old-www/HOWTO/Printing-HOWTO/setup.html

1068 lines
26 KiB
HTML

<HTML
><HEAD
><TITLE
>How to set things up</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="The Printing HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="How it all works"
HREF="background.html"><LINK
REL="NEXT"
TITLE="Vendor Solutions"
HREF="vendors.html"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation 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="background.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="vendors.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="setup"
></A
>8. How to set things up</H1
><P
>For common configurations, you can probably ignore this section
entirely - instead, you should jump straight to <A
HREF="vendors.html"
>Section 9</A
> below, or better yet, your vendor's
documentation. Most GNU/Linux distributions supply one or more
"idiot-proof" tools to do everything described here for common
printers.</P
><P
>If your vendor's tool doesn't work out for you, or you'd like the
ability to interactively control printing options when you print,
then you should use some other system. APS Filter
is another good system; it configures LPD queues and filters very
easily on most any sort of Unix system.</P
><P
>You can also use the printing system interfaces from the <A
HREF="http://www.linuxprinting.org/"
TARGET="_top"
>linuxprinting.org website</A
>
to connect many free drivers into several spooling systems. Once
this project is complete, these interfaces will offer the best
functionality: all styles of free software drivers are supported,
user-settable options are available, and most common spooling
systems are supported. Currently the foomatic print system is used in most modern distributions anyway. However, your distro may include a slightly outdated version of foomatic.</P
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="cups-config-tutorial"
></A
>8.1. Configuring CUPS</H2
><P
>If you are using a client with CUPS and a CUPS server has already been configured, installing the printers on your client can not get much easier than this: do nothing. Through broadcasting, the client should find the CUPS server and automatically configure the printers that are installed on that print server. This is one of the features of CUPS that will be really appreciated on large networks.</P
><P
>Manually configuring printers with CUPS, also is a peace of cake. If you are new to CUPS and/or Unix printing, the way to go is probably the web interface. If you have to configure lots of printers, using the command-line will probably be faster.</P
><P
>The URL to access the CUPS web interface is http://hostname:631/admin by default. The port can be changed in cupsd.conf if necessary.</P
><P
>To add a printer from the command-line the general syntax is
<B
CLASS="command"
>lpadmin -p printer -E -v device -m ppd</B
>
Lpadmin with the -p option adds or modifies a printer. The printers are saved in the file
The -x option deletes the named printer. Read the lpadmin man page for available options.
</P
><DIV
CLASS="example"
><A
NAME="AEN1314"
></A
><P
><B
>Example 3. command-line examples</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;/usr/sbin/lpadmin -p testpr1 -E -v socket://192.168.1.9 -m deskjet.ppd
/usr/sbin/lpadmin -p testpr2 -E -v parallel:/dev/lp0 -m laserjet.ppd
/usr/sbin/lpadmin -x testpr1
</PRE
></FONT
></TD
></TR
></TABLE
></DIV
><P
>More information about configuring printers and options can be found in the <A
HREF="http://www.cups.org/documentation.html"
TARGET="_top"
>CUPS documentation</A
>. The Software Administrators Manual will teach you all you need to know about configuring printers with CUPS.</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="lpd-config-tutorial"
></A
>8.2. Configuring LPD</H2
><P
>Until recently most GNU/Linux distributions shipped with LPD. This section describes a very
basic setup for LPD; further sections detail the creation of
complex filters and network configuration.</P
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="basic-lpd-configuration"
></A
>8.2.1. Basic LPD configuration</H3
><P
>The minimal setup for lpd results in a system that can queue
files and print them. It will not pay any attention to whether or
not your printer will understand them, and will probably not let
you produce attractive output. But we have to start somewhere.</P
><P
>To add a print queue to lpd, you must add an entry in<TT
CLASS="filename"
>/etc/printcap</TT
>, and make the new spool
directory under <TT
CLASS="filename"
>/var/spool/lpd</TT
>.</P
><P
>An entry in <TT
CLASS="filename"
>/etc/printcap</TT
> looks like:<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;# LOCAL djet500
lp|dj|deskjet:\
:sd=/var/spool/lpd/dj:\
:mx#0:\
:lp=/dev/lp0:\
:sh:
</PRE
></FONT
></TD
></TR
></TABLE
>
This defines a spool called <EM
>lp</EM
>,<EM
>dj</EM
>, or <EM
>deskjet</EM
>, spooled
in the directory <TT
CLASS="filename"
>/var/spool/lpd/dj</TT
>, with no
per-job maximum size limit, which prints to the device<TT
CLASS="filename"
>/dev/lp0</TT
>, and which does not have a banner
page (with the name of the person who printed, etc) added to the
front of the print job.</P
><P
>Go now and read the man page for <TT
CLASS="filename"
><TT
CLASS="replaceable"
><I
><A
HREF="http://www.linuxprinting.org/man/printcap.5.html"
TARGET="_top"
>printcap</A
></I
></TT
></TT
>.</P
><P
>The above looks very simple, but there a catch - unless I send in
files a DeskJet 500 can understand, this DeskJet will print
strange things. For example, sending an ordinary Unix text file
to a deskjet results in literally interpreted newlines, and gets
me:<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;This is line one.
This is line two.
This is line three.</PRE
></FONT
></TD
></TR
></TABLE
>
ad nauseam. Printing a PostScript file to this spool would get a
beautiful listing of the PostScript commands, printed out with
this "staircase effect", but no useful output.</P
><P
>&#13;
Clearly more is needed, and this is the purpose of filtering.
The more observant of you who read the printcap man page might
have noticed the spool attributes <TT
CLASS="option"
>if</TT
> and<TT
CLASS="option"
>of</TT
>. Well, <TT
CLASS="option"
>if</TT
>, or the
input filter, is just what we need here.</P
><P
>If we write a small shell script called <B
CLASS="command"
>filter</B
>
that adds carriage returns before newlines, the staircasing can
be eliminated. So we have to add in an <TT
CLASS="option"
>if</TT
>
line to our printcap entry above:<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;lp|dj|deskjet:\
:sd=/var/spool/lpd/dj:\
:mx#0:\
:lp=/dev/lp0:\
:if=/var/spool/lpd/dj/filter:\
:sh:
</PRE
></FONT
></TD
></TR
></TABLE
>
A simple filter script might be:<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;#!perl
# The above line should really have the whole path to perl
# This script must be executable: chmod 755 filter
while(&#60;STDIN&#62;){chomp $_; print "$_\r\n";};
# You might also want to end with a form feed: print "\f";
</PRE
></FONT
></TD
></TR
></TABLE
>
If we were to do the above, we'd have a spool to which we could
print regular Unix text files and get meaningful results. (Yes,
there are four million better ways to write this filter, but few
so illustrative. You are encouraged to do this more
efficiently.)</P
><P
>The only remaining problem is that printing plain text is really
not too hot - surely it would be better to be able to print
PostScript and other formatted or graphic types of output. Well,
yes, it would, and it's easy to do. The method is simply an
extension of the above linefeed-fixing filter.</P
><P
>Such a filter is called a <EM
>magic</EM
> filter. Don't bother
writing one yourself unless you print strange things - there are
a good many written for you already, and most have easy-to-use
interactive configuration tools. You should simply select a
suitable pre-written filter:<P
></P
><DIV
CLASS="variablelist"
><P
><B
></B
></P
><DL
><DT
><A
NAME="lpdomatic-filter-available"
></A
>foomatic-rip</DT
><DD
><P
><A
HREF="http://www.linuxprinting.org/lpd-doc.html"
TARGET="_top"
>foomatic-rip</A
> is a filter designed to use data from the
LinuxPrinting.org printer database. It supports essentially
all free software printer drivers, including regular
Ghostscript drivers, Uniprint drivers, and the assorted
filter programs floating around out there. foomatic-rip works with
CUPS, LPRng, LPD, GNUlpr, PPR, PDQ, no spooler. </P
></DD
><DT
><A
NAME="apsfilter-available-now"
></A
>APS Filter</DT
><DD
><P
><A
HREF="http://www.apsfilter.org/"
TARGET="_top"
>apsfilter</A
> is a filter designed for use on a wide
variety of Unices. It supports essentially all
Ghostscript drivers. It, too, works with
various strains of LPD, including stock BSD and
LPRng.</P
></DD
><DT
><A
NAME="rhs-printfilters-available"
></A
>RHS-Printfilters</DT
><DD
><P
>RHS-Printfilters is a filter system constructed by Red Hat.
It shipped beginning, I think, in version 4 of Red Hat Linux,
as the backend to the easy-to-use <B
CLASS="command"
>printtool</B
> GUI printer configuration tool.
</P
><P
>The rhs filter system is built on an ASCII database listing
distributed with it. This listing supports many Ghostscript
and Uniprint drivers, but not filter-style drivers. The
filters constructed also do not support much in the way of
user-controllable options at print time.</P
><P
>&#13;The <B
CLASS="command"
>printtool</B
> places a configuration file
named <TT
CLASS="filename"
>postscript.cfg</TT
> in the spool
directory. Inside this Bourne shell-style file, each setting
is a variable. In unusual cases, you can make useful changes
directly to the config file which the printtool won't allow;
typically this would be the specification of an unusual
Ghostscript driver, or a PPD filename for the VA
rhs-printfilters version.</P
><P
>&#13;VA Linux has made some enhancements to the rhs-printfilters
system under contract from HP. With the proper versions, it
is possible to select options for Postscript printers
under control of Adobe PPD files. I cover this system in<A
HREF="setup.html#lpd-for-postscript-printers"
>Section 8.2.2</A
>.</P
></DD
></DL
></DIV
></P
><P
>There's one catch to such filters: older version of lpd don't run
the <EM
>if</EM
> filter for remote printers, while
most newer ones do (although often with no arguments). The
version of LPD shipped with modern GNU/Linux and FreeBSD
distributions does; most commercial Unices that still ship LPD
have a version that does not. See the section on network
printing later in this document for more information on this. If
you only have locally-connected printers, then this won't affect
you.</P
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="lpd-for-postscript-printers"
></A
>8.2.2. LPD for PostScript Printers</H3
><P
>While most versions of LPD don't gracefully handle PostScript
(never mind user options), VA Linux modified LPD and Red
Hat's filtering software to support PostScript printers fairly
well. Because the intention was to donate the code to the gnu project, they called it <A
HREF="http://lpr.sourceforge.net/"
TARGET="_top"
>GNUlpr</A
></P
><DIV
CLASS="simplesect"
><H4
CLASS="simplesect"
><A
NAME="AEN1447"
></A
>8.2.2.1. How it works</H4
><P
>VA's system uses Postscript Printer Definition, or PPD,
files. PPD files are provided by printer manufacturers and
declare the available options on a printer, along with the
Postscript code needed to activate them. With the VA system,
the normal LPD scheme works a little differently:<P
></P
><OL
TYPE="1"
><LI
><P
>The user can specify options with the <TT
CLASS="option"
>-o</TT
>
flag. For example, you might specify <TT
CLASS="option"
>-o
MediaType:Transparency</TT
> if you were about to print on
overhead film. Alternatively, the front-end <A
HREF="http://www.compumetric.com/linux.html"
TARGET="_top"
>GPR</A
> can
be used to specify options in a dialog box; you can see
screenshots of GPR in <A
HREF="how.html#gpr-intro"
>Section 3.4.3</A
>.</P
></LI
><LI
><P
>LPR passes the options to LPD as an extended attribute in the
LPD control file.</P
></LI
><LI
><P
>A modified version of the rhs-printfilters package is given
the extended options data in an environment variable, and
uses ppdfilt to add these options to the print data.</P
></LI
></OL
></P
></DIV
><DIV
CLASS="simplesect"
><H4
CLASS="simplesect"
><A
NAME="AEN1461"
></A
>8.2.2.2. Obtaining and Installing</H4
><P
>You can obtain RPM packages, or source tarballs, from the
project's <A
HREF="http://sourceforge.net/projects/lpr"
TARGET="_top"
>website
on SourceForge</A
>. For installation details, consult the
project's <A
HREF="http://printing.sourceforge.net/gpr-libppd-uhowto.html"
TARGET="_top"
>installation
micro-HOWTO</A
>. In essence, you need to uninstall the Red
Hat version of printtool, lpd, and rhs-printfilters entirely,
and then install the VA versions, plus ppdfilt, gpr, and a few
other utilities.</P
><P
>You will also need PPD files for your Postscript printers.
PPD files are usually fairly easy to find. VA Linux and HP
distribute PPD files for many Laserjet models. Other vendors
provide PPDs for their own printers, and Adobe distributes <A
HREF="http://www.adobe.com/products/printerdrivers/winppd.html"
TARGET="_top"
>PPD files</A
> for many printers.</P
><P
>At the moment, much of this is a bit difficult to install. But
future installation tools will build upon the printer
configuration library <B
CLASS="command"
>libprinterconf</B
>, which
enables both the autodetection and rhs-printfilter configuration
of both networked and local printers.</P
><DIV
CLASS="note"
><P
></P
><TABLE
CLASS="note"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/note.gif"
HSPACE="5"
ALT="Note"></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>It is possible to use GPR alone, without the modified LPD
or even rhs-printfilters. GPR can be compiled with
all the logic needed to massage Postscript jobs directly.
This may be an easier-to-install option suitable for
people who never really need to print using lpr
directly.</P
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="simplesect"
><H4
CLASS="simplesect"
><A
NAME="AEN1472"
></A
>8.2.2.3. Controlling Postscript Options</H4
><P
>Once you've setup VA's Postscript-capable LPD system (GNUlpr), you can
control your printer's options in two ways:<P
></P
><DIV
CLASS="variablelist"
><DL
><DT
>With the GUI</DT
><DD
><P
>To use GPR, you first make sure that you've specified the
proper PPD file. Then the printer's options will be
available on the `Advanced' panel. Basic <B
CLASS="command"
>ppdfilt</B
> options will be available on the
`Common' panel.</P
></DD
><DT
>With the command line</DT
><DD
><P
>This <B
CLASS="command"
>lpr</B
> supports the <TT
CLASS="option"
>-o</TT
>
option. You may specify any option/value pair from your
printer's PPD file with <TT
CLASS="option"
>-o</TT
>. For example,
consider this PPD file option clause:<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;*OpenUI *PrintQuality/Print Quality: PickOne
*DefaultPrintQuality: None
*OrderDependency: 150 AnySetup *PrintQuality
*PrintQuality None/Printer Setting: ""
*PrintQuality Quick/QuickPrint: "&#60;&#60; /DeviceRenderingInfo ...
*PrintQuality Normal/Normal: "&#60;&#60; /DeviceRenderingInfo &#60;&#60; /...
*PrintQuality Pres/Presentation: "&#60;&#60; /DeviceRenderingInfo ...
*PrintQuality Image/1200 Image Quality: "&#60;&#60; /DeviceRenderi...
*CloseUI: *PrintQuality
</PRE
></FONT
></TD
></TR
></TABLE
>
For the option <TT
CLASS="option"
>PrintQuality</TT
>, the possible
values are <TT
CLASS="option"
>Quick</TT
>, <TT
CLASS="option"
>Normal</TT
>,<TT
CLASS="option"
>Pres</TT
>, or <TT
CLASS="option"
>Image</TT
>. You might
give a command like:<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
><TT
CLASS="prompt"
>%</TT
> <B
CLASS="command"
>lpr</B
> <TT
CLASS="option"
>-o PrintQuality:Image</TT
> <TT
CLASS="option"
>file.ps</TT
></PRE
></FONT
></TD
></TR
></TABLE
></P
><P
>&#13;There are a number of options common to all printers which
will work in addition to the ones from your PPD. These
include:<P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><TT
CLASS="option"
>page-ranges</TT
></DT
><DD
><P
>You can specify a range of pages to print. For example,<TT
CLASS="option"
>page-ranges:2-3</TT
>.</P
></DD
><DT
><TT
CLASS="option"
>page-set</TT
></DT
><DD
><P
>You can print only odd or even pages. For example,<TT
CLASS="option"
>page-set:odd</TT
>.</P
></DD
><DT
><TT
CLASS="option"
>number-up</TT
></DT
><DD
><P
>You can print multiple pages on each piece of paper.
For example, <TT
CLASS="option"
>number-up:2</TT
>.</P
></DD
></DL
></DIV
>
Other options are detailed in the <B
CLASS="command"
>ppdfilt</B
>
man page.</P
></DD
></DL
></DIV
></P
></DIV
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="lpd-permissions"
></A
>8.2.3. File Permissions</H3
><P
>By popular demand, I include below a listing of the permissions
on interesting files on my system. There are a number of better
ways to do this, ideally using only SGID binaries and not making
everything SUID root, but this is how my system came out of the
box, and it works for me. (Quite frankly, if your vendor can't
even ship a working lpd you're in for a rough ride).<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;-r-sr-sr-x 1 root lp /usr/bin/lpr*
-r-sr-sr-x 1 root lp /usr/bin/lprm*
-rwxr--r-- 1 root root /usr/sbin/lpd*
-r-xr-sr-x 1 root lp /usr/sbin/lpc*
drwxrwxr-x 4 root lp /var/spool/lpd/
drwxr-xr-x 2 root lp /var/spool/lpd/lp/</PRE
></FONT
></TD
></TR
></TABLE
></P
><P
>Lpd must currently be run as root so that it can bind to the
low-numbered lp service port. It should probably become UID
lp.lp or something after binding, but I don't think it does.
This is simply one more reason to avoid the stock BSD LPD.</P
></DIV
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="large-installations"
></A
>8.3. Large Installations</H2
><P
>Large installations, by which I mean networks including more than
two printers or hosts, have special needs. Below are some tips.</P
><P
>CUPS has some nice features that make a good choice for a large network. Printer classes, access control and automatic client configuration to name a few.</P
><P
>If you use LPD, for really large environments, merely distributing printcap/filter
information becomes a difficult problem; the <A
HREF="http://ceps.sourceforge.net/"
TARGET="_top"
>Cisco Enterprise Print
System</A
> addresses this and is probably either a good starting
point or a nearly complete solution, depending on your needs.
Medium to large environments can be well supported by native LPRng
features.
<P
></P
><UL
><LI
><P
>Each printer should have a single point of control, where an
administrator can pause, reorder, or redirect the queue. To
implement this, have everyone printing to a local server,
which will then queue jobs and direct them to the proper
printer. For large campuses or distributed networks, have one
server per building or other suitable network subset.</P
></LI
><LI
><P
>Use CUPS or LPRng, at least on servers; the BSD LPD is too buggy for
"real" use. But don't take my word for it&#8212;you should test a number of
spoolers and see which suits you best.</P
></LI
><LI
><P
>Client systems should not have unique printing configurations. CUPS provides automatic client configuration of printers on the same subnet. You can even configure CUPS (BrowsePoll) to poll servers on other subnets for available printers. These features limit the amount of configuration that needs to take place at the client.
To implement a uniform printing configuration with LPRng, use LPRng's extended printcap syntax so
that you have one printcap to use everywhere. CEPS provides
for this by building atop a lightweight distributed database
instead of traditional printcap files.</P
></LI
><LI
><P
>Print queues should not be named for make or model; name print
queues for something sensible like location (floor2_nw)
or capability (color_transparency). Three years from
now, when a printer breaks, you will be able to replace it
with a different make or model without causing confusion.</P
></LI
><LI
><P
>Operate a web page which shows detailed information on each
printer, including location, capabilities, etc. Consider
having it show the queue and include a button to remove jobs
from the queue. Complex networked environments are
unmanageable for users without proper documentation.</P
></LI
><LI
><P
>On Windows and Apple systems, use either the platform-specific
drivers <EM
>everywhere</EM
> (Samba supports the
Windows automagical driver-download mechanism) or, better, use
generic Postscript drivers <EM
>everywhere</EM
>. Do
not mix and match; primitive word processors often produce
different output when the installed printer driver changes;
users cannot deal with output that varies depending on the
particular client/printer pair.</P
></LI
><LI
><P
>If at all possible, buy a large-volume printer for
large-volume printing. If on a budget, use LPRng's multiple
printers/one queue facility or CUPS printer classes and assign a babysitter; printers
are complex mechanical devices that will often jam and run out
of paper in such configurations.</P
></LI
><LI
><A
NAME="network-print-servers-in-large"
></A
><P
>Do not feel that printers must be plugged into workstations;
Ethernet "print servers" now cost under $100. The ability to
locate printers anywhere you can network is a big improvement
over forced location near a host; locate printers in sensible,
central locations.</P
></LI
><LI
><P
>Use any SNMP trap or other monitoring/alert facility available
to you - someone should be tasked with running around and
fixing printers with no ink or paper. Npadmin (see <A
HREF="network.html#npadmin"
>Section 11.10.1</A
>) can be used to do some management
operations with SNMP printers.</P
></LI
></UL
>
</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="accounting"
></A
>8.4. Accounting</H2
><P
>Regular LPD provides very little to help you with accounting. You
can specify the name of an accounting file in the <TT
CLASS="option"
>af</TT
> printcap attribute, but this is merely passed
as an argument to your <TT
CLASS="option"
>if</TT
> filter. It's up to you
to make your <TT
CLASS="option"
>if</TT
> filter write entries to the
accounting file, and up to you to process the accounting file
later (the traditional format is mainly useful for line printers,
and is nontrivial to parse in Perl, so there's no reason to
preserve it). Also, if you're using <B
CLASS="command"
>foomatic-rip</B
> program as your filter, you'll need
to make changes, since it depends on being given a configuration
file as the ``accounting'' file name.</P
><P
>CUPS provides page accounting by passing jobs through the pstops filter. This filter expects Postscript input. If you use print "raw" jobs, this is always counted as 1 page. This means that accounting will not work, if you print from Windows client with the native printer driver.</P
><P
>&#13;Ghostscript provides a PageCount operator that you can use to
count the number of pages in each job; basically you just tack a
few lines of postscript onto the end of the job to write an
accounting file entry; for the best example of this see the file<TT
CLASS="filename"
>unix-lpr.sh</TT
> in the Ghostscript source
distribution.</P
><P
>Note that the <B
CLASS="command"
>unix-lpr</B
> implementation of
accounting writes to a file from the Ghostscript interpreter, and
is thus incompatible with the recommended -dSAFER option. A
better solution might be to query the printer with a PJL command
after each job, or to write a postscript snippet that prints the
pagecount on stdout, where it can be captured without having to
write to a file.</P
><P
>&#13;The LPRng print spooler includes an HP-specific sample
implementation of accounting; I assume that it queries the
printer with PJL. This technique should work for most PJL,
Postscript, or SNMP printers with which you have two-way
communications.</P
><P
>If you have a networked printer that supports SNMP, you can use
the npadmin program to query a pagecount after each job. This
should work properly for all print jobs. See <A
HREF="network.html#npadmin"
>Section 11.10.1</A
> for more information on npadmin.</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="background.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="vendors.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>How it all works</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Vendor Solutions</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>