Another set of validation updates
[Samba.git] / docs / Samba-HOWTO-Collection / CUPS-printing.xml
blob145422fe7eb2df628162f184fa381ea684dbbe9e
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
3 <chapter id="CUPS-printing">
5 <chapterinfo>
7         <author>
8                 <firstname>Kurt</firstname><surname>Pfeifle</surname>
9                 <affiliation>
10                         <orgname>Danka Deutschland GmbH </orgname>
11                         <address><email>kpfeifle@danka.de</email></address>
12                 </affiliation>
13         </author>
14         <author>
15                 <firstname>Ciprian</firstname><surname>Vizitiu</surname>
16                 <affiliation>
17                         <address><email>CVizitiu@gbif.org</email></address>
18                 </affiliation>
19                 <contrib>drawings</contrib>
20         </author>
22         <author>&person.jelmer;<contrib>drawings</contrib></author>
24         <pubdate> (27 Jan 2004) </pubdate>
25 </chapterinfo>
27 <title>CUPS Printing Support</title>
29 <sect1>
31         <title>Introduction</title>
33         <sect2>
34                 <title>Features and Benefits</title>
36                 <para>
37                 The Common UNIX Print System (<ulink url="http://www.cups.org/">CUPS</ulink>)
38                 has become quite popular. All major Linux distributions now ship it as their default printing
39                 system. To many, it is still a mystical tool. Mostly, it just works.
40                 People tend to regard it as a <quote>black box</quote>
41                 that they do not want to look into as long as it works. But once
42                 there is a little problem, they are in trouble to find out where to
43                 start debugging it. Refer to the chapter <quote>Classical Printing</quote> that
44                 contains a lot of information that is relevant for CUPS.
45                 </para>
47                 <para>
48                 CUPS sports quite a few unique and powerful features. While their
49                 basic functions may be grasped quite easily, they are also
50                 new. Because they are different from other, more traditional printing
51                 systems, it is best not to try and apply any prior knowledge about
52                 printing to this new system. Rather, try to understand CUPS
53                 from the beginning. This documentation will lead you to a
54                 complete understanding of CUPS. Let's start with the most basic
55                 things first.
56                 </para>
58         </sect2>
60         <sect2>
61                 <title>Overview</title>
63                 <para>
64                 CUPS is more than just a print spooling system. It is a complete
65                 printer management system that complies with the new
66                 Internet Printing Protocol (IPP). IPP is an industry
67                 and Internet Engineering Task Force (IETF)
68                 standard for network printing. Many of its functions can be managed
69                 remotely (or locally) via a Web browser (giving you a
70                 platform-independent access to the CUPS print server). Additionally, it
71                 has the traditional command line and several more modern GUI interfaces
72                 (GUI interfaces developed by third parties, like KDE's
73                 overwhelming <ulink url="http://printing.kde.org/">KDEPrint</ulink>).
74                 </para>
76                 <para>
77                 CUPS allows creation of <quote>raw</quote> printers (i.e., no print file
78                 format translation) as well as <quote>smart</quote> printers (i.e., CUPS does
79                 file format conversion as required for the printer). In many ways
80                 this gives CUPS similar capabilities to the MS Windows print
81                 monitoring system. Of course, if you are a CUPS advocate, you would
82                 argue that CUPS is better! In any case, let us now move on to
83                 explore how one may configure CUPS for interfacing with MS Windows
84                 print clients via Samba.
85                 </para>
86         </sect2>
87 </sect1>
89 <sect1>
90         <title>Basic CUPS Support Configuration</title>
92         <para>
93         Printing with CUPS in the most basic &smb.conf; setup in Samba-3.0 (as was true for 2.2.x) only needs two
94         settings: <smbconfoption name="printing">cups</smbconfoption> and
95         <smbconfoption name="printcap">cups</smbconfoption>. CUPS does not need a printcap file.
96         However, the <filename>cupsd.conf</filename> configuration file knows of two related directives that control
97         how such a file will be automatically created and maintained by CUPS for the convenience of third-party
98         applications (example: <parameter>Printcap /etc/printcap</parameter> and <parameter>PrintcapFormat BSD</parameter>).
99         Legacy programs often require the existence of a printcap file containing printer names or they will refuse to
100         print. Make sure CUPS is set to generate and maintain a printcap file. For details, see
101         <command>man cupsd.conf</command> and other CUPS-related documentation, like the wealth of documents on your CUPS server
102         itself: <ulink noescape="1" url="http://localhost:631/documentation.html">http://localhost:631/documentation.html</ulink>.
103         </para>
105         <sect2>
106                 <title>Linking smbd with libcups.so</title>
108                 <para>
109                 Samba has a special relationship to CUPS. Samba can be compiled with CUPS library support.
110                 Most recent installations have this support enabled. Per default, CUPS linking is compiled
111                 into smbd and other Samba binaries. Of course, you can use CUPS even
112                 if Samba is not linked against <filename>libcups.so</filename> &smbmdash; but
113                 there are some differences in required or supported configuration.
114                 </para>
116                 <para>
117                 When Samba is compiled against <filename>libcups</filename>, <smbconfoption name="printcap">cups</smbconfoption>
118                 uses the CUPS API to list printers, submit jobs, query queues, and so on. Otherwise it maps to the System V
119                 commands with an additional <command>-oraw</command> option for printing. On a Linux
120                 system, you can use the <command>ldd</command> utility to find out details (ldd may not be present on
121                 other OS platforms, or its function may be embodied by a different command):
122                 </para>
124 <para><screen>
125 &rootprompt;<userinput>ldd `which smbd`</userinput>
126 libssl.so.0.9.6 =&gt; /usr/lib/libssl.so.0.9.6 (0x4002d000)
127 libcrypto.so.0.9.6 =&gt; /usr/lib/libcrypto.so.0.9.6 (0x4005a000)
128 libcups.so.2 =&gt; /usr/lib/libcups.so.2 (0x40123000)
129 [....]
130 </screen></para>
132                 <para>
133                 The line <computeroutput>libcups.so.2 =&gt; /usr/lib/libcups.so.2 (0x40123000)</computeroutput> shows
134                 there is CUPS support compiled into this version of Samba. If this is the case, and printing = cups
135                 is set, then <emphasis>any otherwise manually set print command in &smb.conf; is ignored</emphasis>.
136                 This is an important point to remember!
137                 </para>
139                 <tip><para> Should it be necessary, for any reason, to set your own print commands, you can do this by setting
140                 <smbconfoption name="printing">sysv</smbconfoption>. However, you will lose all the benefits
141                 of tight CUPS/Samba integration. When you do this you must manually configure the printing system commands
142                 (most important: 
143                 <smbconfoption name="print command"/>; other commands are
144                 <smbconfoption name="lppause command"/>,
145                 <smbconfoption name="lpresume command"/>,
146                 <smbconfoption name="lpq command"/>,
147                 <smbconfoption name="lprm command"/>,
148                 <smbconfoption name="queuepause command"/> and
149                 <smbconfoption name="queue resume command"/>).</para></tip>
150         </sect2>
152         <sect2>
153                 <title>Simple &smb.conf; Settings for CUPS</title>
155                 <para>
156                 To summarize, <link linkend="cups-exam-simple">following example</link> shows simplest printing-related setup for &smb.conf; to enable basic CUPS support:
157                 </para>
159                 <para><smbconfexample id="cups-exam-simple">
160                 <title>Simplest printing-related smb.conf</title>
161                 <smbconfsection>[global]</smbconfsection>
162                 <smbconfoption name="load printers">yes</smbconfoption>
163                 <smbconfoption name="printing">cups</smbconfoption>
164                 <smbconfoption name="printcap name">cups</smbconfoption>
166                 <smbconfsection>[printers]</smbconfsection>
167                 <smbconfoption name="comment">All Printers</smbconfoption>
168                 <smbconfoption name="path">/var/spool/samba</smbconfoption>
169                 <smbconfoption name="browseable">no</smbconfoption>
170                 <smbconfoption name="public">yes</smbconfoption>
171                 <smbconfoption name="guest ok">yes</smbconfoption>
172                 <smbconfoption name="writable">no</smbconfoption>
173                 <smbconfoption name="printable">yes</smbconfoption>
174                 <smbconfoption name="printer admin">root, @ntadmins</smbconfoption>
176                 </smbconfexample></para>
178                 <para>
179                 This is all you need for basic printing setup for CUPS. It will print
180                 all graphic, text, PDF, and PostScript files submitted from Windows
181                 clients. However, most of your Windows users would not know how to
182                 send these kinds of files to print without opening a GUI
183                 application. Windows clients tend to have local printer drivers
184                 installed, and the GUI application's print buttons start a printer
185                 driver. Your users also rarely send files from the command
186                 line. Unlike UNIX clients, they hardly submit graphic, text or PDF
187                 formatted files directly to the spooler. They nearly exclusively print
188                 from GUI applications with a <quote>printer driver</quote> hooked in between the
189                 application's native format and the print-data-stream. If the backend
190                 printer is not a PostScript device, the print data stream is <quote>binary,</quote>
191                 sensible only for the target printer. Read on to learn which problem
192                 this may cause and how to avoid it.
193                 </para>
194         </sect2>
196         <sect2>
197         <title>More Complex CUPS &smb.conf; Settings</title>
199         <para>
200         <link linkend="overridesettings">Next configuration</link> is a slightly more complex printing-related setup
201         for &smb.conf;. It enables general CUPS printing
202         support for all printers, but defines one printer share, which is set
203         up differently. 
204         </para>
206         <para><smbconfexample id="overridesettings">
207         <title>Overriding global CUPS settings for one printer</title>
208         <smbconfsection>[global]</smbconfsection>
209         <smbconfoption name="printing">cups</smbconfoption>
210         <smbconfoption name="printcap name">cups</smbconfoption>
211         <smbconfoption name="load printers">yes</smbconfoption>
213         <smbconfsection>[printers]</smbconfsection>
214         <smbconfoption name="comment">All Printers</smbconfoption>
215         <smbconfoption name="path">/var/spool/samba</smbconfoption>
216         <smbconfoption name="public">yes</smbconfoption>
217         <smbconfoption name="guest ok">yes</smbconfoption>
218         <smbconfoption name="writable">no</smbconfoption>
219         <smbconfoption name="printable">yes</smbconfoption>
220         <smbconfoption name="printer admin">root, @ntadmins</smbconfoption>
222         <smbconfsection>[special_printer]</smbconfsection>
223         <smbconfoption name="comment">A special printer with his own settings</smbconfoption>
224         <smbconfoption name="path">/var/spool/samba-special</smbconfoption>
225         <smbconfoption name="printing">sysv</smbconfoption>
226         <smbconfoption name="printcap">lpstat</smbconfoption>
227         <smbconfoption name="print command">echo "NEW: `date`: printfile %f" \</smbconfoption>
228         <member><parameter> >> /tmp/smbprn.log ; \</parameter></member>
229         <member><parameter>echo "     `date`: p-%p s-%s f-%f" >> /tmp/smbprn.log ; \</parameter></member>
230         <member><parameter>echo "     `date`: j-%j J-%J z-%z c-%c" >> /tmp/smbprn.log ; rm %f</parameter></member>
231         <smbconfoption name="public">no</smbconfoption>
232         <smbconfoption name="guest ok">no</smbconfoption>
233         <smbconfoption name="writable">no</smbconfoption>
234         <smbconfoption name="printable">yes</smbconfoption>
235         <smbconfoption name="printer admin">kurt</smbconfoption>
236         <smbconfoption name="hosts deny">0.0.0.0</smbconfoption>
237         <smbconfoption name="hosts allow">turbo_xp, 10.160.50.23, 10.160.51.60</smbconfoption>
238         </smbconfexample></para>
240         <para>
241         This special share is only there for testing purposes. It does not write the print job to a file. It just logs the job parameters
242         known to Samba into the <filename>/tmp/smbprn.log</filename> file and deletes the job-file. Moreover, the
243         <smbconfoption name="printer admin"/> of this share is <quote>kurt</quote> (not the <quote>@ntadmins</quote> group),
244         guest access is not allowed, the share isn't published to the Network Neighborhood (so you need to know it is there), and it only
245         allows access from only three hosts. To prevent CUPS kicking in and taking over the print jobs for that share, we need to set
246         <smbconfoption name="printing">sysv</smbconfoption> and
247         <smbconfoption name="printcap">lpstat</smbconfoption>.
248         </para>
249         </sect2>
250 </sect1>
252 <sect1>
253         <title>Advanced Configuration</title>
255         <para>
256         Before we delve into all the configuration options, let us clarify a few
257         points. <emphasis>Network printing needs to be organized and setup
258         correctly</emphasis>. This frequently doesn't happen. Legacy systems
259         or small business LAN environments often lack design and good housekeeping.
260         </para>
263         <sect2>
264         <title>Central Spooling vs. <quote>Peer-to-Peer</quote> Printing</title>
267         <para>
268 <indexterm><primary>spooling</primary><secondary>central</secondary></indexterm>
269 <indexterm><primary>spooling</primary><secondary>peer-to-peer</secondary></indexterm>
270         Many small office or home networks, as well as badly organized larger
271         environments, allow each client a direct access to available network
272         printers. This is generally a bad idea. It often blocks one client's
273         access to the printer when another client's job is printing. It might
274         freeze the first client's application while it is waiting to get
275         rid of the job. Also, there are frequent complaints about various jobs
276         being printed with their pages mixed with each other. A better concept
277         is the usage of a print server: it routes all jobs through one
278         central system, which responds immediately, takes jobs from multiple
279         concurrent clients at the same time, and in turn transfers them to the
280         printer(s) in the correct order.
281         </para>
282         </sect2>
284         <sect2>
285         <title>Raw Print Serving &smbmdash; Vendor Drivers on Windows Clients</title>
288         <para>
289         <indexterm><primary>spooling-only</primary></indexterm>
290         <indexterm><primary>"raw" printing</primary></indexterm>
291         Most traditionally configured UNIX print servers acting on behalf of
292         Samba's Windows clients represented a really simple setup. Their only
293         task was to manage the <quote>raw</quote> spooling of all jobs handed to them by
294         Samba. This approach meant that the Windows clients were expected to
295         prepare the print job file that its ready to be sent to the printing
296         device. Here a native (vendor-supplied) Windows printer driver needs to
297         be installed on each and every client for the target device.
298         </para>
300         <para>
301         It is possible to configure CUPS, Samba and your Windows clients in the
302         same traditional and simple way. When CUPS printers are configured
303         for RAW print-through mode operation, it is the responsibility of the
304         Samba client to fully render the print job (file). The file must be
305         sent in a format that is suitable for direct delivery to the
306         printer. Clients need to run the vendor-provided drivers to do
307         this. In this case, CUPS will not do any print file format conversion
308         work.
309         </para>
311         <para>
312         The easiest printing configuration possible is to use raw print-through.
313         This is achieved by installation of the printer as if it was physically
314         attached to the Windows client. You then redirect output to a raw network
315         print queue. The following procedure may be followed to achieve this:
316         </para>
318         <procedure>
319                 <step><para>
320                 Edit <filename>/etc/cups/mime.types</filename> to uncomment the line
321                 near the end of the file that has:
322 <screen>
323 #application/octet-...
324 </screen>
325                 </para></step>
327                 <step><para>
328                 Do the same for the file <filename>/etc/cups/mime.convs</filename>.
329                 </para></step>
331                 <step><para>
332                 Add a raw printer using the Web interface. Point your browser at
333                 <constant>http://localhost:631</constant>. Enter Administration, add
334                 the printer following the prompts. Do not install any drivers for it.
335                 Choose Raw. Choose queue name <constant>Raw Queue</constant>.
336                 </para></step>
338                 <step><para>
339                 In the &smb.conf; file <constant>[printers]</constant> section add
340                 <smbconfoption name="use client driver">Yes</smbconfoption>,
341                 and in the <constant>[global]</constant> section add
342                 <smbconfoption name="printing">CUPS</smbconfoption>, plus
343                 <smbconfoption name="printcap">CUPS</smbconfoption>.
344                 </para></step>
346                 <step><para>
347                 Install the printer as if it is a local printer. i.e.: Printing to <constant>LPT1:</constant>.
348                 </para></step>
350                 <step><para>
351                 Edit the configuration under the <guimenu>Detail</guimenu> tab, create a
352                 <constant>local port</constant> that points to the raw printer queue that
353                 you have configured above. Example: <constant>\\server\raw_q</constant>.
354                 Here, the name <constant>raw_q</constant> is the name you gave the print
355                 queue in the CUPS environment.
356                 </para></step>
357         </procedure>
359         </sect2>
361         <sect2>
362         <title>Installation of Windows Client Drivers</title>
364         <para>
365         The printer drivers on the Windows clients may be installed
366         in two functionally different ways:
367         </para>
369         <itemizedlist>
370         <listitem><para>Manually install the drivers locally on each client,
371         one by one; this yields the old <emphasis>LanMan</emphasis> style
372         printing and uses a <filename>\\sambaserver\printershare</filename>
373         type of connection.</para></listitem>
376         <listitem><para>
377         <indexterm><primary>point 'n' print</primary></indexterm>
378                         Deposit and prepare the drivers (for later download) on
379                         the print server (Samba); this enables the clients to use
380         <quote>Point'n'Print</quote> to get drivers semi-automatically installed the
381         first time they access the printer; with this method NT/200x/XP
382         clients use the <emphasis>SPOOLSS/MS-RPC</emphasis>
383         type printing calls.</para></listitem>
384         </itemizedlist>
386         <para>
387         The second method is recommended for use over the first.
388         </para>
389         </sect2>
391         <sect2 id="cups-raw">
392         <title>Explicitly Enable <quote>raw</quote> Printing for <emphasis>application/octet-stream</emphasis></title>
395         <para>
396         <indexterm><primary>application/octet-stream</primary></indexterm>
397         <indexterm><primary>raw printing</primary></indexterm>
398         <indexterm><primary>MIME</primary><secondary>raw</secondary></indexterm>
399         If you use the first option (drivers are installed on the client
400         side), there is one setting to take care of: CUPS needs to be told
401         that it should allow <quote>raw</quote> printing of deliberate (binary) file
402         formats. The CUPS files that need to be correctly set for RAW mode
403         printers to work are:
404         </para>
406         <itemizedlist>
407                 <listitem><para><filename>/etc/cups/mime.types</filename></para></listitem>
408                 <listitem><para><filename>/etc/cups/mime.convs</filename></para></listitem>
409         </itemizedlist>
411         <para>
412         Both contain entries (at the end of the respective files) which must
413         be uncommented to allow RAW mode operation.
414         In <filename>/etc/cups/mime.types</filename>, make sure this line is
415         present:
417         <programlisting>
418          application/octet-stream
419         </programlisting>
421         <indexterm><primary>/etc/cups/mime.convs</primary></indexterm>
422         <indexterm><primary>/etc/cups/mime.types</primary></indexterm>
424         In <filename>/etc/cups/mime.convs</filename>,
425         have this line:
427         <indexterm><primary>application/vnd.cups-raw</primary></indexterm>
429         <programlisting>
430                 application/octet-stream   application/vnd.cups-raw   0   - 
431         </programlisting>
433         If these two files are not set up correctly for raw Windows client
434         printing, you may encounter the dreaded <computeroutput>Unable to
435         convert file 0</computeroutput> in your CUPS error_log file. 
436         </para>
438         <note><para>Editing the <filename>mime.convs</filename> and the
439         <filename>mime.types</filename> file does not
440         <emphasis>enforce</emphasis> <quote>raw</quote> printing, it only
441         <emphasis>allows</emphasis> it.
442         </para></note>
444         <formalpara><title>Background</title>
447         <para>
448         <indexterm><primary>application/octet-stream</primary></indexterm>
449         CUPS being a more security-aware printing system than traditional ones
450         does not by default allow a user to send deliberate (possibly binary)
451         data to printing devices. This could be easily abused to launch a
452         <quote>Denial of Service</quote> attack on your printer(s), causing at least
453         the loss of a lot of paper and ink. <quote>Unknown</quote> data are tagged by CUPS
454         as <parameter>MIME type: application/octet-stream</parameter> and not
455         allowed to go to the printer. By default, you can only send other
456         (known) MIME types <quote>raw</quote>. Sending data <quote>raw</quote> means that CUPS does not
457         try to convert them and passes them to the printer untouched (see the next
458         chapter for even more background explanations).
459         </para>
460         </formalpara>
462         <para>
463         This is all you need to know to get the CUPS/Samba combo printing
464         <quote>raw</quote> files prepared by Windows clients, which have vendor drivers
465         locally installed. If you are not interested in background information about
466         more advanced CUPS/Samba printing, simply skip the remaining sections
467         of this chapter.
468         </para>
469         </sect2>
471         <sect2>
472         <title>Driver Upload Methods</title>
474         <para>
475         This section describes three familiar methods, plus one new one, by which
476         printer drivers may be uploaded.
477         </para>
479         <para>
480         <indexterm><primary>point 'n' print</primary></indexterm>
481         If you want to use the MS-RPC type printing, you must upload the
482         drivers onto the Samba server first (<smbconfsection>[print$]</smbconfsection>
483         share). For a discussion on how to deposit printer drivers on the
484         Samba host (so the Windows clients can download and use them via
485         <quote>Point'n'Print</quote>), please refer to the previous chapter of this
486         HOWTO Collection. There you will find a description or reference to
487         three methods of preparing the client drivers on the Samba server:
488         </para>
489         <itemizedlist>
490                 <listitem><para>
491         <indexterm><primary>add printer wizard</primary></indexterm>
492                                 The GUI, <quote>Add Printer Wizard</quote>
493         <emphasis>upload-from-a-Windows-client</emphasis>
494         method.</para></listitem>
496         <listitem><para>The command line, <quote>smbclient/rpcclient</quote>
497         upload-from-a-UNIX-workstation method.</para></listitem>
500         <listitem><para>
501         <indexterm><primary>imprints</primary></indexterm>
502                         The Imprints Toolset
503         method.</para></listitem>
504         </itemizedlist>
506         <para>
507         These three methods apply to CUPS all the same. A new and more
508         convenient way to load the Windows drivers into Samba is provided
509         if you use CUPS:
510         </para>
513         <itemizedlist>
514                 <listitem><para>
515         <indexterm><primary>cupsaddsmb</primary></indexterm>
516                                 the <parameter>cupsaddsmb</parameter>
517         utility.</para></listitem>
518         </itemizedlist>
520         <para>
521         <command>cupsaddsmb</command> is discussed in much detail further below. But we first
522         explore the CUPS filtering system and compare the Windows and UNIX printing architectures.
523         </para>
524         </sect2>
525 </sect1>
527 <sect1>
528         <title>Advanced Intelligent Printing with PostScript Driver Download</title>
531         <para>
532         <indexterm><primary>PostScript</primary><seealso>Ghostscript</seealso></indexterm>
533         We now know
534         how to set up a <quote>dump</quote> printserver, that is, a server which is spooling
535         print-jobs <quote>raw</quote>, leaving the print data untouched.
536         </para>
538         <para>
539         Possibly you need to setup CUPS in a smarter way. The reasons could
540         be manifold:
541         </para>
543         <itemizedlist>
544         <listitem><para>Maybe your boss wants to get monthly statistics: Which
545         printer did how many pages? What was the average data size of a job?
546         What was the average print run per day? What are the typical hourly
547         peaks in printing? Which department prints how much?</para></listitem>
549         <listitem><para>Maybe you are asked to setup a print quota system:
550         Users should not be able to print more jobs, once they have surpassed
551         a given limit per period.</para></listitem>
553         <listitem><para>Maybe your previous network printing setup is a mess
554         and must be re-organized from a clean beginning.</para></listitem>
556         <listitem><para>Maybe you have experiencing too many <quote>blue screens</quote>
557         originating from poorly debugged printer drivers running in NT <quote>kernel mode</quote>?</para></listitem>
558         </itemizedlist>
560         <para>
561         These goals cannot be achieved by a raw print server. To build a
562         server meeting these requirements, you'll first need to learn about
563         how CUPS works and how you can enable its features.
564         </para>
566         <para>
567         What follows is the comparison of some fundamental concepts for
568         Windows and UNIX printing; then follows a description of the
569         CUPS filtering system, how it works and how you can tweak it.
570         </para>
572         <sect2 id="gdipost">
573         <title>GDI on Windows -- PostScript on UNIX</title>
576         <para>
577         <indexterm><primary>GDI</primary></indexterm>
578         <indexterm><primary>PostScript</primary></indexterm>
579         Network printing is one of the most complicated and error-prone
580         day-to-day tasks any user or administrator may encounter. This is
581         true for all OS platforms. And there are reasons for this.
582         </para>
585         <para>
586         <indexterm><primary>PCL</primary></indexterm>
587         <indexterm><primary>PDL</primary></indexterm>
588         You can't expect most file formats to just throw them toward
589         printers and they get printed. There needs to be a file format
590         conversion in between. The problem is that there is no common standard for
591         print file formats across all manufacturers and printer types. While
592         PostScript (trademark held by Adobe) and, to an
593         extent, PCL (trademark held by HP) have developed
594         into semi-official <quote>standards</quote> by being the most widely used PDLs
595         Page Description Languages (PDLs), there are still
596         many manufacturers who <quote>roll their own</quote> (their reasons may be
597         unacceptable license fees for using printer-embedded PostScript
598         interpreters, and so on).
599         </para>
600         </sect2>
602         <sect2>
603         <title>Windows Drivers, GDI and EMF</title>
606         <para>
607         <indexterm><primary>GDI</primary></indexterm>
608         <indexterm><primary>EMF</primary></indexterm>
609         <indexterm><primary>WYSIWYG</primary></indexterm>
610         In Windows OS, the format conversion job is done by the printer
611         drivers. On MS Windows OS platforms all application programmers have
612         at their disposal a built-in API, the Graphical Device
613         Interface (GDI), as part and parcel of the OS itself to base
614         themselves on. This GDI core is used as one common unified ground for
615         all Windows programs to draw pictures, fonts and documents
616         <emphasis>on screen</emphasis> as well as <emphasis>on
617         paper</emphasis> (print). Therefore, printer driver developers can
618         standardize on a well-defined GDI output for their own driver
619         input. Achieving WYSIWYG (<quote>What You See Is What You Get</quote>) is
620         relatively easy, because the on-screen graphic primitives, as well as
621         the on-paper drawn objects, come from one common source. This source,
622         the GDI, often produces a file format called Enhanced
623         MetaFile (EMF). The EMF is processed by the printer driver and
624         converted to the printer-specific file format.
625         </para>
627         <note><para>
628         <indexterm><primary>PDF</primary></indexterm>
629         To the GDI foundation in MS Windows, Apple has chosen to
630         put paper and screen output on a common foundation for their
631         (BSD-UNIX-based, did you know?) Mac OS X and Darwin Operating
632         <indexterm><primary>X Window System</primary></indexterm>
633         <indexterm><primary>PostScript</primary></indexterm>
634         <indexterm><primary>PCL</primary></indexterm>
635         <indexterm><primary>Xprint</primary></indexterm>
636         Systems. Their <emphasis>Core Graphic Engine</emphasis> uses a
637         <emphasis>PDF</emphasis> derivative for all display work.
638         </para></note>
640         <para>
642                 <image>
643                         <imagedescription>Windows printing to a local printer.</imagedescription>
644                         <imagefile>1small</imagefile>
645                 </image>
646         </para>
647         </sect2>
649         <sect2>
650         <title>UNIX Printfile Conversion and GUI Basics</title>
653         <para>
654         <indexterm><primary>X Window System</primary></indexterm>
655         <indexterm><primary>PostScript</primary></indexterm>
656         <indexterm><primary>PCL</primary></indexterm>
657         <indexterm><primary>Xprint</primary></indexterm>
658         In UNIX and Linux, there is no comparable layer built into the OS
659         kernel(s) or the X (screen display) server. Every application is
660         responsible for itself to create its print output. Fortunately, most
661         use PostScript and that at least gives some common ground. Unfortunately,
662         there are many different levels of quality for this PostScript. And
663         worse, there is a huge difference (and no common root) in the way
664         the same document is displayed on screen and how it is presented on
665         paper. WYSIWYG is more difficult to achieve. This goes back to the
666         time, decades ago, when the predecessors of X.org,
667         designing the UNIX foundations and protocols for Graphical User
668         Interfaces, refused to take responsibility for <quote>paper output</quote>
669         also, as some had demanded at the time, and restricted itself to
670         <quote>on-screen only.</quote> (For some years now, the <quote>Xprint</quote> project has been
671         under development, attempting to build printing support into the X
672         framework, including a PostScript and a PCL driver, but it is not yet
673         ready for prime time.) You can see this unfavorable inheritance up to
674         the present day by looking into the various <quote>font</quote> directories on your
675         system; there are separate ones for fonts used for X display and fonts
676         to be used on paper.
677         </para>
679         <formalpara>
680         <title>Background</title>
683         <para>
684         <indexterm><primary>PostScript</primary></indexterm>
685         The PostScript programming language is an <quote>invention</quote> by Adobe Inc.,
686         but its specifications have been published to the full. Its strength
687         lies in its powerful abilities to describe graphical objects (fonts,
688         shapes, patterns, lines, curves, and dots), their attributes (color,
689         linewidth) and the way to manipulate (scale, distort, rotate,
690         shift) them. Because of its open specification, anybody with the
691         skill can start writing his own implementation of a PostScript
692         interpreter and use it to display PostScript files on screen or on
693         paper. Most graphical output devices are based on the concept of
694         <quote>raster images</quote> or <quote>pixels</quote> (one notable exception is pen
695         plotters). Of course, you can look at a PostScript file in its textual
696         form and you will be reading its PostScript code, the language
697         instructions which need to be interpreted by a rasterizer. Rasterizers
698         produce pixel images, which may be displayed on screen by a viewer
699         program or on paper by a printer.
700         </para>
701         </formalpara>
702         </sect2>
704         <sect2 id="post-and-ghost">
705         <title>PostScript and Ghostscript</title>
708         <para>
709         <indexterm><primary>PostScript</primary></indexterm>
710         <indexterm><primary>GhostScript</primary><seealso>PostScript</seealso></indexterm>
711         <indexterm><primary>PostScript</primary><secondary>RIP</secondary></indexterm>
712         So, UNIX is lacking a common ground for printing on paper and
713         displaying on screen. Despite this unfavorable legacy for UNIX, basic
714         printing is fairly easy if you have PostScript printers at your
715         disposal. The reason is these devices have a built-in PostScript
716         language <quote>interpreter,</quote> also called a Raster Image
717         Processor (RIP) (which makes them more expensive than
718         other types of printers); throw PostScript toward them, and they will
719         spit out your printed pages. Their RIP is doing all the hard work of
720         converting the PostScript drawing commands into a bitmap picture as
721         you see it on paper, in a resolution as done by your printer. This is
722         no different to PostScript printing a file from a Windows origin.
723         </para>
725         <note><para>
726         <indexterm><primary>PPD</primary></indexterm>
727         Traditional UNIX programs and printing systems &smbmdash; while
728         using PostScript &smbmdash; are largely not PPD-aware. PPDs are <quote>PostScript
729                 Printer Description</quote> files. They enable you to specify and control all
730         options a printer supports: duplexing, stapling and punching. Therefore,
731         UNIX users for a long time couldn't choose many of the supported
732         device and job options, unlike Windows or Apple users. But now there
733         is CUPS.
734         </para>
735         </note>
737         <para>
738                 <image>
739                         <imagedescription>Printing to a PostScript printer.</imagedescription>
740                         <imagefile>2small</imagefile>
741                 </image>
742         </para>
745         <para>
746         <indexterm><primary>PDL</primary></indexterm>
747         However, there are other types of printers out there. These do not know
748         how to print PostScript. They use their own Page Description
749         Language (PDL, often proprietary). To print to them is much
750         more demanding. Since your UNIX applications mostly produce
751         PostScript, and since these devices do not understand PostScript, you
752         need to convert the print files to a format suitable for your printer
753         on the host before you can send it away.
754         </para>
755         </sect2>
757         <sect2>
758         <title>Ghostscript &smbmdash; the Software RIP for Non-PostScript Printers</title>
761         <para>
762         <indexterm><primary>GhostScript</primary></indexterm>
763         Here is where Ghostscript kicks in. Ghostscript is
764         the traditional (and quite powerful) PostScript interpreter used on
765         UNIX platforms. It is a RIP in software, capable of doing a
766         <emphasis>lot</emphasis> of file format conversions for a very broad
767         spectrum of hardware devices as well as software file formats.
768         Ghostscript technology and drivers are what enable PostScript printing
769         to non-PostScript hardware.
770         </para>
772         <para>
773         <image><imagedescription>Ghostscript as a RIP for non-postscript printers.</imagedescription>
774                 <imagefile>3small</imagefile>
775         </image>
776         </para>
778         <tip><para>
779         Use the <quote>gs -h</quote> command to check for all built-in <quote>devices</quote>
780         of your Ghostscript version. If you specify a parameter of
781         <parameter>-sDEVICE=png256</parameter> on your Ghostscript command
782         line, you are asking Ghostscript to convert the input into a PNG
783         file. Naming a <quote>device</quote> on the command line is the most important
784         single parameter to tell Ghostscript exactly how it should render the
785         input. New Ghostscript versions are released at fairly regular
786         intervals, now by artofcode LLC. They are initially put under the
787         <quote>AFPL</quote> license, but re-released under the GNU GPL as soon as the next
788         AFPL version appears. GNU Ghostscript is probably the version
789         installed on most Samba systems. But it has some deficiencies.
790         <indexterm><primary>Ghostscript</primary><secondary>ESP</secondary><see>ESP GhostScript</see></indexterm>
791         Therefore, ESP Ghostscript was developed as an
792         enhancement over GNU Ghostscript, with lots of bug-fixes, additional
793         devices and improvements. It is jointly maintained by developers from
794         CUPS, Gimp-Print, MandrakeSoft, SuSE, Red Hat, and Debian. It includes
795         the <quote>cups</quote> device (essential to print to non-PS printers from CUPS).
796         </para></tip>
797         </sect2>
799         <sect2>
800         <title>PostScript Printer Description (PPD) Specification</title>
803         <para>
804         <indexterm><primary>PPD</primary></indexterm>
805         While PostScript in essence is a Page Description
806         Language (PDL) to represent the page layout in a
807         device-independent way, real-world print jobs are
808         always ending up being output on hardware with device-specific
809         features. To take care of all the differences in hardware and to
810         allow for innovations, Adobe has specified a syntax and file format
811         for PostScript Printer Description (PPD)
812         files. Every PostScript printer ships with one of these files.
813         </para>
815         <para>
816         PPDs contain all the information about general and special features of the
817         given printer model: Which different resolutions can it handle? Does
818         it have a Duplexing Unit? How many paper trays are there? What media
819         types and sizes does it take? For each item, it also names the special
820         command string to be sent to the printer (mostly inside the PostScript
821         file) in order to enable it.
822         </para>
824         <para>
825         Information from these PPDs is meant to be taken into account by the
826         printer drivers. Therefore, installed as part of the Windows
827         PostScript driver for a given printer is the printer's PPD. Where it
828         makes sense, the PPD features are presented in the drivers' UI dialogs
829         to display to the user a choice of print options. In the end, the
830         user selections are somehow written (in the form of special
831         PostScript, PJL, JCL or vendor-dependent commands) into the PostScript
832         file created by the driver.
833         </para>
835         <warning><para>
836         <indexterm><primary>PDF</primary></indexterm>
837         A PostScript file that was created to contain device-specific commands
838         for achieving a certain print job output (e.g., duplex-ed, stapled and
839         punched) on a specific target machine, may not print as expected, or
840         may not be printable at all on other models; it also may not be fit
841         for further processing by software (e.g., by a PDF distilling program).
842         </para></warning>
843         </sect2>
845         <sect2>
846         <title>Using Windows-Formatted Vendor PPDs</title>
848         <para>
849         CUPS can handle all spec-compliant PPDs as supplied by the
850         manufacturers for their PostScript models. Even if a
851         vendor might not have mentioned our favorite
852         OS in his manuals and brochures, you can safely trust this:
853         <emphasis>If you get the Windows NT version of the PPD, you
854         can use it unchanged in CUPS</emphasis> and thus access the full
855         power of your printer just like a Windows NT user could!
856         </para>
858         <tip><para>
859         To check the spec compliance of any PPD online, go to <ulink
860         noescape="1" url="http://www.cups.org/testppd.php">http://www.cups.org/testppd.php</ulink>
861         and upload your PPD. You will see the results displayed
862         immediately. CUPS in all versions after 1.1.19 has a much more strict
863         internal PPD parsing and checking code enabled; in case of printing
864         trouble, this online resource should be one of your first pit-stops.
865         </para></tip>
867         <warning><para>
868         <indexterm><primary>foomatic</primary></indexterm>
869         <indexterm><primary>cupsomatic</primary></indexterm>
870         For real PostScript printers, <emphasis>do not</emphasis> use the
871         <emphasis>Foomatic</emphasis> or <emphasis>cupsomatic</emphasis>
872         PPDs from Linuxprinting.org. With these devices, the original
873         vendor-provided PPDs are always the first choice!
874         </para></warning>
876         <tip><para>
877         If you are looking for an original vendor-provided PPD of a specific
878         device, and you know that an NT4 box (or any other Windows box) on
879         your LAN has the PostScript driver installed, just use
880         <command>smbclient //NT4-box/print\$ -U username</command> to
881         access the Windows directory where all printer driver files are
882         stored. First look in the <filename>W32X86/2</filename> subdir for
883         the PPD you are seeking.
884         </para></tip>
885         </sect2>
887         <sect2>
888         <title>CUPS Also Uses PPDs for Non-PostScript Printers</title>
890         <para>
891         CUPS also uses specially crafted PPDs to handle non-PostScript
892         printers. These PPDs are usually not available from the vendors (and
893         no, you can't just take the PPD of a PostScript printer with the same
894         model name and hope it works for the non-PostScript version too). To
895         understand how these PPDs work for non-PS printers, we first need to
896         dive deeply into the CUPS filtering and file format conversion
897         architecture. Stay tuned.
898         </para>
899         </sect2>
900 </sect1>
902 <sect1>
903 <title>The CUPS Filtering Architecture</title>
905 <para>
906 The core of the CUPS filtering system is based on
907 Ghostscript. In addition to Ghostscript, CUPS
908 uses some other filters of its own. You (or your OS vendor) may have
909 plugged in even more filters. CUPS handles all data file formats under
910 the label of various MIME types. Every incoming
911 printfile is subjected to an initial
912 auto-typing. The auto-typing determines its given
913 MIME type. A given MIME type implies zero or more possible filtering
914 chains relevant to the selected target printer. This section discusses
915 how MIME types recognition and conversion rules interact. They are
916 used by CUPS to automatically setup a working filtering chain for any
917 given input data format.
918 </para>
920 <para>
921 If CUPS rasterizes a PostScript file natively to
922 a bitmap, this is done in two stages:
923 </para>
925 <itemizedlist>
926         <listitem><para>The first stage uses a Ghostscript device named <quote>cups</quote>
927 (this is since version 1.1.15) and produces a generic raster format
928 called <quote>CUPS raster</quote>.
929 </para></listitem>
931 <listitem><para>The second stage uses a <quote>raster driver</quote> that converts
932                 the generic CUPS raster to a device-specific raster.</para></listitem>
933 </itemizedlist>
935 <para>
936 Make sure your Ghostscript version has the <quote>cups</quote> device compiled in
937 (check with <command>gs -h | grep cups</command>). Otherwise you
938 may encounter the dreaded <computeroutput>Unable to convert file
939 0</computeroutput> in your CUPS error_log file. To have <quote>cups</quote> as a
940 device in your Ghostscript, you either need to patch GNU
941 Ghostscript and re-compile, or use <indexterm><primary>ESP</primary><secondary>Ghostscript</secondary></indexterm><ulink
942 url="http://www.cups.org/ghostscript.php">ESP Ghostscript</ulink>. The
943 superior alternative is ESP Ghostscript. It supports not just CUPS,
944 but 300 other devices too (while GNU Ghostscript supports only about
945 180). Because of this broad output device support, ESP Ghostscript is
946 the first choice for non-CUPS spoolers, too. It is now recommended by
947 Linuxprinting.org for all spoolers.
948 </para>
950 <para>
951 <indexterm><primary>cupsomatic</primary></indexterm>
952 <indexterm><primary>foomatic</primary></indexterm>
953 CUPS printers may be setup to use external rendering paths. One of the most common is provided by the
954 Foomatic/cupsomatic concept from <ulink url="http://www.linuxprinting.org/">Linuxprinting.org.</ulink> This
955 uses the classical Ghostscript approach, doing everything in one step. 
956 It does not use the <quote>cups</quote> device, but one of the many
957 others. However, even for Foomatic/cupsomatic usage, best results and
958 <indexterm><primary>ESP</primary><secondary>Ghostscript</secondary></indexterm>
959 broadest printer model support is provided by ESP Ghostscript (more
960 about cupsomatic/Foomatic, particularly the new version called now
961 <emphasis>foomatic-rip</emphasis>, follows below).
962 </para>
964 <sect2>
965 <title>MIME Types and CUPS Filters</title>
968 <para>
969 <indexterm><primary>MIME</primary><secondary>filters</secondary></indexterm>
970         <indexterm><primary>MIME</primary></indexterm>
971 CUPS reads the file <filename>/etc/cups/mime.types</filename>
972 (and all other files carrying a <filename>*.types</filename> suffix
973 in the same directory) upon startup. These files contain the MIME
974 type recognition rules that are applied when CUPS runs its
975 auto-typing routines. The rule syntax is explained in the man page
976 for <filename>mime.types</filename> and in the comments section of the
977 <filename>mime.types</filename> file itself. A simple rule reads
978 like this:
980 <indexterm><primary>application/pdf</primary></indexterm>
981 <programlisting>
982  application/pdf         pdf string(0,%PDF)
983 </programlisting>
985 This means if a filename has either a
986 <filename>.pdf</filename> suffix or if the magic
987 string <emphasis>%PDF</emphasis> is right at the
988 beginning of the file itself (offset 0 from the start), then it is
989 a PDF file (<parameter>application/pdf</parameter>).
990 Another rule is this: 
992 <programlisting>
993  application/postscript  ai eps ps string(0,%!) string(0,&lt;04&gt;%!)
994 </programlisting>
996 If the filename has one of the suffixes
997 <filename>.ai</filename>, <filename>.eps</filename>,
998 <filename>.ps</filename> or if the file itself starts with one of the
999 strings <emphasis>%!</emphasis> or <emphasis><![CDATA[<04>%!]]></emphasis>, it
1000 is a generic PostScript file
1001 (<parameter>application/postscript</parameter>).
1002 </para>
1004 <warning><para>
1005 Don't confuse the other mime.types files your system might be using
1006 with the one in the <filename>/etc/cups/</filename> directory.
1007 </para></warning>
1009 <note><para>
1010 There is an important difference between two similar MIME types in
1011 CUPS: one is <parameter>application/postscript</parameter>, the other is
1012 <parameter>application/vnd.cups-postscript</parameter>. While
1013 <parameter>application/postscript</parameter> is meant to be device
1014 independent (job options for the file are still outside the PS file
1015 content, embedded in command line or environment variables by CUPS),
1016 <parameter>application/vnd.cups-postscript</parameter> may have the job
1017 options inserted into the PostScript data itself (where
1018 applicable). The transformation of the generic PostScript
1019 (<parameter>application/postscript</parameter>) to the device-specific version
1020 (<parameter>application/vnd.cups-postscript</parameter>) is the responsibility of the
1021 CUPS <parameter>pstops</parameter> filter. pstops uses information
1022 contained in the PPD to do the transformation.
1023 </para></note>
1025 <para>
1026 CUPS can handle ASCII text, HP-GL, PDF, PostScript, DVI, and
1027 many image formats (GIF. PNG, TIFF, JPEG, Photo-CD, SUN-Raster,
1028 PNM, PBM, SGI-RGB, and more) and their associated MIME types
1029 with its filters.
1030 </para>
1031 </sect2>
1033 <sect2>
1034 <title>MIME Type Conversion Rules</title>
1037 <para>
1038 <indexterm><primary>MIME</primary></indexterm>
1039 <indexterm><primary>application/pdf</primary></indexterm>
1040 CUPS reads the file <filename>/etc/cups/mime.convs</filename>
1041 (and all other files named with a <filename>*.convs</filename>
1042 suffix in the same directory) upon startup. These files contain
1043 lines naming an input MIME type, an output MIME type, a format
1044 conversion filter that can produce the output from the input type
1045 and virtual costs associated with this conversion. One example line
1046 reads like this:
1048 <programlisting>
1049  application/pdf         application/postscript   33   pdftops
1050 </programlisting>
1052 This means that the <parameter>pdftops</parameter> filter will take
1053 <parameter>application/pdf</parameter> as input and produce
1054 <parameter>application/postscript</parameter> as output; the virtual
1055 cost of this operation is 33 CUPS-$. The next filter is more
1056 expensive, costing 66 CUPS-$:
1058 <indexterm><primary>pdf</primary></indexterm>
1060 <programlisting>
1061  application/vnd.hp-HPGL application/postscript   66   hpgltops
1062 </programlisting>
1064 This is the <parameter>hpgltops</parameter>, which processes HP-GL
1065 plotter files to PostScript.
1067 <indexterm><primary>application/octet-stream</primary></indexterm>
1069 <programlisting>
1070  application/octet-stream
1071 </programlisting>
1073 Here are two more examples: 
1075 <indexterm><primary>text/plain</primary></indexterm>
1077 <programlisting>
1078  application/x-shell     application/postscript   33    texttops
1079  text/plain              application/postscript   33    texttops
1080 </programlisting>
1082 The last two examples name the <parameter>texttops</parameter> filter
1083 to work on <parameter>text/plain</parameter> as well as on <parameter>application/x-shell</parameter>. (Hint:
1084 This differentiation is needed for the syntax highlighting feature of
1085 <parameter>texttops</parameter>).
1086 </para>
1087 </sect2>
1089 <sect2>
1090 <title>Filtering  Overview</title>
1093 <para>
1094 <indexterm><primary>MIME</primary></indexterm>
1095 There are many more combinations named in <filename>mime.convs</filename>. However, you
1096 are not limited to use the ones pre-defined there. You can plug in any
1097 filter you like into the CUPS framework. It must meet, or must be made
1098 to meet, some minimal requirements. If you find (or write) a cool
1099 conversion filter of some kind, make sure it complies to what CUPS
1100 needs and put in the right lines in <filename>mime.types</filename>
1101 and <filename>mime.convs</filename>, then it will work seamlessly
1102 inside CUPS.
1103 </para>
1105 <sect3>
1106 <title>Filter requirements</title>
1107 <para>
1108 The mentioned <quote>CUPS requirements</quote> for filters are simple. Take
1109 filenames or <filename>stdin</filename> as input and write to
1110 <filename>stdout</filename>. They should take these 5 or 6 arguments:
1111 <emphasis>printer job user title copies options [filename]</emphasis>
1112 </para>
1114 <variablelist>
1115 <varlistentry><term>Printer </term>
1116 <listitem><para>The name of the printer queue (normally this is the
1117 name of the filter being run).</para></listitem>
1118 </varlistentry>
1120 <varlistentry><term>job </term>
1121 <listitem><para>The numeric job ID for the job being
1122 printed.</para></listitem>
1123 </varlistentry>
1125 <varlistentry><term>user </term>
1126 <listitem><para>The string from the originating-user-name
1127 attribute.</para></listitem>
1128 </varlistentry>
1130 <varlistentry><term>title </term>
1131 <listitem><para>The string from the job-name attribute.</para></listitem>
1132 </varlistentry>
1134 <varlistentry><term>copies </term>
1135 <listitem><para>The numeric value from the number-copies
1136 attribute.</para></listitem>
1137 </varlistentry>
1139 <varlistentry><term>options </term>
1140 <listitem><para>The job options.</para></listitem>
1141 </varlistentry>
1143 <varlistentry><term>filename </term>
1144 <listitem><para>(Optionally) The print request file (if missing,
1145 filters expected data fed through <filename>stdin</filename>). In most
1146 cases, it is easy to write a simple wrapper script around existing
1147 filters to make them work with CUPS.</para></listitem>
1148 </varlistentry>
1149 </variablelist>
1150 </sect3>
1151 </sect2>
1153 <sect2>
1154 <title>Prefilters</title>
1157 <para>
1158 <indexterm><primary>PostScript</primary></indexterm>
1159 As previously stated, PostScript is the central file format to any UNIX-based
1160 printing system. From PostScript, CUPS generates raster data to feed
1161 non-PostScript printers.
1162 </para>
1164 <para>
1165 But what happens if you send one of the supported non-PS formats
1166 to print? Then CUPS runs <quote>pre-filters</quote> on these input formats to
1167 generate PostScript first. There are pre-filters to create PS from
1168 ASCII text, PDF, DVI, or HP-GL. The outcome of these filters is always
1169 of MIME type <parameter>application/postscript</parameter> (meaning that
1170 any device-specific print options are not yet embedded into the
1171 PostScript by CUPS, and that the next filter to be called is
1172 pstops). Another pre-filter is running on all supported image formats,
1173 the <parameter>imagetops</parameter> filter. Its outcome is always of
1174 MIME type <parameter>application/vnd.cups-postscript</parameter>
1175 (not application/postscript), meaning it has the
1176 print options already embedded into the file.
1177 </para>
1179 <para>
1180         <image>
1181                 <imagedescription>Pre-filtering in CUPS to form PostScript.</imagedescription>
1182                 <imagefile scale="25">4small</imagefile>
1183         </image>
1184 </para>
1185 </sect2>
1187 <sect2>
1188 <title>pstops</title>
1190 <para>
1191 <emphasis>pstops</emphasis> is the filter to convert
1192 <parameter>application/postscript</parameter> to <?latex \linebreak ?>
1193 <parameter>application/vnd.cups-postscript</parameter>. It was said
1194 above that this filter inserts all device-specific print options
1195 (commands to the printer to ask for the duplexing of output, or
1196 stapling and punching it, and so on) into the PostScript file.
1197 </para>
1199 <para>
1200         <image><imagedescription>Adding device-specific print options.</imagedescription>
1201                 <imagefile scale="25">5small</imagefile>
1202         </image>
1203 </para>
1205 <para>
1206 This is not all. Other tasks performed by it are:
1207 </para>
1209 <itemizedlist>
1210 <listitem><para>
1211 Selecting the range of pages to be printed (if you choose to
1212 print only pages <quote>3, 6, 8-11, 16, 19-21</quote>, or only the odd numbered
1213 ones).
1214 </para></listitem>
1216 <listitem><para>
1217 Putting 2 or more logical pages on one sheet of paper (the
1218 so-called <quote>number-up</quote> function).
1219 </para></listitem>
1221 <listitem><para>Counting the pages of the job to insert the accounting
1222 information into the <filename>/var/log/cups/page_log</filename>.
1223 </para></listitem>
1224 </itemizedlist>
1225 </sect2>
1227 <sect2>
1228 <title>pstoraster</title>
1230 <para>
1231 <parameter>pstoraster</parameter> is at the core of the CUPS filtering
1232 system. It is responsible for the first stage of the rasterization
1233 process. Its input is of MIME type application/vnd.cups-postscript;
1234 its output is application/vnd.cups-raster. This output format is not
1235 yet meant to be printable. Its aim is to serve as a general purpose
1236 input format for more specialized <emphasis>raster drivers</emphasis>
1237 that are able to generate device-specific printer data.
1238 </para>
1240 <para>
1241         <image>
1242                 <imagedescription>PostScript to intermediate raster format.</imagedescription>
1243                 <imagefile scale="25">6small</imagefile>
1244         </image>
1245 </para>
1247 <para>
1248 CUPS raster is a generic raster format with powerful features. It is
1249 able to include per-page information, color profiles, and more, to be
1250 used by the following downstream raster drivers. Its MIME type is
1251 registered with IANA and its specification is, of course, completely
1252 open. It is designed to make it quite easy and inexpensive for
1253 manufacturers to develop Linux and UNIX raster drivers for their
1254 printer models, should they choose to do so. CUPS always takes care
1255 for the first stage of rasterization so these vendors do not need to care
1256 about Ghostscript complications (in fact, there is currently more
1257 than one vendor financing the development of CUPS raster drivers).
1258 </para>
1260 <para>
1261         <image>
1262                 <imagedescription>CUPS-raster production using Ghostscript.</imagedescription>
1263                 <imagefile>7small</imagefile>
1264         </image>
1265 </para>
1267 <para>
1268 CUPS versions before version 1.1.15 were shipping a binary (or source
1269 code) standalone filter, named <parameter>pstoraster</parameter>. <parameter>pstoraster</parameter> was derived
1270 from GNU Ghostscript 5.50, and could be installed besides and in
1271 addition to any GNU or AFPL Ghostscript package without conflicting.
1272 </para>
1274 <para>
1275 >From version 1.1.15, this has changed. The functions for this have been
1276 integrated back into Ghostscript (now based on GNU Ghostscript version
1277 7.05). The <parameter>pstoraster</parameter> filter is now a simple shell script calling
1278 <command>gs</command> with the <command>-sDEVICE=cups</command>
1279 parameter. If your Ghostscript does not show a success on asking for
1280 <command>gs -h |grep cups</command>, you might not be able to
1281 print. Update your Ghostscript.
1282 </para>
1283 </sect2>
1285 <sect2>
1286 <title>imagetops and imagetoraster</title>
1288 <para>
1289 In the section about pre-filters, we mentioned the pre-filter
1290 that generates PostScript from image formats. The <parameter>imagetoraster</parameter>
1291 filter is used to convert directly from image to raster, without the
1292 intermediate PostScript stage. It is used more often than the above
1293 mentioned pre-filters. We summarize flowchart of image file
1294 filtering on <link linkend="small8">next picture</link>.
1295 </para>
1297 <para>
1298         <image id="small8">
1299                 <imagedescription>Image format to CUPS-raster format conversion.</imagedescription>
1300                 <imagefile>8small</imagefile>
1301         </image>
1302 </para>
1304 </sect2>
1306 <sect2>
1307 <title>rasterto [printers specific]</title>
1309 <para>
1310 CUPS ships with quite different raster drivers processing CUPS
1311 raster. On my system I find in /usr/lib/cups/filter/ these:
1312 <parameter>rastertoalps</parameter>, <parameter>rastertobj</parameter>, <parameter>rastertoepson</parameter>, <parameter>rastertoescp</parameter>,
1313 <parameter>rastertopcl</parameter>, <parameter>rastertoturboprint</parameter>, <parameter>rastertoapdk</parameter>, <parameter>rastertodymo</parameter>,
1314 <parameter>rastertoescp</parameter>, <parameter>rastertohp</parameter>, and
1315 <parameter>rastertoprinter</parameter>. Don't worry if you have less
1316 than this; some of these are installed by commercial add-ons to CUPS
1317 (like <parameter>rastertoturboprint</parameter>), others (like
1318 <parameter>rastertoprinter</parameter>) by third-party driver
1319 development projects (such as Gimp-Print) wanting to cooperate as
1320 closely as possible with CUPS.
1321 </para>
1323 <para>
1324         <image id="small9">
1325                 <imagedescription>Raster to printer-specific formats.</imagedescription>
1326                 <imagefile>9small</imagefile>
1327         </image>
1328 </para>
1329 </sect2>
1331 <sect2>
1332 <title>CUPS Backends</title>
1334 <para>
1335 The last part of any CUPS filtering chain is a backend. Backends
1336 are special programs that send the print-ready file to the final
1337 device. There is a separate backend program for any transfer
1338 protocol of sending print jobs over the network, or for every local
1339 interface. Every CUPS print queue needs to have a CUPS <quote>device-URI</quote>
1340 associated with it. The device URI is the way to encode the backend
1341 used to send the job to its destination. Network device-URIs are using
1342 two slashes in their syntax, local device URIs only one, as you can
1343 see from the following list. Keep in mind that local interface names
1344 may vary much from my examples, if your OS is not Linux:
1345 </para>
1347 <variablelist>
1348         <varlistentry><term>usb </term>
1349         <listitem><para>
1350         This backend sends print files to USB-connected printers. An
1351         example for the CUPS device-URI to use is:
1352         <filename>usb:/dev/usb/lp0</filename>.
1353         </para></listitem></varlistentry>
1355         <varlistentry><term>serial </term>
1356         <listitem><para>
1357         This backend sends print files to serially connected printers.
1358         An example for the CUPS device-URI to use is:
1359         <filename>serial:/dev/ttyS0?baud=11500</filename>.
1360         </para></listitem></varlistentry>
1362         <varlistentry><term>parallel </term>
1363         <listitem><para>
1364         This backend sends print files to printers connected to the
1365         parallel port. An example for the CUPS device-URI to use is:
1366         <filename>parallel:/dev/lp0</filename>.
1367         </para></listitem></varlistentry>
1369         <varlistentry><term>SCSI </term>
1370         <listitem><para>
1371         This backend sends print files to printers attached to the
1372         SCSI interface. An example for the CUPS device-URI to use is:
1373         <filename>scsi:/dev/sr1</filename>.
1374         </para></listitem></varlistentry>
1376         <varlistentry><term>lpd </term>
1377         <listitem><para>
1378         This backend sends print files to LPR/LPD connected network
1379         printers. An example for the CUPS device-URI to use is:
1380         <filename>lpd://remote_host_name/remote_queue_name</filename>.
1381         </para></listitem></varlistentry>
1383         <varlistentry><term>AppSocket/HP JetDirect </term>
1384         <listitem><para>
1385         This backend sends print files to AppSocket (a.k.a. "HP
1386         JetDirect") connected network printers. An example for the CUPS
1387         device-URI to use is:
1388         <filename>socket://10.11.12.13:9100</filename>.
1389         </para></listitem></varlistentry>
1391         <varlistentry><term>ipp </term>
1392         <listitem><para>
1393         This backend sends print files to IPP connected network
1394         printers (or to other CUPS servers). Examples for CUPS device-URIs
1395         to use are:
1396         <filename>ipp:://192.193.194.195/ipp</filename>
1397         (for many HP printers) or
1398         <filename>ipp://remote_cups_server/printers/remote_printer_name</filename>.
1399         </para></listitem></varlistentry>
1401         <varlistentry><term>http </term>
1402         <listitem><para>
1403         This backend sends print files to HTTP connected printers.
1404         (The http:// CUPS backend is only a symlink to the ipp:// backend.)
1405         Examples for the CUPS device-URIs to use are:
1406         <filename>http:://192.193.194.195:631/ipp</filename>
1407         (for many HP printers) or
1408         <filename>http://remote_cups_server:631/printers/remote_printer_name</filename>.
1409         </para></listitem></varlistentry>
1411         <varlistentry><term>smb </term>
1412         <listitem><para>
1413         This backend sends print files to printers shared by a Windows
1414         host. An example for CUPS device-URIs that may be used includes:
1415         </para>
1417         <para>
1418         <simplelist>
1419         <member><filename>smb://workgroup/server/printersharename</filename></member>
1420         <member><filename>smb://server/printersharename</filename></member>
1421         <member><filename>smb://username:password@workgroup/server/printersharename</filename></member>
1422         <member><filename>smb://username:password@server/printersharename</filename></member>
1423         </simplelist>
1424         </para>
1426         <para>
1427         The smb:// backend is a symlink to the Samba utility
1428         <parameter>smbspool</parameter> (does not ship with CUPS). If the
1429         symlink is not present in your CUPS backend directory, have your
1430         root user create it: <command>ln -s `which smbspool'
1431         /usr/lib/cups/backend/smb</command>.
1432         </para></listitem></varlistentry>
1433 </variablelist>
1435 <para>
1436 It is easy to write your own backends as shell or Perl scripts, if you
1437 need any modification or extension to the CUPS print system. One
1438 reason could be that you want to create <quote>special</quote> printers that send
1439 the print-jobs as email (through a <quote>mailto:/</quote> backend), convert them to
1440 PDF (through a <quote>pdfgen:/</quote> backend) or dump them to <quote>/dev/null</quote>. (In
1441 fact I have the system-wide default printer set up to be connected to
1442 a devnull:/ backend: there are just too many people sending jobs
1443 without specifying a printer, or scripts and programs which do not name
1444 a printer. The system-wide default deletes the job and sends a polite
1445 email back to the $USER asking him to always specify the correct
1446 printer name.)
1447 </para>
1449 <para>
1450 Not all of the mentioned backends may be present on your system or
1451 usable (depending on your hardware configuration). One test for all
1452 available CUPS backends is provided by the <emphasis>lpinfo</emphasis>
1453 utility. Used with the <option>-v</option> parameter, it lists
1454 all available backends:
1455 </para>
1457 <para><screen>
1458 &prompt;<userinput>lpinfo -v</userinput>
1459 </screen></para>
1460 </sect2>
1462 <sect2>
1463 <title>The Role of <parameter>cupsomatic/foomatic</parameter></title>
1465 <para>
1466 <indexterm><primary>cupsomatic</primary></indexterm>
1467 <indexterm><primary>foomatic</primary></indexterm>
1468 <parameter>cupsomatic</parameter> filters may be the most widely used on CUPS
1469 installations. You must be clear about the fact that these were not
1470 developed by the CUPS people. They are a third party add-on to
1471 CUPS. They utilize the traditional Ghostscript devices to render jobs
1472 for CUPS. When troubleshooting, you should know about the
1473 difference. Here the whole rendering process is done in one stage,
1474 inside Ghostscript, using an appropriate device for the target
1475 printer. <parameter>cupsomatic</parameter> uses PPDs that are generated from the Foomatic
1476 Printer &amp; Driver Database at Linuxprinting.org.
1477 </para>
1479 <para>
1480 You can recognize these PPDs from the line calling the
1481 <parameter>cupsomatic</parameter> filter:
1483 <programlisting>
1484  *cupsFilter: "application/vnd.cups-postscript  0  cupsomatic"
1485 </programlisting>
1487 You may find this line among the first 40 or so lines of the PPD
1488 file. If you have such a PPD installed, the printer shows up in the
1489 CUPS Web interface with a <parameter>foomatic</parameter> namepart for
1490 the driver description. <parameter>cupsomatic</parameter> is a Perl script that runs
1491 Ghostscript with all the complicated command line options
1492 auto-constructed from the selected PPD and command line options give to
1493 the print-job.
1494 </para>
1496 <para>
1497 <indexterm><primary>point 'n' print</primary></indexterm>
1498         However, <parameter>cupsomatic</parameter> is now deprecated. Its PPDs (especially the first
1499 generation of them, still in heavy use out there) are not meeting the
1500 Adobe specifications. You might also suffer difficulties when you try
1501 to download them with <quote>Point'n'Print</quote> to Windows clients. A better
1502 and more powerful successor is now in a stable beta-version: it is called <parameter>foomatic-rip</parameter>. To use
1503 <parameter>foomatic-rip</parameter> as a filter with CUPS, you need the new-type PPDs. These
1504 have a similar but different line:
1506 <programlisting>
1507  *cupsFilter: "application/vnd.cups-postscript  0  foomatic-rip"
1508 </programlisting>
1510 The PPD generating engine at Linuxprinting.org has been revamped.
1511 The new PPDs comply to the Adobe spec. On top, they also provide a
1512 new way to specify different quality levels (hi-res photo, normal
1513 color, grayscale, and draft) with a single click, whereas before you
1514 could have required five or more different selections (media type,
1515 resolution, inktype and dithering algorithm). There is support for
1516 custom-size media built in. There is support to switch
1517 print-options from page to page in the middle of a job. And the
1518 best thing is the new foomatic-rip now works seamlessly with all
1519 legacy spoolers too (like LPRng, BSD-LPD, PDQ, PPR and so on), providing
1520 for them access to use PPDs for their printing.
1521 </para>
1522 </sect2>
1524 <sect2>
1525 <title>The Complete Picture</title>
1527 <para>
1528 If you want to see an overview of all the filters and how they
1529 relate to each other, the complete picture of the puzzle is at the end
1530 of this document.
1531 </para>
1532 </sect2>
1534 <sect2>
1535 <title><filename>mime.convs</filename></title>
1537 <para>
1538 CUPS auto-constructs all possible filtering chain paths for any given
1539 MIME type, and every printer installed. But how does it decide in
1540 favor or against a specific alternative?  (There may often be cases
1541 where there is a choice of two or more possible filtering chains for
1542 the same target printer.) Simple. You may have noticed the figures in
1543 the third column of the mime.convs file. They represent virtual costs
1544 assigned to this filter. Every possible filtering chain will sum up to
1545 a total <quote>filter cost.</quote> CUPS decides for the most <quote>inexpensive</quote> route.
1546 </para>
1548 <tip><para>
1549 The setting of <parameter>FilterLimit 1000</parameter> in
1550 <filename>cupsd.conf</filename> will not allow more filters to
1551 run concurrently than will consume a total of 1000 virtual filter
1552 cost. This is an efficient way to limit the load of any CUPS
1553 server by setting an appropriate <quote>FilterLimit</quote> value. A FilterLimit of
1554 200 allows roughly one job at a time, while a FilterLimit of 1000 allows
1555 approximately five jobs maximum at a time.
1556 </para></tip>
1557 </sect2>
1559 <sect2>
1560         <title><quote>Raw</quote> Printing</title>
1562 <para>
1563         You can tell CUPS to print (nearly) any file <quote>raw</quote>. <quote>Raw</quote> means it
1564         will not be filtered. CUPS will send the file to the printer <quote>as is</quote>
1565 without bothering if the printer is able to digest it. Users need to
1566 take care themselves that they send sensible data formats only. Raw
1567 printing can happen on any queue if the <quote><parameter>-o raw</parameter></quote> option is specified
1568 on the command line. You can also set up raw-only queues by simply not
1569 associating any PPD with it. This command:
1570 </para>
1572 <para><screen>
1573 &prompt;<userinput>lpadmin -P rawprinter -v socket://11.12.13.14:9100 -E</userinput>
1574 </screen></para>
1576 <para>
1577         sets up a queue named <quote>rawprinter</quote>, connected via the <quote>socket</quote>
1578         protocol (a.k.a. <quote>HP JetDirect</quote>) to the device at IP address
1579 11.12.1.3.14, using port 9100. (If you had added a PPD with
1580 <command>-P /path/to/PPD</command> to this command line, you would
1581 have installed a <quote>normal</quote> print queue.
1582 </para>
1584 <para>
1585 CUPS will automatically treat each job sent to a queue as a <quote>raw</quote> one,
1586 if it can't find a PPD associated with the queue. However, CUPS will
1587 only send known MIME types (as defined in its own mime.types file) and
1588 refuse others.
1589 </para>
1590 </sect2>
1592 <sect2>
1593 <title>application/octet-stream Printing</title>
1595 <para>
1596 Any MIME type with no rule in the
1597 <filename>/etc/cups/mime.types</filename> file is regarded as unknown
1598 or <parameter>application/octet-stream</parameter> and will not be
1599 sent. Because CUPS refuses to print unknown MIME types per default,
1600 you will probably have experienced the fact that print jobs originating
1601 from Windows clients were not printed. You may have found an error
1602 message in your CUPS logs like:
1603 </para>
1605 <para><computeroutput>
1606  Unable to convert file 0 to printable format for job
1607 </computeroutput></para>
1609 <para>
1610 To enable the printing of <parameter>application/octet-stream</parameter> files, edit
1611 these two files:
1612 </para>
1614 <itemizedlist>
1615 <listitem><para><filename>/etc/cups/mime.convs</filename></para></listitem>
1617 <listitem><para><filename>/etc/cups/mime.types</filename></para></listitem>
1618 </itemizedlist>
1620 <para>
1621 Both contain entries (at the end of the respective files) which must
1622 be uncommented to allow RAW mode operation for
1623 <parameter>application/octet-stream</parameter>. In <filename>/etc/cups/mime.types</filename>
1624 make sure this line is present:
1626 <indexterm><primary>application/octet-stream</primary></indexterm>
1628 <programlisting>
1629 application/octet-stream
1630 </programlisting>
1632 This line (with no specific auto-typing rule set) makes all files
1633 not otherwise auto-typed a member of <parameter>application/octet-stream</parameter>. In
1634 <filename>/etc/cups/mime.convs</filename>, have this
1635 line: 
1637 <programlisting>
1638 application/octet-stream   application/vnd.cups-raw   0   -
1639 </programlisting>
1641 <indexterm><primary>MIME</primary></indexterm>
1643 This line tells CUPS to use the <emphasis>Null Filter</emphasis>
1644 (denoted as <quote>-</quote>, doing nothing at all) on
1645 <parameter>application/octet-stream</parameter>, and tag the result as
1646 <parameter>application/vnd.cups-raw</parameter>. This last one is
1647 always a green light to the CUPS scheduler to now hand the file over
1648 to the backend connecting to the printer and sending it over.
1649 </para>
1651 <note><para>Editing the <filename>mime.convs</filename> and the
1652 <filename>mime.types</filename> file does not
1653 <emphasis>enforce</emphasis> <quote>raw</quote> printing, it only
1654 <emphasis>allows</emphasis> it.
1655 </para></note>
1657 <formalpara>
1658 <title>Background</title>
1660 <para>
1661 CUPS being a more security-aware printing system than traditional ones
1662 does not by default allow one to send deliberate (possibly binary)
1663 data to printing devices. (This could be easily abused to launch a
1664 Denial of Service attack on your printer(s), causing at least the loss
1665 of a lot of paper and ink...) <quote>Unknown</quote> data are regarded by CUPS
1666 as <emphasis>MIME type</emphasis>
1667 <emphasis>application/octet-stream</emphasis>. While you
1668 <emphasis>can</emphasis> send data <quote>raw</quote>, the MIME type for these must
1669 be one that is known to CUPS and an allowed one. The file
1670 <filename>/etc/cups/mime.types</filename> defines the <quote>rules</quote> of how CUPS
1671 recognizes MIME types. The file
1672 <filename>/etc/cups/mime.convs</filename> decides which file
1673 conversion filter(s) may be applied to which MIME types.
1674 </para>
1675 </formalpara>
1676 </sect2>
1678 <sect2>
1679 <title>PostScript Printer Descriptions (PPDs) for Non-PS Printers</title>
1682 <para>
1683 <indexterm><primary>PPD</primary></indexterm>
1684 Originally PPDs were meant to be used for PostScript printers
1685 only. Here, they help to send device-specific commands and settings
1686 to the RIP which processes the job file. CUPS has extended this
1687 scope for PPDs to cover non-PostScript printers too. This was not
1688 difficult, because it is a standardized file format. In a way
1689 it was logical too: CUPS handles PostScript and uses a PostScript
1690 RIP (Ghostscript) to process the job files. The only difference is:
1691 a PostScript printer has the RIP built-in, for other types of
1692 printers the Ghostscript RIP runs on the host computer.
1693 </para>
1695 <para>
1696 PPDs for a non-PS printer have a few lines that are unique to
1697 CUPS. The most important one looks similar to this:
1699 <indexterm><primary>application/vnd.cups-raster</primary></indexterm>
1701 <programlisting>
1702  *cupsFilter: application/vnd.cups-raster  66   rastertoprinter
1703 </programlisting>
1705 It is the last piece in the CUPS filtering puzzle. This line tells the
1706 CUPS daemon to use as a last filter <parameter>rastertoprinter</parameter>. This filter
1707 should be served as input an <parameter>application/vnd.cups-raster</parameter> MIME type
1708 file. Therefore, CUPS should auto-construct a filtering chain, which
1709 delivers as its last output the specified MIME type. This is then
1710 taken as input to the specified <parameter>rastertoprinter</parameter> filter. After this
1711 the last filter has done its work (<parameter>rastertoprinter</parameter> is a Gimp-Print
1712 filter), the file should go to the backend, which sends it to the
1713 output device.
1714 </para>
1716 <para>
1717 CUPS by default ships only a few generic PPDs, but they are good for
1718 several hundred printer models. You may not be able to control
1719 different paper trays, or you may get larger margins than your
1720 specific model supports. See <link linkend="cups-ppds">PPDs shipped with CUPS</link> for summary information.
1721 </para>
1723 <table frame="all" id="cups-ppds">
1724         <title>PPDs shipped with CUPS</title>
1725         <tgroup cols="2" align="left">
1726                 <colspec align="left"/>
1727                 <colspec align="justify" colwidth="1*"/>
1728                 <thead><row><entry>PPD file</entry><entry>Printer type</entry></row></thead>
1729                 <tbody>
1730                 <row><entry>deskjet.ppd</entry><entry>older HP inkjet printers and compatible</entry></row>
1732                 <row><entry>deskjet2.ppd</entry> <entry>newer HP inkjet printers and compatible </entry> </row>
1734                 <row><entry>dymo.ppd</entry> <entry>label printers </entry> </row>
1736                 <row><entry>epson9.ppd</entry> <entry>Epson 24pin impact printers and compatible </entry> </row>
1738                 <row><entry>epson24.ppd</entry> <entry>Epson 24pin impact printers and compatible </entry> </row>
1740                 <row><entry>okidata9.ppd</entry> <entry>Okidata 9pin impact printers and compatible </entry> </row>
1742                 <row><entry>okidat24.ppd</entry> <entry>Okidata 24pin impact printers and compatible </entry> </row>
1744                 <row><entry>stcolor.ppd</entry> <entry>older Epson Stylus Color printers </entry> </row>
1746                 <row><entry>stcolor2.ppd</entry> <entry>newer Epson Stylus Color printers </entry> </row>
1748                 <row><entry>stphoto.ppd</entry> <entry>older Epson Stylus Photo printers </entry> </row>
1750                 <row><entry>stphoto2.ppd</entry> <entry>newer Epson Stylus Photo printers </entry> </row>
1752                 <row><entry>laserjet.ppd</entry> <entry>all PCL printers. Further below is a discussion
1753                         of several other driver/PPD-packages suitable for use with CUPS. </entry> </row>
1755                 </tbody>
1756         </tgroup>
1757 </table>
1759 </sect2>
1761 <sect2>
1762 <title><emphasis>cupsomatic/foomatic-rip</emphasis> Versus <emphasis>native CUPS</emphasis> Printing</title>
1765 <para>
1766 <indexterm><primary>cupsomatic</primary></indexterm>
1767 <indexterm><primary>foomatic-rip</primary></indexterm>
1768 Native CUPS rasterization works in two steps:
1769 </para>
1771 <itemizedlist>
1772 <listitem><para>
1773 First is the <parameter>pstoraster</parameter> step. It uses the special CUPS
1774 <indexterm><primary>ESP</primary><secondary>Ghostscript</secondary></indexterm>
1775 device from ESP Ghostscript 7.05.x as its tool.
1776 </para></listitem>
1778 <listitem><para>
1779 Second comes the <parameter>rasterdriver</parameter> step. It uses various
1780 device-specific filters; there are several vendors who provide good
1781 quality filters for this step. Some are free software, some are
1782 shareware/non-free and some are proprietary.</para></listitem>
1783 </itemizedlist>
1785 <para>
1786 Often this produces better quality (and has several more
1787 advantages) than other methods.
1788 </para>
1790 <para>
1791         <image id="cupsomatic-dia">
1792                 <imagedescription>cupsomatic/foomatic Processing versus Native CUPS.</imagedescription>
1793                 <imagefile>10small</imagefile>
1794         </image>
1795 </para>
1797 <para>
1798 One other method is the <parameter>cupsomatic/foomatic-rip</parameter>
1799 way. Note that <parameter>cupsomatic</parameter> is <emphasis>not</emphasis> made by the CUPS
1800 developers. It is an independent contribution to printing development,
1801 made by people from Linuxprinting.org <footnote><para>see also <ulink
1802 noescape="1" url="http://www.cups.org/cups-help.html">http://www.cups.org/cups-help.html</ulink></para></footnote>.
1803 <parameter>cupsomatic</parameter> is no longer developed and maintained and is no longer
1804 supported. It has now been replaced by
1805 <parameter>foomatic-rip</parameter>. <parameter>foomatic-rip</parameter> is a complete re-write
1806 of the old <parameter>cupsomatic</parameter> idea, but very much improved and generalized to
1807 other (non-CUPS) spoolers. An upgrade to foomatic-rip is strongly
1808 advised, especially if you are upgrading to a recent version of CUPS,
1809 too.
1810 </para>
1812 <para>
1813         <indexterm><primary>cupsomatic</primary></indexterm>
1814         <indexterm><primary>foomatic</primary></indexterm>
1815 Both the <parameter>cupsomatic</parameter> (old) and the <parameter>foomatic-rip</parameter> (new) methods from
1816 Linuxprinting.org use the traditional Ghostscript print file
1817 processing, doing everything in a single step. It therefore relies on
1818 all the other devices built into Ghostscript. The quality is as
1819 good (or bad) as Ghostscript rendering is in other spoolers. The
1820 advantage is that this method supports many printer models not
1821 supported (yet) by the more modern CUPS method.
1822 </para>
1824 <para>
1825 Of course, you can use both methods side by side on one system (and
1826 even for one printer, if you set up different queues) and find out
1827 which works best for you.
1828 </para>
1830 <para>
1831 <parameter>cupsomatic</parameter> kidnaps the printfile after the
1832 <parameter>application/vnd.cups-postscript</parameter> stage and
1833 deviates it through the CUPS-external, system-wide Ghostscript
1834 installation. Therefore the printfile bypasses the <parameter>pstoraster</parameter> filter
1835 (and also bypasses the CUPS-raster-drivers
1836 <parameter>rastertosomething</parameter>). After Ghostscript finished its rasterization,
1837 <parameter>cupsomatic</parameter> hands the rendered file directly to the CUPS backend. The
1838 flowchart in <link linkend="cupsomatic-dia">cupsomatic/foomatic processing versus Native CUPS</link> illustrates the difference between native CUPS
1839 rendering and the <parameter>Foomatic/cupsomatic</parameter> method.
1840 </para>
1841 </sect2>
1843 <sect2>
1844 <title>Examples for Filtering Chains</title>
1846 <para>
1847 Here are a few examples of commonly occurring filtering chains to
1848 illustrate the workings of CUPS.
1849 </para>
1851 <para>
1852 Assume you want to print a PDF file to an HP JetDirect-connected
1853 PostScript printer, but you want to print the pages 3-5, 7, 11-13
1854 only, and you want to print them <quote>two-up</quote> and <quote>duplex</quote>:
1855 </para>
1857 <itemizedlist>
1858 <listitem><para>Your print options (page selection as required, two-up,
1859 duplex) are passed to CUPS on the command line.</para></listitem>
1861 <listitem><para>The (complete) PDF file is sent to CUPS and auto-typed as
1862 <parameter>application/pdf</parameter>.</para></listitem>
1864 <listitem><para>The file therefore must first pass the
1865 <parameter>pdftops</parameter> pre-filter, which produces PostScript
1866 MIME type <parameter>application/postscript</parameter> (a preview here
1867 would still show all pages of the original PDF).</para></listitem>
1869 <listitem><para>The file then passes the <parameter>pstops</parameter>
1870 filter that applies the command line options: it selects the pages
1871 2-5, 7 and 11-13, creates an imposed layout <quote>2 pages on 1 sheet</quote> and
1872 inserts the correct <quote>duplex</quote> command (as defined in the printer's
1873 PPD) into the new PostScript file; the file is now of PostScript MIME
1874 type
1875 <parameter>application/vnd.cups-postscript</parameter>.</para></listitem>
1877 <listitem><para>The file goes to the <parameter>socket</parameter>
1878 backend, which transfers the job to the printers.</para></listitem>
1879 </itemizedlist>
1881 <para>
1882         The resulting filter chain, therefore, is as drawn in <link linkend="pdftosocket">PDF to socket chain</link>.
1883         <image id="pdftosocket">
1884                 <imagedescription>PDF to socket chain.</imagedescription>
1885                 <imagefile>pdftosocket</imagefile>
1886         </image>
1887 </para>
1890 <para>
1891 Assume you want to print the same filter to an USB-connected
1892 Epson Stylus Photo printer installed with the CUPS
1893 <filename>stphoto2.ppd</filename>. The first few filtering stages
1894 are nearly the same:
1895 </para>
1897 <itemizedlist>
1898 <listitem><para>Your print options (page selection as required, two-up,
1899 duplex) are passed to CUPS on the command-line.</para></listitem>
1901 <listitem><para>The (complete) PDF file is sent to CUPS and auto-typed as
1902 <parameter>application/pdf</parameter>.</para></listitem>
1904 <listitem><para>The file must first pass the
1905 <parameter>pdftops</parameter> pre-filter, which produces PostScript
1906 MIME type <parameter>application/postscript</parameter> (a preview here
1907 would still show all pages of the original PDF).</para></listitem>
1909 <listitem><para>The file then passes the <quote>pstops</quote> filter that applies
1910 the command-line options: it selects the pages 2-5, 7 and 11-13,
1911 creates an imposed layout <quote>two pages on one sheet</quote> and inserts the
1912 correct <quote>duplex</quote> command... (Oops &smbmdash; this printer and PPD
1913 do not support duplex printing at all &smbmdash; so this option will
1914 be ignored) into the new PostScript file; the file is now of PostScript
1915 MIME type 
1916 <parameter>application/vnd.cups-postscript</parameter>.</para></listitem>
1918 <listitem><para>The file then passes the
1919                 <!--FIXME-->
1920 <parameter>pstoraster</parameter> stage and becomes MIME type
1921 <parameter>application/
1922 cups-raster</parameter>.</para></listitem>
1924 <listitem><para>Finally, the <parameter>rastertoepson</parameter> filter
1925 does its work (as indicated in the printer's PPD), creating the
1926 printer-specific raster data and embedding any user-selected
1927 print-options into the print data stream.</para></listitem>
1929 <listitem><para>The file goes to the <parameter>usb</parameter> backend,
1930 which transfers the job to the printers.</para></listitem>
1931 </itemizedlist>
1933 <para>
1934 The resulting filter chain therefore is as drawn in <link linkend="pdftoepsonusb">this figure</link>.
1935 </para>
1937 <image id="pdftoepsonusb">
1938         <imagedescription>PDF to USB chain.</imagedescription>
1939         <imagefile>pdftoepsonusb</imagefile>
1940 </image>
1941 </sect2>
1943 <sect2>
1944 <title>Sources of CUPS Drivers/PPDs</title>
1946 <para>
1947 On the Internet you can now find many thousands of CUPS-PPD files
1948 (with their companion filters), in many national languages
1949 supporting more than thousand non-PostScript models.
1950 </para>
1952 <itemizedlist>
1953 <indexterm><primary>ESP</primary><secondary>Print Pro</secondary></indexterm>
1954 <indexterm><primary>PrintPro</primary><see>ESP Print Pro</see></indexterm>
1955 <listitem><para><ulink url="http://wwwl.easysw.com/printpro/">ESP
1956 PrintPro</ulink> (commercial,
1957 non-free) is packaged with more than three thousand PPDs, ready for
1958 successful use <quote>out of the box</quote> on Linux, Mac OS X, IBM-AIX,
1959 HP-UX, Sun-Solaris, SGI-IRIX, Compaq Tru64, Digital UNIX, and some
1960 more commercial Unices (it is written by the CUPS developers
1961 themselves and its sales help finance the further development of
1962 CUPS, as they feed their creators).</para></listitem>
1964 <listitem><para>The <ulink
1965 url="http://gimp-print.sourceforge.net/">Gimp-Print-Project
1966 </ulink> (GPL, free software)
1967 provides around 140 PPDs (supporting nearly 400 printers, many driven
1968 to photo quality output), to be used alongside the Gimp-Print CUPS
1969 filters.</para></listitem>
1971 <listitem><para><ulink url="http://www.turboprint.com/">TurboPrint
1972 </ulink> (shareware, non-free) supports
1973 roughly the same amount of printers in excellent
1974 quality.</para></listitem>
1976 <listitem><para><ulink
1977 url="http://www-124.ibm.com/developerworks/oss/linux/projects/omni/">OMNI
1978 </ulink>
1979 (LPGL, free) is a package made by IBM, now containing support for more
1980 than 400 printers, stemming from the inheritance of IBM OS/2 Know-How
1981 ported over to Linux (CUPS support is in a beta-stage at
1982 present).</para></listitem>
1984 <listitem><para><ulink url="http://hpinkjet.sourceforge.net/">HPIJS
1985 </ulink> (BSD-style licenses, free)
1986 supports around 150 of HP's own printers and is also providing
1987 excellent print quality now (currently available only via the Foomatic
1988 path).</para></listitem>
1990 <listitem><para><ulink url="http://www.linuxprinting.org/">Foomatic/cupsomatic
1991 </ulink> (LPGL, free) from Linuxprinting.org are providing PPDs for practically every Ghostscript
1992 filter known to the world (including Omni, Gimp-Print and HPIJS).</para></listitem>
1993 </itemizedlist>
1995 </sect2>
1997 <sect2>
1998 <title>Printing with Interface Scripts</title>
2000 <para>
2001 CUPS also supports the usage of <quote>interface scripts</quote> as known from
2002 System V AT&amp;T printing systems. These are often used for PCL
2003 printers, from applications that generate PCL print jobs. Interface
2004 scripts are specific to printer models. They have a similar role as
2005 PPDs for PostScript printers. Interface scripts may inject the Escape
2006 sequences as required into the print data stream, if the user has
2007 chosen to select a certain paper tray, or print landscape, or use A3
2008 paper, etc. Interfaces scripts are practically unknown in the Linux
2009 realm. On HP-UX platforms they are more often used. You can use any
2010 working interface script on CUPS too. Just install the printer with
2011 the <command>-i</command> option:
2012 </para>
2014 <para><screen>
2015 &rootprompt;<userinput>lpadmin -p pclprinter -v socket://11.12.13.14:9100 \
2016   -i /path/to/interface-script</userinput>
2017 </screen></para>
2019 <para>
2020 Interface scripts might be the <quote>unknown animal</quote> to many. However,
2021 with CUPS they provide the easiest way to plug in your own
2022 custom-written filtering script or program into one specific print
2023 queue (some information about the traditional usage of interface scripts is
2024 to be found at <ulink
2025         noescape="1" url="http://playground.sun.com/printing/documentation/interface.html">http://playground.sun.com/printing/documentation/interface.html</ulink>).
2026 </para>
2027 </sect2>
2028 </sect1>
2030 <sect1>
2031         <title>Network Printing (Purely Windows)</title>
2033 <para>
2034 Network printing covers a lot of ground. To understand what exactly
2035 goes on with Samba when it is printing on behalf of its Windows
2036 clients, let's first look at a <quote>purely Windows</quote> setup: Windows clients
2037 with a Windows NT print server.
2038 </para>
2040 <sect2>
2041 <title>From Windows Clients to an NT Print Server</title>
2043 <para>
2044 Windows clients printing to an NT-based print server have two
2045 options. They may:
2046 <indexterm><primary>GDI</primary></indexterm>
2047 <indexterm><primary>EMF</primary></indexterm>
2048 </para>
2051 <itemizedlist>
2052         <listitem><para>Execute the driver locally and render the GDI output
2053                         (EMF) into the printer-specific format on their own.
2054         </para></listitem>
2056         <listitem><para>Send the GDI output (EMF) to the server, where the
2057 driver is executed to render the printer specific
2058 output.</para></listitem>
2059 </itemizedlist>
2061 <para>
2062 Both print paths are shown in the flowcharts <link linkend="small11">Print driver 
2063 execution on the client</link> and <link linkend="small12">Print driver execution on the server</link>.
2064 </para>
2065 </sect2>
2067 <sect2>
2068 <title>Driver Execution on the Client</title>
2070 <para>
2071 In the first case the print server must spool the file as raw,
2072 meaning it shouldn't touch the jobfile and try to convert it in any
2073 way. This is what a traditional UNIX-based print server can do too, and
2074 at a better performance and more reliably than an NT print server. This
2075 is what most Samba administrators probably are familiar with. One
2076 advantage of this setup is that this <quote>spooling-only</quote> print server may
2077 be used even if no driver(s) for UNIX are available it is sufficient
2078 to have the Windows client drivers available; and installed on the
2079 clients.
2080 </para>
2082 <para>
2083         <image id="small11">
2084                 <imagedescription>Print driver execution on the client.</imagedescription>
2085                 <imagefile>11small</imagefile>
2086         </image>
2087 </para>
2088 </sect2>
2090 <sect2>
2091 <title>Driver Execution on the Server</title>
2094 <para>
2095 <indexterm><primary>PostScript</primary></indexterm>
2096 <indexterm><primary>PCL</primary></indexterm>
2097 <indexterm><primary>ESC/P</primary></indexterm>
2098 <indexterm><primary>EMF</primary></indexterm>
2099 <indexterm><primary>GDI</primary></indexterm>
2100 The other path executes the printer driver on the server. The client
2101 transfers print files in EMF format to the server. The server uses the
2102 PostScript, PCL, ESC/P or other driver to convert the EMF file into
2103 the printer-specific language. It is not possible for UNIX to do the
2104 same. Currently, there is no program or method to convert a Windows
2105 client's GDI output on a UNIX server into something a printer could
2106 understand.
2107 </para>
2109 <para>
2110         <image id="small12">
2111                 <imagedescription>Print driver execution on the server.</imagedescription>
2112                 <imagefile>12small</imagefile>
2113         </image>
2114 </para>
2116 <para>
2117 However, there is something similar possible with CUPS. Read on.
2118 </para>
2119 </sect2>
2120 </sect1>
2122 <sect1>
2123 <title>Network Printing (Windows Clients &smbmdash; UNIX/Samba Print
2124 Servers)</title>
2126 <para>
2127 Since UNIX print servers <emphasis>cannot</emphasis> execute the Win32
2128 program code on their platform, the picture is somewhat
2129 different. However, this does not limit your options all that
2130 much. On the contrary, you may have a way here to implement printing
2131 features that are not possible otherwise.
2132 </para>
2134 <sect2>
2135 <title>From Windows Clients to a CUPS/Samba Print Server</title>
2137 <para>
2138 Here is a simple recipe showing how you can take advantage of CUPS'
2139 powerful features for the benefit of your Windows network printing
2140 clients:
2141 </para>
2143 <itemizedlist>
2145 <listitem><para>Let the Windows clients send PostScript to the CUPS
2146 server.</para></listitem>
2148 <listitem><para>Let the CUPS server render the PostScript into device-specific raster format.</para></listitem>
2149 </itemizedlist>
2151 <para>
2152 This requires the clients to use a PostScript driver (even if the
2153 printer is a non-PostScript model. It also requires that you have a
2154 driver on the CUPS server.
2155 </para>
2157 <para>
2158 First, to enable CUPS-based printing through Samba the
2159 following options should be set in your &smb.conf; file [global]
2160 section:
2161 </para>
2163 <smbconfblock>
2164 <smbconfoption name="printing">cups</smbconfoption>
2165 <smbconfoption name="printcap">cups</smbconfoption>
2166 </smbconfblock>
2168 <para>
2169 When these parameters are specified, all manually set print directives
2170 (like <smbconfoption name="print command"/>, or <smbconfoption name="lppause command"/>) in &smb.conf; (as well as
2171 in Samba itself) will be ignored. Instead, Samba will directly
2172 interface with CUPS through its application program interface (API),
2173 as long as Samba has been compiled with CUPS library (libcups)
2174 support. If Samba has not been compiled with CUPS support, and if no
2175 other print commands are set up, then printing will use the
2176 <emphasis>System V</emphasis> AT&amp;T command set, with the -oraw
2177 option automatically passing through (if you want your own defined
2178 print commands to work with a Samba that has CUPS support compiled in,
2179 simply use <smbconfoption name="printing">sysv</smbconfoption>).
2180 </para>
2182 <para>
2183         <image>
2184                 <imagedescription>Printing via CUPS/Samba server.</imagedescription>
2185                 <imagefile>13small</imagefile>
2186         </image>
2187 </para>
2188 </sect2>
2190 <sect2>
2191 <title>Samba Receiving Job-files and Passing Them to CUPS</title>
2193 <para>
2194 Samba <emphasis>must</emphasis> use its own spool directory (it is set
2195 by a line similar to <smbconfoption name="path">/var/spool/samba</smbconfoption>,
2196 in the <smbconfsection>[printers]</smbconfsection> or
2197 <smbconfsection>[printername]</smbconfsection> section of
2198 &smb.conf;). Samba receives the job in its own
2199 spool space and passes it into the spool directory of CUPS (the CUPS
2200 spooling directory is set by the <parameter>RequestRoot</parameter>
2201 directive, in a line that defaults to <parameter>RequestRoot
2202 /var/spool/cups</parameter>). CUPS checks the access rights of its
2203 spool dir and resets it to healthy values with every restart. We have
2204 seen quite a few people who had used a common spooling space for Samba
2205 and CUPS, and were struggling for weeks with this <quote>problem.</quote>
2206 </para>
2208 <para>
2209 A Windows user authenticates only to Samba (by whatever means is
2210 configured). If Samba runs on the same host as CUPS, you only need to
2211 allow <quote>localhost</quote> to print. If they run on different machines, you
2212 need to make sure the Samba host gets access to printing on CUPS.
2213 </para>
2214 </sect2>
2215 </sect1>
2217 <sect1>
2218 <title>Network PostScript RIP</title>
2220 <para>
2221 This section discusses the use of CUPS filters on the server &smbmdash; configuration where
2222 clients make use of a PostScript driver with CUPS-PPDs.
2223 </para>
2226 <para>
2227 <indexterm><primary>PostScript</primary></indexterm>
2228 <indexterm><primary>PCL</primary></indexterm>
2229 <indexterm><primary>PJL</primary></indexterm>
2230 PPDs can control all print device options. They are usually provided
2231 by the manufacturer, if you own a PostScript printer, that is. PPD
2232 files (PostScript Printer Descriptions) are always a component of
2233 PostScript printer drivers on MS Windows or Apple Mac OS systems. They
2234 are ASCII files containing user-selectable print options, mapped to
2235 appropriate PostScript, PCL or PJL commands for the target
2236 printer. Printer driver GUI dialogs translate these options
2237 <quote>on-the-fly</quote> into buttons and drop-down lists for the user to select.
2238 </para>
2240 <para>
2241 CUPS can load, without any conversions, the PPD file from any Windows
2242 (NT is recommended) PostScript driver and handle the options. There is
2243 a Web browser interface to the print options (select <ulink
2244 noescape="1" url="http://localhost:631/printers/">http://localhost:631/printers/</ulink>
2245 and click on one <guibutton>Configure Printer</guibutton> button to see
2246 it), or a command line interface (see <command>man lpoptions</command>
2247 or see if you have <command>lphelp</command> on your system). There are also some
2248 different GUI front-ends on Linux/UNIX, which can present PPD options
2249 to users. PPD options are normally meant to be evaluated by the
2250 PostScript RIP on the real PostScript printer.
2251 </para>
2253 <sect2>
2254 <title>PPDs for Non-PS Printers on UNIX</title>
2257 <para>
2258 <indexterm><primary>PPD</primary></indexterm>
2259 CUPS does not limit itself to <quote>real</quote> PostScript printers in its usage
2260 of PPDs. The CUPS developers have extended the scope of the PPD
2261 concept to also describe available device and driver options for
2262 non-PostScript printers through CUPS-PPDs.
2263 </para>
2265 <para>
2266 This is logical, as CUPS includes a fully featured PostScript
2267 interpreter (RIP). This RIP is based on Ghostscript. It can process
2268 all received PostScript (and additionally many other file formats)
2269 from clients. All CUPS-PPDs geared to non-PostScript printers contain
2270 an additional line, starting with the keyword
2271 <parameter>*cupsFilter</parameter>. This line tells the CUPS print
2272 system which printer-specific filter to use for the interpretation of
2273 the supplied PostScript. Thus CUPS lets all its printers appear as
2274 PostScript devices to its clients, because it can act as a PostScript
2275 RIP for those printers, processing the received PostScript code into a
2276 proper raster print format.
2277 </para>
2278 </sect2>
2280 <sect2>
2281 <title>PPDs for Non-PS Printers on Windows</title>
2283 <para>
2284 <indexterm><primary>PPD</primary></indexterm>
2285 CUPS-PPDs can also be used on Windows-Clients, on top of a
2286 <quote>core</quote> PostScript driver (now recommended is the "CUPS PostScript
2287 Driver for Windows NT/200x/XP"; you can also use the Adobe one, with
2288 limitations). This feature enables CUPS to do a few tricks no other
2289 spooler can do:
2290 </para>
2292 <itemizedlist>
2294 <listitem><para>Act as a networked PostScript RIP (Raster Image
2295 Processor), handling print files from all client platforms in a uniform
2296 way.</para></listitem>
2298 <listitem><para>Act as a central accounting and billing server, since
2299 all files are passed through the pstops filter and are, therefore,
2300 logged in the CUPS <filename>page_log</filename> file.
2301 <emphasis>Note:</emphasis> this cannot happen with <quote>raw</quote> print jobs,
2302 which always remain unfiltered per definition.</para></listitem>
2304 <listitem><para>Enable clients to consolidate on a single PostScript
2305 driver, even for many different target printers.</para></listitem>
2306 </itemizedlist>
2308 <para>
2309 Using CUPS PPDs on Windows clients enables these to control
2310 all print job settings just as a UNIX client can do.
2311 </para>
2312 </sect2>
2313 </sect1>
2315 <sect1>
2316 <title>Windows Terminal Servers (WTS) as CUPS Clients</title>
2318 <para>
2319 This setup may be of special interest to people experiencing major
2320 problems in WTS environments. WTS often need a multitude of
2321 non-PostScript drivers installed to run their clients' variety of
2322 different printer models. This often imposes the price of much
2323 increased instability.
2324 </para>
2326 <sect2>
2327 <title>Printer Drivers Running in <quote>Kernel Mode</quote> Cause Many
2328 Problems</title>
2330 <para>
2331         In Windows NT printer drivers which run in <quote>Kernel
2332 Mode</quote>, introduces a high risk for the stability of the system
2333 if the driver is not really stable and well-tested. And there are a
2334 lot of bad drivers out there! Especially notorious is the example
2335 of the PCL printer driver that had an additional sound module
2336 running, to notify users via sound-card of their finished jobs. Do I
2337 need to say that this one was also reliably causing <quote>blue screens
2338 of death</quote> on a regular basis?
2339 </para>
2341 <para>
2342 PostScript drivers are generally well tested. They are not known
2343 to cause any problems, even though they also run in kernel mode. This
2344 might be because there have been so far only two different PostScript
2345 drivers: the ones from Adobe and the one from Microsoft. Both are
2346 well tested and are as stable as you can imagine on
2347 Windows. The CUPS driver is derived from the Microsoft one.
2348 </para>
2349 </sect2>
2351 <sect2>
2352 <title>Workarounds Impose Heavy Limitations</title>
2354 <para>
2355 In many cases, in an attempt to work around this problem, site
2356 administrators have resorted to restricting the allowed drivers installed
2357 on their WTS to one generic PCL and one PostScript driver. This,
2358 however, restricts the clients in the number of printer options
2359 available for them. Often they can't get out more than simplex
2360 prints from one standard paper tray, while their devices could do much
2361 better, if driven by a different driver!
2362 </para>
2363 </sect2>
2365 <sect2>
2366 <title>CUPS: A <quote>Magical Stone</quote>?</title>
2369 <para>
2370 <indexterm><primary>PPD</primary></indexterm>
2371 <indexterm><primary>PostScript</primary></indexterm>
2372 Using a PostScript driver, enabled with a CUPS-PPD, seems to be a very
2373 elegant way to overcome all these shortcomings. There are, depending
2374 on the version of Windows OS you use, up to three different PostScript
2375 drivers available: Adobe, Microsoft and CUPS PostScript drivers. None
2376 of them is known to cause major stability problems on WTS (even if
2377 used with many different PPDs). The clients will be able to (again)
2378 chose paper trays, duplex printing and other settings. However, there
2379 is a certain price for this too: a CUPS server acting as a PostScript
2380 RIP for its clients requires more CPU and RAM than when just acting as
2381 a <quote>raw spooling</quote> device. Plus, this setup is not yet widely tested,
2382 although the first feedbacks look very promising.
2383 </para>
2384 </sect2>
2386 <sect2>
2387 <title>PostScript Drivers with No Major Problems &smbmdash; Even in Kernel
2388 Mode</title>
2390 <para>
2391 <indexterm><primary>DDK</primary></indexterm>
2392 More recent printer drivers on W200x and XP no longer run in kernel mode
2393 (unlike Windows NT). However, both operating systems can still
2394 use the NT drivers, running in kernel mode (you can roughly tell which
2395 is which as the drivers in subdirectory <quote>2</quote> of <quote>W32X86</quote> are <quote>old</quote>
2396 ones). As was said before, the Adobe as well as the Microsoft
2397 PostScript drivers are not known to cause any stability problems. The
2398 CUPS driver is derived from the Microsoft one. There is a simple
2399 reason for this: The MS DDK (Device Development Kit) for Windows NT (which
2400 used to be available at no cost to licensees of Visual Studio)
2401 includes the source code of the Microsoft driver, and licensees of
2402 Visual Studio are allowed to use and modify it for their own driver
2403 development efforts. This is what the CUPS people have done. The
2404 license does not allow them to publish the whole of the source code.
2405 However, they have released the <quote>diff</quote> under the GPL, and if you are
2406 the owner of an <quote>MS DDK for Windows NT,</quote> you can check the driver yourself.
2407 </para>
2408 </sect2>
2409 </sect1>
2411 <sect1>
2412 <title>Configuring CUPS for Driver Download</title>
2414 <para>
2415 As we have said before, all previously known methods to prepare client
2416 printer drivers on the Samba server for download and Point'n'Print
2417 convenience of Windows workstations are working with CUPS, too. These
2418 methods were described in the previous chapter. In reality, this is a
2419 pure Samba business and only relates to the Samba/Windows client
2420 relationship.
2421 </para>
2423 <sect2>
2424 <title><emphasis>cupsaddsmb</emphasis>: The Unknown Utility</title>
2427 <para>
2428 <indexterm><primary>cupsaddsmb</primary></indexterm>
2429 The <command>cupsaddsmb</command> utility (shipped with all current CUPS versions) is an
2430 alternate method to transfer printer drivers into the Samba
2431 <smbconfsection>[print$]</smbconfsection> share. Remember, this share is where
2432 clients expect drivers deposited and setup for download and
2433 installation. It makes the sharing of any (or all) installed CUPS
2434 printers quite easy. <command>cupsaddsmb</command> can use the Adobe PostScript driver as
2435 well as the newly developed CUPS PostScript Driver for
2436 Windows NT/200x/XP. <parameter>cupsaddsmb</parameter> does
2437 <emphasis>not</emphasis> work with arbitrary vendor printer drivers,
2438 but only with the <emphasis>exact</emphasis> driver files that are
2439 named in its man page.
2440 </para>
2442 <para>
2443 The CUPS printer driver is available from the CUPS download site. Its
2444 package name is <filename>cups-samba-[version].tar.gz</filename> . It
2445 is preferred over the Adobe drivers since it has a number of
2446 advantages:
2447 </para>
2449 <itemizedlist>
2450 <listitem><para>It supports a much more accurate page
2451 accounting.</para></listitem>
2453 <listitem><para>It supports banner pages, and page labels on all
2454 printers.</para></listitem>
2456 <listitem><para>It supports the setting of a number of job IPP
2457 attributes (such as job-priority, page-label and
2458 job-billing).</para></listitem>
2459 </itemizedlist>
2461 <para>
2462 However, currently only Windows NT, 2000 and XP are supported by the
2463 CUPS drivers. You will also need to get the respective part of Adobe driver
2464 if you need to support Windows 95, 98 and ME clients.
2465 </para>
2466 </sect2>
2468 <sect2>
2469         <title>Prepare Your &smb.conf; for <command>cupsaddsmb</command></title>
2471 <para>
2472 Prior to running <command>cupsaddsmb</command>, you need the settings in
2473 &smb.conf; as shown in <link linkend="cupsadd-ex">the next example</link>:
2474 </para>
2476 <para><smbconfexample id="cupsadd-ex">
2477 <title>smb.conf for cupsaddsmb usage</title>
2478 <smbconfsection>[global]</smbconfsection>
2479 <smbconfoption name="load printers">yes</smbconfoption>
2480 <smbconfoption name="printing">cups</smbconfoption>
2481 <smbconfoption name="printcap name">cups</smbconfoption>
2483 <smbconfsection>[printers]</smbconfsection>
2484 <smbconfoption name="comment">All Printers</smbconfoption>
2485 <smbconfoption name="path">/var/spool/samba</smbconfoption>
2486 <smbconfoption name="browseable">no</smbconfoption>
2487 <smbconfoption name="public">yes</smbconfoption>
2488 <smbconfcomment>setting depends on your requirements</smbconfcomment>
2489 <smbconfoption name="guest ok">yes</smbconfoption>
2490 <smbconfoption name="writable">no</smbconfoption>
2491 <smbconfoption name="printable">yes</smbconfoption>
2492 <smbconfoption name="printer admin">root</smbconfoption>
2493  <smbconfsection>[print$]</smbconfsection>
2494 <smbconfoption name="comment">Printer Drivers</smbconfoption>
2495 <smbconfoption name="path">/etc/samba/drivers</smbconfoption>
2496 <smbconfoption name="browseable">yes</smbconfoption>
2497 <smbconfoption name="guest ok">no</smbconfoption>
2498 <smbconfoption name="read only">yes</smbconfoption>
2499 <smbconfoption name="write list">root</smbconfoption>
2500 </smbconfexample></para>
2501 </sect2>
2503 <sect2>
2504 <title>CUPS <quote>PostScript Driver for Windows NT/200x/XP</quote></title>
2506 <para>
2507 <indexterm><primary>PostScript</primary></indexterm>
2508 CUPS users may get the exact same packages from <ulink
2509 noescape="1" url="http://www.cups.org/software.html">http://www.cups.org/software.html</ulink>.
2510 It is a separate package from the CUPS base software files, tagged as
2511 CUPS 1.1.x Windows NT/200x/XP Printer Driver for Samba
2512 (tar.gz, 192k). The filename to download is
2513 <filename>cups-samba-1.1.x.tar.gz</filename>. Upon untar and unzipping,
2514 it will reveal these files:
2515 </para>
2517 <para><screen>
2518 &rootprompt;<userinput>tar xvzf cups-samba-1.1.19.tar.gz</userinput>
2519 cups-samba.install
2520 cups-samba.license
2521 cups-samba.readme
2522 cups-samba.remove
2523 cups-samba.ss
2524 </screen></para>
2526 <para>
2527 <indexterm><primary>ESP</primary><secondary>meta packager</secondary></indexterm>
2528 <indexterm><primary>EPM</primary><see>ESP meta packager</see></indexterm>
2529 These have been packaged with the ESP meta packager software
2530 EPM. The <filename>*.install</filename> and
2531 <filename>*.remove</filename> files are simple shell scripts, which
2532 untars the <filename>*.ss</filename> (the <filename>*.ss</filename> is
2533 nothing else but a tar-archive, which can be untarred by <quote>tar</quote>
2534 too). Then it puts the content into
2535 <filename>/usr/share/cups/drivers/</filename>. This content includes three
2536 files:
2537 </para>
2539 <para><screen>
2540 &rootprompt;<userinput>tar tv cups-samba.ss</userinput>
2541 cupsdrvr.dll
2542 cupsui.dll
2543 cups.hlp  
2544 </screen></para>
2546 <para>
2547 The <parameter>cups-samba.install</parameter> shell scripts are easy to
2548 handle:
2549 </para>
2551 <para><screen>
2552 &rootprompt;<userinput>./cups-samba.install</userinput>
2553 [....]
2554 Installing software...
2555 Updating file permissions...
2556 Running post-install commands...
2557 Installation is complete.       
2558 </screen></para>
2560 <para>
2561 The script should automatically put the driver files into the
2562 <filename>/usr/share/cups/drivers/</filename> directory.
2563 </para>
2565 <warning><para>
2566 Due to a bug, one recent CUPS release puts the
2567 <filename>cups.hlp</filename> driver file
2568 into<filename>/usr/share/drivers/</filename> instead of
2569 <filename>/usr/share/cups/drivers/</filename>. To work around this,
2570 copy/move the file (after running the
2571 <command>./cups-samba.install</command> script) manually to the
2572 correct place.
2573 </para></warning>
2575 <para><screen>
2576 &rootprompt;<userinput>cp /usr/share/drivers/cups.hlp /usr/share/cups/drivers/</userinput>
2577 </screen></para>
2580 <para>
2581 <indexterm><primary>DDK</primary></indexterm>
2582 This new CUPS PostScript driver is currently binary-only, but free of
2583 charge. No complete source code is provided (yet). The reason is that
2584 it has been developed with the help of the Microsoft Driver
2585 Developer Kit (DDK) and compiled with Microsoft Visual
2586 Studio 6. Driver developers are not allowed to distribute the whole of
2587 the source code as free software. However, CUPS developers released
2588 the <quote>diff</quote> in source code under the GPL, so anybody with a license of
2589 Visual Studio and a DDK will be able to compile for him/herself.
2590 </para>
2591 </sect2>
2593 <sect2>
2594 <title>Recognizing Different Driver Files</title>
2596 <para>
2597 The CUPS drivers do not support the older Windows 95/98/Me, but only
2598 the Windows NT/2000/XP client.
2599 </para>
2601 <para>Windows NT, 2000 and XP are supported by:</para>
2603 <para>
2604         <itemizedlist>
2605                 <listitem><para>cups.hlp</para></listitem>
2606                 <listitem><para>cupsdrvr.dll</para></listitem>
2607                 <listitem><para>cupsui.dll</para></listitem>
2608         </itemizedlist>
2609 </para>
2611 <para>
2612 Adobe drivers are available for the older Windows 95/98/Me as well as
2613 the Windows NT/2000/XP clients. The set of files is different from the
2614 different platforms.
2615 </para>
2617 <para>Windows 95, 98 and ME are supported by:</para>
2619 <para>
2620         <itemizedlist>
2621         <listitem><para>ADFONTS.MFM</para></listitem>
2622         <listitem><para>ADOBEPS4.DRV</para></listitem>
2623         <listitem><para>ADOBEPS4.HLP</para></listitem>
2624         <listitem><para>DEFPRTR2.PPD</para></listitem>
2625         <listitem><para>ICONLIB.DLL</para></listitem>
2626         <listitem><para>PSMON.DLL</para></listitem>
2627 </itemizedlist>
2628 </para>
2630 <para>Windows NT, 2000 and XP are supported by:</para>
2632 <para>
2633 <itemizedlist>
2634         <listitem><para>ADOBEPS5.DLL</para></listitem>
2635         <listitem><para>ADOBEPSU.DLL</para></listitem>
2636         <listitem><para>ADOBEPSU.HLP</para></listitem>
2637 </itemizedlist>
2639 </para>
2641 <note><para>
2642 If both the Adobe driver files and the CUPS driver files for the
2643 support of Windows NT/200x/XP are present in FIXME, the Adobe ones will be ignored
2644 and the CUPS ones will be used. If you prefer &smbmdash; for whatever reason
2645 &smbmdash; to use Adobe-only drivers, move away the three CUPS driver files. The
2646 Windows 9x/Me clients use the Adobe drivers in any case.
2647 </para></note>
2648 </sect2>
2650 <sect2>
2651 <title>Acquiring the Adobe Driver Files</title>
2653 <para>
2654 Acquiring the Adobe driver files seems to be unexpectedly difficult
2655 for many users. They are not available on the Adobe Web site as single
2656 files and the self-extracting and/or self-installing Windows-.exe is
2657 not easy to locate either. Probably you need to use the included
2658 native installer and run the installation process on one client
2659 once. This will install the drivers (and one Generic PostScript
2660 printer) locally on the client. When they are installed, share the
2661 Generic PostScript printer. After this, the client's
2662 <smbconfsection>[print$]</smbconfsection> share holds the Adobe files, from
2663 where you can get them with smbclient from the CUPS host. 
2664 </para>
2665 </sect2>
2667 <sect2>
2668 <title>ESP Print Pro PostScript Driver for Windows NT/200x/XP</title>
2672 <para>
2673 <indexterm><primary>ESP</primary><secondary>Print Pro</secondary></indexterm>
2674 Users of the ESP Print Pro software are able to install their Samba
2675 drivers package for this purpose with no problem. Retrieve the driver
2676 files from the normal download area of the ESP Print Pro software
2677 at <ulink
2678         noescape="1" url="http://www.easysw.com/software.html">http://www.easysw.com/software.html</ulink>.
2679 You need to locate the link labeled <quote>SAMBA</quote> among the
2680 <guilabel>Download Printer Drivers for ESP Print Pro 4.x</guilabel>
2681 area and download the package. Once installed, you can prepare any
2682 driver by simply highlighting the printer in the Printer Manager GUI
2683 and select <guilabel>Export Driver...</guilabel> from the menu. Of
2684 course you need to have prepared Samba beforehand to handle the
2685 driver files; i.e., setup the <smbconfsection>[print$]</smbconfsection>
2686 share, and so on. The ESP Print Pro package includes the CUPS driver files
2687 as well as a (licensed) set of Adobe drivers for the Windows 95/98/Me
2688 client family.
2689 </para>
2690 </sect2>
2692 <sect2>
2693 <title>Caveats to be Considered</title>
2696 <para>
2697 <indexterm><primary>cupsaddsmb</primary></indexterm>
2698 Once you have run the install script (and possibly manually
2699 moved the <filename>cups.hlp</filename> file to
2700 <filename>/usr/share/cups/drivers/</filename>), the driver is
2701 ready to be put into Samba's <smbconfsection>[print$]</smbconfsection> share (which often maps to
2702 <filename>/etc/samba/drivers/</filename> and contains a subdirectory
2703 tree with <emphasis>WIN40</emphasis> and
2704 <emphasis>W32X86</emphasis> branches). You do this by running
2705 <command>cupsaddsmb</command> (see also <command>man cupsaddsmb</command> for
2706 CUPS since release 1.1.16).
2707 </para>
2709 <tip><para>
2710 <indexterm><primary>Single Sign On</primary></indexterm>
2711 You may need to put root into the smbpasswd file by running
2712 <command>smbpasswd</command>; this is especially important if you
2713 should run this whole procedure for the first time, and are not
2714 working in an environment where everything is configured for
2715 <emphasis>single sign on</emphasis> to a Windows Domain Controller.
2716 </para></tip>
2718 <para>
2719 Once the driver files are in the <smbconfsection>[print$]</smbconfsection> share
2720 and are initialized, they are ready to be downloaded and installed by
2721 the Windows NT/200x/XP clients.
2722 </para>
2724 <note><para>
2725 Win 9x/Me clients will not work with the CUPS PostScript driver. For
2726 these you still need to use the <filename>ADOBE*.*</filename>
2727 drivers as previously stated.
2728 </para></note>
2730 <note>
2731 <para>
2732 It is not harmful if you still have the
2733 <filename>ADOBE*.*</filename> driver files from previous
2734 installations in the <filename>/usr/share/cups/drivers/</filename>
2735 directory. The new <command>cupsaddsmb</command> (from 1.1.16) will
2736 automatically prefer its own drivers if it finds both.
2737 </para></note>
2739 <note><para>
2740 <indexterm><primary>"Printers" folder</primary></indexterm>
2741 Should your Windows clients have had the old <filename>ADOBE*.*</filename>
2742 files for the Adobe PostScript driver installed, the download and
2743 installation of the new CUPS PostScript driver for Windows NT/200x/XP
2744 will fail at first. You need to wipe the old driver from the clients
2745 first. It is not enough to <quote>delete</quote> the printer, as the driver files
2746 will still be kept by the clients and re-used if you try to re-install
2747 the printer. To really get rid of the Adobe driver files on the
2748 clients, open the <guilabel>Printers</guilabel> folder (possibly via <guilabel>Start > Settings > Control Panel > Printers</guilabel>),
2749 right-click on the folder background and select <guimenuitem>Server
2750 Properties</guimenuitem>. When the new dialog opens, select the
2751 <guilabel>Drivers</guilabel> tab. On the list select the driver you
2752 want to delete and click the <guilabel>Delete</guilabel>
2753 button. This will only work if there is not one single printer left
2754 that uses that particular driver. You need to <quote>delete</quote> all printers
2755 using this driver in the <guilabel>Printers</guilabel> folder first. You will need
2756 Administrator privileges to do this.
2757 </para></note>
2759 <note><para>
2760 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
2761 Once you have successfully downloaded the CUPS PostScript driver to a
2762 client, you can easily switch all printers to this one by proceeding
2763 as described in <link linkend="printing">Classical Printing Support</link>. Either change
2764 a driver for an existing printer by running the <guilabel>Printer Properties</guilabel>
2765 dialog, or use <command>rpcclient</command> with the
2766 <command>setdriver</command> subcommand.
2767 </para></note>
2768 </sect2>
2770 <sect2>
2771 <title>Windows CUPS PostScript Driver Versus Adobe Driver</title>
2773 <para>
2774 Are you interested in a comparison between the CUPS and the Adobe
2775 PostScript drivers? For our purposes these are the most important
2776 items that weigh in favor of the CUPS ones:
2777 </para>
2779 <itemizedlist>
2780 <listitem><para>No hassle with the Adobe EULA.</para></listitem>
2782 <listitem><para>No hassle with the question <quote>Where do I
2783 get the ADOBE*.* driver files from?</quote></para></listitem>
2785 <listitem><para>
2786 <indexterm><primary>PJL</primary></indexterm>
2787 The Adobe drivers (on request of the printer PPD
2788 associated with them) often put a PJL header in front of the main
2789 PostScript part of the print file. Thus, the printfile starts with
2790 <parameter>&lt;1B &gt;%-12345X</parameter> or
2791 <parameter>&lt;escape&gt;%-12345X</parameter> instead
2792 of <parameter>%!PS</parameter>). This leads to the
2793 CUPS daemon auto-typing the incoming file as a print-ready file,
2794 not initiating a pass through the <parameter>pstops</parameter> filter (to speak more
2795 technically, it is not regarded as the generic MIME-type 
2796 <indexterm><primary>application/postscript</primary></indexterm>
2797 <parameter>application/postscript</parameter>, but as
2798 the more special MIME type
2799 <indexterm><primary>application/cups.vnd-postscript</primary></indexterm>
2800 <parameter>application/cups.vnd-postscript</parameter>),
2801 which therefore also leads to the page accounting in
2802 <parameter>/var/log/cups/page_log</parameter> not
2803 receiving the exact number of pages; instead the dummy page number
2804 of <quote>1</quote> is logged in a standard setup).</para></listitem>
2806 <listitem><para>The Adobe driver has more options to mis-configure the
2807 PostScript generated by it (like setting it inadvertently to
2808 <guilabel>Optimize for Speed</guilabel>, instead of
2809 <guilabel>Optimize for Portability</guilabel>, which
2810 could lead to CUPS being unable to process it).</para></listitem>
2812 <listitem><para>The CUPS PostScript driver output sent by Windows
2813 clients to the CUPS server is guaranteed to auto-type 
2814 as the generic MIME type <parameter>application/postscript</parameter>,
2815 thus passing through the CUPS <parameter>pstops</parameter> filter and logging the
2816 correct number of pages in the <filename>page_log</filename> for
2817 accounting and quota purposes.</para></listitem>
2819 <listitem><para>The CUPS PostScript driver supports the sending of
2820 additional standard (IPP) print options by Windows NT/200x/XP clients. Such
2821 additional print options are: naming the CUPS standard
2822 <emphasis>banner pages</emphasis> (or the custom ones, should they be
2823 installed at the time of driver download), using the CUPS
2824 page-label option, setting a
2825 job-priority, and setting the scheduled
2826 time of printing (with the option to support additional
2827 useful IPP job attributes in the future).</para></listitem>
2829 <listitem><para>The CUPS PostScript driver supports the inclusion of
2830 the new <parameter>*cupsJobTicket</parameter> comments at the
2831 beginning of the PostScript file (which could be used in the future
2832 for all sort of beneficial extensions on the CUPS side, but which will
2833 not disturb any other applications as they will regard it as a comment
2834 and simply ignore it).</para></listitem>
2836 <listitem><para>The CUPS PostScript driver will be the heart of the
2837 fully fledged CUPS IPP client for Windows NT/200x/XP to be released soon
2838 (probably alongside the first beta release for CUPS
2839 1.2).</para></listitem>
2840 </itemizedlist>
2842 </sect2>
2844 <sect2>
2845 <title>Run cupsaddsmb (Quiet Mode)</title>
2848 <para>
2849 <indexterm><primary>cupsaddsmb</primary></indexterm>
2850 <indexterm><primary>point 'n' print</primary></indexterm>
2851 The <command>cupsaddsmb</command> command copies the needed files into your
2852 <smbconfsection>[print$]</smbconfsection> share. Additionally, the PPD
2853 associated with this printer is copied from
2854 <filename>/etc/cups/ppd/</filename> to
2855 <smbconfsection>[print$]</smbconfsection>. There the files wait for convenient
2856 Windows client installations via Point'n'Print. Before we can run the
2857 command successfully, we need to be sure that we can authenticate
2858 toward Samba. If you have a small network, you are probably using user-level
2859 security (<smbconfoption name="security">user</smbconfoption>). 
2860 </para>
2862 <para>
2863 Here is an example of a successfully run <command>cupsaddsmb</command> command: 
2864 </para>
2866 <para><screen>
2867 &rootprompt;<userinput>cupsaddsmb -U root infotec_IS2027</userinput>
2868 Password for root required to access localhost via Samba: <userinput>['secret']</userinput>
2869 </screen></para>
2871 <para>
2872 To share <emphasis>all</emphasis> printers and drivers, use the
2873 <option>-a</option> parameter instead of a printer name. Since
2874 <command>cupsaddsmb</command> <quote>exports</quote> the printer drivers to Samba, it should be
2875 obvious that it only works for queues with a CUPS driver associated.
2876 </para>
2877 </sect2>
2879 <sect2>
2880 <title>Run cupsaddsmb with Verbose Output</title>
2883 <para>
2884 <indexterm><primary>cupsaddsmb</primary></indexterm>
2885 Probably you want to see what's going on. Use the
2886 <option>-v</option> parameter to get a more verbose output. The
2887 output below was edited for better readability: all <quote>\</quote> at the end of
2888 a line indicate that I inserted an artificial line break plus some
2889 indentation here:
2890 </para>
2892 <warning><para>
2893 You will see the root password for the Samba account printed on
2894 screen. 
2895 </para></warning>
2897 <para>
2898         
2899 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
2900 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
2901         <screen>
2902 &rootprompt;<userinput>cupsaddsmb -U root -v infotec_2105</userinput>
2903 Password for root required to access localhost via &example.server.samba;:
2904 Running command: smbclient //localhost/print\$ -N -U'root%secret' \
2905     -c 'mkdir W32X86; \
2906     put /var/spool/cups/tmp/3e98bf2d333b5 W32X86/infotec_2105.ppd; \
2907         put /usr/share/cups/drivers/cupsdrvr.dll W32X86/cupsdrvr.dll; \
2908     put /usr/share/cups/drivers/cupsui.dll W32X86/cupsui.dll; \
2909     put /usr/share/cups/drivers/cups.hlp W32X86/cups.hlp'
2910 added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
2911 Domain=[CUPS-PRINT] OS=[UNIX] Server=[Samba 2.2.7a]
2912 NT_STATUS_OBJECT_NAME_COLLISION making remote directory \W32X86
2913 putting file /var/spool/cups/tmp/3e98bf2d333b5 as \W32X86/infotec_2105.ppd
2914 putting file /usr/share/cups/drivers/cupsdrvr.dll as \W32X86/cupsdrvr.dll
2915 putting file /usr/share/cups/drivers/cupsui.dll as \W32X86/cupsui.dll
2916 putting file /usr/share/cups/drivers/cups.hlp as \W32X86/cups.hlp
2917   
2918 Running command: rpcclient localhost -N -U'root%secret' 
2919    -c 'adddriver "Windows NT x86"   \
2920    "infotec_2105:cupsdrvr.dll:infotec_2105.ppd:cupsui.dll:cups.hlp:NULL: \
2921     RAW:NULL"'
2922 cmd = adddriver "Windows NT x86" \
2923    "infotec_2105:cupsdrvr.dll:infotec_2105.ppd:cupsui.dll:cups.hlp:NULL: \
2924         RAW:NULL"
2925 Printer Driver infotec_2105 successfully installed.
2926   
2927 Running command: smbclient //localhost/print\$ -N -U'root%secret' \
2928 -c 'mkdir WIN40; \
2929     put /var/spool/cups/tmp/3e98bf2d333b5 WIN40/infotec_2105.PPD; \
2930         put /usr/share/cups/drivers/ADFONTS.MFM WIN40/ADFONTS.MFM;   \
2931     put /usr/share/cups/drivers/ADOBEPS4.DRV WIN40/ADOBEPS4.DRV; \
2932     put /usr/share/cups/drivers/ADOBEPS4.HLP WIN40/ADOBEPS4.HLP; \
2933     put /usr/share/cups/drivers/DEFPRTR2.PPD WIN40/DEFPRTR2.PPD; \
2934         put /usr/share/cups/drivers/ICONLIB.DLL WIN40/ICONLIB.DLL; \
2935         put /usr/share/cups/drivers/PSMON.DLL WIN40/PSMON.DLL;'
2936   added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
2937   Domain=[CUPS-PRINT] OS=[UNIX] Server=[Samba 2.2.7a]
2938   NT_STATUS_OBJECT_NAME_COLLISION making remote directory \WIN40
2939   putting file /var/spool/cups/tmp/3e98bf2d333b5 as \WIN40/infotec_2105.PPD
2940   putting file /usr/share/cups/drivers/ADFONTS.MFM as \WIN40/ADFONTS.MFM
2941   putting file /usr/share/cups/drivers/ADOBEPS4.DRV as \WIN40/ADOBEPS4.DRV
2942   putting file /usr/share/cups/drivers/ADOBEPS4.HLP as \WIN40/ADOBEPS4.HLP
2943   putting file /usr/share/cups/drivers/DEFPRTR2.PPD as \WIN40/DEFPRTR2.PPD
2944   putting file /usr/share/cups/drivers/ICONLIB.DLL as \WIN40/ICONLIB.DLL
2945   putting file /usr/share/cups/drivers/PSMON.DLL as \WIN40/PSMON.DLL
2946   
2947   Running command: rpcclient localhost -N -U'root%secret' \
2948    -c 'adddriver "Windows 4.0"      \
2949    "infotec_2105:ADOBEPS4.DRV:infotec_2105.PPD:NULL:ADOBEPS4.HLP: \
2950    PSMON.DLL:RAW:ADOBEPS4.DRV,infotec_2105.PPD,ADOBEPS4.HLP,PSMON.DLL, \
2951     ADFONTS.MFM,DEFPRTR2.PPD,ICONLIB.DLL"'
2952         cmd = adddriver "Windows 4.0" "infotec_2105:ADOBEPS4.DRV:\
2953         infotec_2105.PPD:NULL:ADOBEPS4.HLP:PSMON.DLL:RAW:ADOBEPS4.DRV,\
2954         infotec_2105.PPD,ADOBEPS4.HLP,PSMON.DLL,ADFONTS.MFM,DEFPRTR2.PPD,\
2955         ICONLIB.DLL"
2956   Printer Driver infotec_2105 successfully installed.
2957   
2958   Running command: rpcclient localhost -N -U'root%secret'  \
2959    -c 'setdriver infotec_2105 infotec_2105'
2960   cmd = setdriver infotec_2105 infotec_2105
2961   Successfully set infotec_2105 to driver infotec_2105.
2963 </screen></para>
2965 <para>
2966 If you look closely, you'll discover your root password was transferred
2967 unencrypted over the wire, so beware! Also, if you look further,
2968 you'll discover error messages like <?latex \linebreak ?>NT_STATUS_OBJECT_NAME_COLLISION in between. They occur, because the directories WIN40 and W32X86 already existed in the <smbconfsection>[print$]</smbconfsection> driver download share (from a previous driver installation). They are harmless here.
2969 </para>
2970 </sect2>
2972 <sect2>
2973 <title>Understanding cupsaddsmb</title>
2976 <para>
2977 <indexterm><primary>cupsaddsmb</primary></indexterm>
2978 What has happened? What did <command>cupsaddsmb</command> do? There are five stages of
2979 the procedure:
2980 </para>
2982 <orderedlist>
2983         <listitem><para>
2984         <indexterm><primary>IPP</primary></indexterm>
2985                         Call the CUPS server via IPP and request the
2986 driver files and the PPD file for the named printer.</para></listitem>
2988 <listitem><para>Store the files temporarily in the local
2989 TEMPDIR (as defined in
2990 <filename>cupsd.conf</filename>).</para></listitem>
2992 <listitem><para>Connect via smbclient to the Samba server's
2993  <smbconfsection>[print$]</smbconfsection> share and put the files into the
2994  share's WIN40 (for Windows 9x/Me) and W32X86/ (for Windows NT/200x/XP) subdirectories.</para></listitem>
2996 <listitem><para>
2997 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
2998                 Connect via rpcclient to the Samba server and
2999 execute the <command>adddriver</command> command with the correct
3000 parameters.</para></listitem>
3002 <listitem><para>
3003 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
3004                 Connect via rpcclient to the Samba server a second
3005 time and execute the <command>setdriver</command> command.</para></listitem>
3006 </orderedlist>
3008 <note>
3009 <para>
3010 You can run the <command>cupsaddsmb</command> utility with parameters to
3011 specify one remote host as Samba host and a second remote host as CUPS
3012 host. Especially if you want to get a deeper understanding, it is a
3013 good idea to try it and see more clearly what is going on (though in real
3014 life most people will have their CUPS and Samba servers run on the
3015 same host):
3016 </para>
3018 <para><screen>
3019 &rootprompt;<userinput>cupsaddsmb -H sambaserver -h cupsserver -v printer</userinput>
3020 </screen></para>
3021 </note>
3022 </sect2>
3024 <sect2>
3025 <title>How to Recognize If cupsaddsmb Completed Successfully</title>
3027 <para>
3028 You <emphasis>must</emphasis> always check if the utility completed
3029 successfully in all fields. You need as a minimum these three messages
3030 among the output:
3031 </para>
3033 <orderedlist>
3035 <listitem><para><emphasis>Printer Driver infotec_2105 successfully
3036 installed.</emphasis> # (for the W32X86 == Windows NT/200x/XP
3037 architecture).</para></listitem>
3039 <listitem><para><emphasis>Printer Driver infotec_2105 successfully
3040 installed.</emphasis> # (for the WIN40 == Windows 9x/Me
3041 architecture).</para></listitem>
3043 <listitem><para><emphasis>Successfully set [printerXPZ] to driver
3044 [printerXYZ].</emphasis></para></listitem>
3045 </orderedlist>
3047 <para>
3048 These messages are probably not easily recognized in the general
3049 output. If you run <command>cupsaddsmb</command> with the <option>-a</option>
3050 parameter (which tries to prepare <emphasis>all</emphasis> active CUPS
3051 printer drivers for download), you might miss if individual printers
3052 drivers had problems installing properly. Here a redirection of the
3053 output will help you analyze the results in retrospective.
3054 </para>
3056 <para>
3057 If you get:
3058 <screen>
3059 SetPrinter call failed!
3060 result was WERR_ACCESS_DENIED
3061 </screen>
3062 It means that you might have set <smbconfoption name="use client driver">yes</smbconfoption> for this printer. 
3063 Set it to <quote>no</quote> will solve the problem. Refer to man samba(5) for explanantion on 
3064 <parameter>use client driver</parameter>.
3065 </para>
3067 <note><para>
3068 It is impossible to see any diagnostic output if you do not run
3069 <command>cupsaddsmb</command> in verbose mode. Therefore, we strongly recommend to not
3070 use the default quiet mode. It will hide any problems from you that
3071 might occur.
3072 </para></note>
3073 </sect2>
3075 <sect2>
3076 <title>cupsaddsmb with a Samba PDC</title>
3079 <para>
3080 <indexterm><primary>cupsaddsmb</primary></indexterm>
3081 Can't get the standard <command>cupsaddsmb</command> command to run on a Samba PDC?
3082 Are you asked for the password credential all over again and again and
3083 the command just will not take off at all? Try one of these
3084 variations:
3085 </para>
3087 <para><screen>
3088 &rootprompt;<userinput>cupsaddsmb -U &example.workgroup;\\root -v printername</userinput>
3089 &rootprompt;<userinput>cupsaddsmb -H &example.pdc.samba; -U &example.workgroup;\\root -v printername</userinput>
3090 &rootprompt;<userinput>cupsaddsmb -H &example.pdc.samba; -U &example.workgroup;\\root -h cups-server -v printername</userinput>
3091 </screen></para>
3093 <para>
3094 (Note the two backslashes: the first one is required to
3095 <quote>escape</quote> the second one).
3096 </para>
3097 </sect2>
3099 <sect2>
3100 <title>cupsaddsmb Flowchart</title>
3102 <para>
3103 <indexterm><primary>cupsaddsmb</primary></indexterm>
3104 <link linkend="small14">cupsaddsmb flowchart</link> shows a chart about the procedures, command-flows and
3105 data-flows of the <command>cupaddsmb</command> command. Note again: cupsaddsmb is
3106 not intended to, and does not work with, raw queues!
3107 </para>
3109 <para>
3110         <image id="small14">
3111                 <imagedescription>cupsaddsmb flowchart.</imagedescription>
3112                 <imagefile>14small</imagefile></image>
3113 </para>
3114 </sect2>
3116 <sect2>
3117 <title>Installing the PostScript Driver on a Client</title>
3119 <para>
3120 <indexterm><primary>point 'n' print</primary></indexterm>
3121 After <command>cupsaddsmb</command> is completed, your driver is prepared for the clients to
3122 use. Here are the steps you must perform to download and install it
3123 via Point'n'Print. From a Windows client, browse to the CUPS/Samba
3124 server:
3125 </para>
3127 <itemizedlist>
3130 <listitem><para>
3131 <indexterm><primary>"Printers" folder</primary></indexterm>
3132 Open the <guilabel>Printers</guilabel>
3133 share of Samba in Network Neighborhood.</para></listitem>
3135 <listitem><para>Right-click on the printer in
3136 question.</para></listitem>
3138 <listitem><para>From the opening context-menu select
3139 <guimenuitem>Install...</guimenuitem> or 
3140 <guimenuitem>Connect...</guimenuitem> (depending on the Windows version you
3141 use).</para></listitem>
3142 </itemizedlist>
3144 <para>
3145 After a few seconds, there should be a new printer in your
3146 client's <emphasis>local</emphasis> <guilabel>Printers</guilabel> folder. On Windows
3147 XP it will follow a naming convention of <emphasis>PrinterName on
3148 SambaServer</emphasis>. (In my current case it is "infotec_2105 on
3149 kde-bitshop"). If you want to test it and send your first job from
3150 an application like Winword, the new printer appears in a
3151 <filename>\\SambaServer\PrinterName</filename> entry in the
3152 drop-down list of available printers.
3153 </para>
3155 <para>
3156 <indexterm><primary>PPD</primary></indexterm>
3157 <command>cupsaddsmb</command> will only reliably work with CUPS version 1.1.15 or higher
3158 and Samba from 2.2.4. If it does not work, or if the automatic printer
3159 driver download to the clients does not succeed, you can still manually
3160 install the CUPS printer PPD on top of the Adobe PostScript driver on
3161 clients. Then point the client's printer queue to the Samba printer
3162 share for a UNC type of connection:
3163 </para>
3165 <para><screen>
3166 &dosprompt;<userinput>net use lpt1: \\sambaserver\printershare /user:ntadmin</userinput>
3167 </screen></para>
3169 <para>
3170 should you desire to use the CUPS networked PostScript RIP
3171 functions. (Note that user <quote>ntadmin</quote> needs to be a valid Samba user
3172 with the required privileges to access the printershare.) This
3173 sets up the printer connection in the traditional
3174 <emphasis>LanMan</emphasis> way (not using MS-RPC).
3175 </para>
3176 </sect2>
3178 <sect2>
3179 <title>Avoiding Critical PostScript Driver Settings on the Client</title>
3181 <para>
3182 Printing works, but there are still problems. Most jobs print
3183 well, some do not print at all. Some jobs have problems with fonts,
3184 which do not look very good. Some jobs print fast and some are
3185 dead-slow. Many of these problems can be greatly reduced or even
3186 completely eliminated if you follow a few guidelines. Remember, if
3187 your print device is not PostScript-enabled, you are treating your
3188 Ghostscript installation on your CUPS host with the output your client
3189 driver settings produce. Treat it well:
3190 </para>
3192 <itemizedlist>
3193 <listitem><para>Avoid the PostScript Output Option: Optimize
3194 for Speed setting. Use the Optimize for
3195 Portability instead (Adobe PostScript
3196 driver).</para></listitem>
3198 <listitem><para>Don't use the Page Independence:
3199 NO setting. Instead, use Page Independence
3200 YES (CUPS PostScript Driver).</para></listitem>
3202 <listitem><para>Recommended is the True Type Font
3203 Downloading Option: Native True Type over
3204 Automatic and Outline; you
3205 should by all means avoid Bitmap (Adobe
3206 PostScript Driver).</para></listitem>
3208 <listitem><para>Choose True Type Font: Download as Softfont
3209 into Printer over the default Replace by Device
3210 Font (for exotic fonts, you may need to change it back to
3211 get a printout at all) (Adobe).</para></listitem>
3213 <listitem><para>Sometimes you can choose PostScript Language
3214 Level: In case of problems try 2
3215 instead of 3 (the latest ESP Ghostscript package
3216 handles Level 3 PostScript very well) (Adobe).</para></listitem>
3218 <listitem><para>Say Yes to PostScript
3219 Error Handler (Adobe).</para></listitem>
3220 </itemizedlist>
3221 </sect2>
3222 </sect1>
3224 <sect1>
3225 <title>Installing PostScript Driver Files Manually Using rpcclient</title>
3227 <para>
3228 Of course, you can run all the commands that are embedded into the
3229 cupsaddsmb convenience utility yourself, one by one, and hereby upload
3230 and prepare the driver files for future client downloads.
3231 </para>
3233 <orderedlist>
3234 <listitem><para>Prepare Samba (A CUPS print queue with the name of the
3235 printer should be there. We are providing the driver
3236 now).</para></listitem>
3238 <listitem><para>Copy all files to
3239                 <smbconfsection>[print$]</smbconfsection>.</para></listitem>
3241 <listitem><para>
3242 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3243 Run <command>rpcclient adddriver</command>
3244 (for each client architecture you want to support).</para></listitem>
3246 <listitem><para>
3247 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
3248 Run <command>rpcclient
3249 setdriver.</command></para></listitem>
3250 </orderedlist>
3252 <para>
3253 <indexterm><primary>rpcclient</primary><secondary>enumports</secondary></indexterm>
3254 <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3255 <indexterm><primary>rpcclient</primary><secondary>enumdrivers</secondary></indexterm>
3256 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
3257 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3258 We are going to do this now. First, read the man page on <parameter>rpcclient</parameter>
3259 to get a first idea. Look at all the printing related
3260 subcommands. <command>enumprinters</command>,
3261 <command>enumdrivers</command>, <command>enumports</command>,
3262 <command>adddriver</command>, <command>setdriver</command> are among
3263 the most interesting ones. <parameter>rpcclient</parameter> implements an important part of
3264 the MS-RPC protocol. You can use it to query (and command) a Windows NT
3265 (or 200x/XP) PC, too. MS-RPC is used by Windows clients, among other
3266 things, to benefit from the Point'n'Print features. Samba can now
3267 mimic this as well.
3268 </para>
3270 <sect2>
3271 <title>A Check of the rpcclient man Page</title>
3273 <para>
3274         First let's check the <parameter>rpcclient</parameter> man page. Here are
3275 two relevant passages:
3276 </para>
3278 <para>
3279 <command>adddriver &lt;arch&gt; &lt;config&gt;</command> Execute an
3280 <command>AddPrinterDriver()</command> RPC to install the printer driver information on
3281 the server. The driver files should already exist in the
3282 directory returned by <command>getdriverdir</command>. Possible
3283 values for <parameter>arch</parameter> are the same as those for the
3284 <command>getdriverdir</command> command. The
3285 <parameter>config</parameter> parameter is defined as follows:
3286 </para>
3287                 
3288 <para><screen>
3289 Long Printer Name:\
3290 Driver File Name:\
3291 Data File Name:\
3292 Config File Name:\
3293 Help File Name:\
3294 Language Monitor Name:\
3295 Default Data Type:\
3296 Comma Separated list of Files
3297 </screen></para>
3299 <para>Any empty fields should be enter as the string <quote>NULL</quote>. </para>
3301 <para>Samba does not need to support the concept of Print Monitors
3302 since these only apply to local printers whose driver can make use of
3303 a bi-directional link for communication. This field should be <quote>NULL</quote>.
3304 On a remote NT print server, the Print Monitor for a driver must
3305 already be installed prior to adding the driver or else the RPC will
3306 fail.
3307 </para>
3309 <para>
3310 <command>setdriver &lt;printername&gt; &lt;drivername&gt;</command>
3311 Execute a <command>SetPrinter()</command> command to update the
3312 printer driver associated with an installed printer. The printer
3313 driver must already be correctly installed on the print server.
3314 </para>
3316 <para>See also the <command>enumprinters</command> and <command>enumdrivers</command> commands for
3317 obtaining a list of installed printers and drivers.
3318 </para>
3320 </sect2>
3322 <sect2>
3323 <title>Understanding the rpcclient man Page</title>
3325 <para>
3326 The <emphasis>exact</emphasis> format isn't made too clear by the man
3327 page, since you have to deal with some parameters containing
3328 spaces. Here is a better description for it. We have line-broken the
3329 command and indicated the breaks with <quote>\</quote>. Usually you would type the
3330 command in one line without the line-breaks:
3331 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3332 </para>
3334 <para><screen>
3335  adddriver "Architecture" \
3336            "LongPrinterName:DriverFile:DataFile:ConfigFile:HelpFile:\
3337            LanguageMonitorFile:DataType:ListOfFiles,Comma-separated"
3338 </screen></para>
3340 <para>
3341 What the man pages denote as a simple <parameter>&lt;config&gt;</parameter>
3342 keyword, in reality consists of eight colon-separated fields. The
3343 last field may take multiple (in some very insane cases, even
3344 20 different additional) files. This might sound confusing at first.
3345 What the man pages names the <quote>LongPrinterName</quote> in
3346 reality should be called the <quote>Driver Name</quote>. You can name it
3347 anything you want, as long as you use this name later in the
3348 <command>rpcclient ... setdriver</command> command. For
3349 practical reasons, many name the driver the same as the
3350 printer.
3351 </para>
3353 <para>
3354 It isn't simple at all. I hear you asking:
3355 <quote>How do I know which files are "Driver
3356 File</quote>, <quote>Data File</quote>, <quote>Config File</quote>, <quote>Help File</quote> and <quote>Language
3357 Monitor File" in each case?</quote> &smbmdash; For an answer, you may
3358 want to have a look at how a Windows NT box with a shared printer
3359 presents the files to us. Remember, that this whole procedure has
3360 to be developed by the Samba team by overhearing the traffic caused
3361 by Windows computers on the wire. We may as well turn to a Windows
3362 box now and access it from a UNIX workstation. We will query it
3363 with <command>rpcclient</command> to see what it tells us and
3364 try to understand the man page more clearly that we've read just
3365 now.
3366 </para>
3367 </sect2>
3369 <sect2>
3370 <title>Producing an Example by Querying a Windows Box</title>
3372 <para>
3373         <indexterm><primary>rpcclient</primary><secondary>getdriver</secondary></indexterm>
3374         <indexterm><primary>rpcclient</primary><secondary>getprinter</secondary></indexterm>
3375 We could run <command>rpcclient</command> with a
3376 <command>getdriver</command> or a <command>getprinter</command>
3377 subcommand (in level 3 verbosity) against it. Just sit down at a UNIX or
3378 Linux workstation with the Samba utilities installed, then type the
3379 following command:
3380 </para>
3382 <para><screen>
3383 &rootprompt;<userinput>rpcclient -U'user%secret' NT-SERVER -c 'getdriver printername 3'</userinput>
3384 </screen></para>
3386 <para>
3387 From the result it should become clear which is which. Here is an example from my installation:
3388 </para>
3390 <para>
3391 <indexterm><primary>rpcclient</primary><secondary>getdriver</secondary></indexterm>
3392         <screen>
3393 &rootprompt;<userinput>rpcclient -U'Danka%xxxx' W200xSERVER \
3394         -c'getdriver "DANKA InfoStream Virtual Printer" 3'</userinput>
3395  cmd = getdriver "DANKA InfoStream Virtual Printer" 3
3397  [Windows NT x86]
3398  Printer Driver Info 3:
3399          Version: [2]
3400          Driver Name: [DANKA InfoStream]
3401          Architecture: [Windows NT x86]
3402          Driver Path: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\PSCRIPT.DLL]
3403          Datafile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\INFOSTRM.PPD]
3404          Configfile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\PSCRPTUI.DLL]
3405          Helpfile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\PSCRIPT.HLP]
3407          Dependentfiles: []
3408          Dependentfiles: []
3409          Dependentfiles: []
3410          Dependentfiles: []
3411          Dependentfiles: []
3412          Dependentfiles: []
3413          Dependentfiles: []
3415          Monitorname: []
3416          Defaultdatatype: []
3418 </screen></para>
3420 <para>
3421 Some printer drivers list additional files under the label
3422 <parameter>Dependentfiles</parameter> and these would go into the last field
3423 <parameter>ListOfFiles,Comma-separated</parameter>. For the CUPS
3424 PostScript drivers, we do not need any (nor would we for the Adobe
3425 PostScript driver), therefore, the field will get a <quote>NULL</quote> entry.
3426 </para>
3427 </sect2>
3429 <sect2>
3430 <title>Requirements for adddriver and setdriver to Succeed</title>
3432 <para>
3433 >From the man page (and from the quoted output
3434 of <command>cupsaddsmb</command> above) it becomes clear that you
3435 need to have certain conditions in order to make the manual uploading
3436 and initializing of the driver files succeed. The two <command>rpcclient</command>
3437 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3438 subcommands (<command>adddriver</command> and
3439 <command>setdriver</command>) need to encounter the following
3440 preconditions to complete successfully:
3441 </para>
3442 <itemizedlist>
3444 <listitem><para>You are connected as <smbconfoption name="printer admin"/> or root (this is <emphasis>not</emphasis> the <quote>Printer Operators</quote> group in
3445 NT, but the <emphasis>printer admin</emphasis> group as defined in
3446 the <smbconfsection>[global]</smbconfsection> section of
3447 &smb.conf;).</para></listitem>
3449 <listitem><para>Copy all required driver files to
3450 <filename>\\SAMBA\print$\w32x86</filename> and
3451 <filename>\\SAMBA\print$\win40</filename> as appropriate. They
3452 will end up in the <quote>0</quote> respective <quote>2</quote> subdirectories later. For now,
3453 <emphasis>do not</emphasis> put them there, they'll be automatically
3454 used by the <command>adddriver</command> subcommand. (If you use
3455 <command>smbclient</command> to put the driver files into the share, note that you need
3456 to escape the <quote>$</quote>: <command>smbclient //sambaserver/print\$ -U
3457 root.</command>)</para></listitem>
3459 <listitem><para>The user you're connecting as must be able to write to
3460 the <smbconfsection>[print$]</smbconfsection> share and create
3461 subdirectories.</para></listitem>
3463 <listitem><para>The printer you are going to setup for the Windows
3464 clients needs to be installed in CUPS already.</para></listitem>
3466 <listitem><para>
3467         <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
3468         <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3469                 The CUPS printer must be known to Samba, otherwise the
3470 <command>setdriver</command> subcommand fails with an
3471 NT_STATUS_UNSUCCESSFUL error. To check if the printer is known by
3472 Samba, you may use the <command>enumprinters</command> subcommand to
3473 <command>rpcclient</command>. A long-standing bug prevented a proper update of the
3474 printer list until every smbd process had received a SIGHUP or was
3475 restarted. Remember this in case you've created the CUPS printer just
3476 recently and encounter problems: try restarting
3477 Samba.</para></listitem>
3478 </itemizedlist>
3479 </sect2>
3481 <sect2>
3482 <title>Manual Driver Installation in 15 Steps</title>
3484 <para>
3485 We are going to install a printer driver now by manually executing all
3486 required commands. As this may seem a rather complicated process at
3487 first, we go through the procedure step by step, explaining every
3488 single action item as it comes up.
3489 </para>
3491 <procedure>
3492         <title>Manual Driver Installation</title>
3494 <step>
3495 <title>Install the printer on CUPS.</title>
3497 <para><screen>
3498 &rootprompt;<userinput>lpadmin -p mysmbtstprn -v socket://10.160.51.131:9100 -E \
3499                         -P canonIR85.ppd</userinput>
3500 </screen></para>
3502 <para>
3503 This installs a printer with the name <parameter>mysmbtstprn</parameter>
3504 to the CUPS system. The printer is accessed via a socket
3505 (a.k.a. JetDirect or Direct TCP/IP) connection. You need to be root
3506 for this step.
3507 </para>
3508 </step>
3510 <step>
3511 <title>(Optional) Check if the printer is recognized by Samba.</title>
3513 <para>
3514 <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3515 <screen>
3516         &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'enumprinters' localhost \
3517   | grep -C2 mysmbtstprn</userinput>
3518 flags:[0x800000]
3519 name:[\\kde-bitshop\mysmbtstprn]
3520 description:[\\kde-bitshop\mysmbtstprn,,mysmbtstprn]
3521 comment:[mysmbtstprn]
3522 </screen></para>
3524 <para>
3525 This should show the printer in the list. If not, stop and restart
3526 the Samba daemon (smbd), or send a HUP signal: 
3527 <screen>
3528 &rootprompt;<userinput>kill -HUP `pidof smbd`</userinput>
3529 </screen>Check again. Troubleshoot and repeat until
3530 successful. Note the <quote>empty</quote> field between the two commas in the
3531 <quote>description</quote> line. The driver name would appear here if there was one already. You need to know root's Samba password (as set by the
3532 <command>smbpasswd</command> command) for this step and most of the
3533 following steps. Alternately, you can authenticate as one of the
3534 users from the <quote>write list</quote> as defined in &smb.conf; for
3535 <smbconfsection>[print$]</smbconfsection>.
3536 </para>
3537 </step>
3539 <step>
3540 <title>(Optional) Check if Samba knows a driver for the printer.</title>
3542 <para>
3543         <indexterm><primary>rpcclient</primary><secondary>getprinter</secondary></indexterm>
3544         <indexterm><primary>rpcclient</primary><secondary>getdriver</secondary></indexterm>
3545         <screen>
3546 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' localhost \
3547                         | grep driver </userinput>
3548 drivername:[]
3550 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' localhost \
3551         | grep -C4 driv</userinput>
3552 servername:[\\kde-bitshop]
3553 printername:[\\kde-bitshop\mysmbtstprn]
3554 sharename:[mysmbtstprn]
3555 portname:[Samba Printer Port]
3556 drivername:[]
3557 comment:[mysmbtstprn]
3558 location:[]
3559 sepfile:[]
3560 printprocessor:[winprint]
3562 &rootprompt;<userinput>rpcclient -U root%xxxx -c 'getdriver mysmbtstprn' localhost</userinput>
3563  result was WERR_UNKNOWN_PRINTER_DRIVER
3565 </screen></para>
3567 <para>
3568 None of the three commands shown above should show a driver.
3569 This step was done for the purpose of demonstrating this condition. An
3570 attempt to connect to the printer at this stage will prompt the
3571 message along the lines of: <quote>The server does not have the required printer
3572 driver installed.</quote>
3573 </para>
3574 </step>
3576 <step>
3577 <title>Put all required driver files into Samba's
3578 [print$].</title>
3580 <para><screen>
3581 &rootprompt;<userinput>smbclient //localhost/print\$ -U 'root%xxxx' \
3582         -c 'cd W32X86; \
3583         put /etc/cups/ppd/mysmbtstprn.ppd mysmbtstprn.PPD; \ 
3584         put /usr/share/cups/drivers/cupsui.dll cupsui.dll; \
3585         put /usr/share/cups/drivers/cupsdrvr.dll cupsdrvr.dll; \
3586         put /usr/share/cups/drivers/cups.hlp cups.hlp'</userinput>
3587 </screen></para>
3589 <para>
3590 (This command should be entered in one long single
3591 line. Line-breaks and the line-end indicated by <quote>\</quote> have been inserted
3592 for readability reasons.) This step is <emphasis>required</emphasis>
3593 for the next one to succeed. It makes the driver files physically
3594 present in the <smbconfsection>[print$]</smbconfsection> share. However, clients
3595 would still not be able to install them, because Samba does not yet
3596 treat them as driver files. A client asking for the driver would still
3597 be presented with a <quote>not installed here</quote> message.
3598 </para>
3599 </step>
3601 <step>
3602 <title>Verify where the driver files are now.</title>
3604 <para><screen>
3605 &rootprompt;<userinput>ls -l /etc/samba/drivers/W32X86/</userinput>
3606 total 669
3607 drwxr-sr-x    2 root     ntadmin       532 May 25 23:08 2
3608 drwxr-sr-x    2 root     ntadmin       670 May 16 03:15 3
3609 -rwxr--r--    1 root     ntadmin     14234 May 25 23:21 cups.hlp
3610 -rwxr--r--    1 root     ntadmin    278380 May 25 23:21 cupsdrvr.dll
3611 -rwxr--r--    1 root     ntadmin    215848 May 25 23:21 cupsui.dll
3612 -rwxr--r--    1 root     ntadmin    169458 May 25 23:21 mysmbtstprn.PPD
3613 </screen></para>
3615 <para>
3616 The driver files now are in the W32X86 architecture <quote>root</quote> of
3617 <smbconfsection>[print$]</smbconfsection>.
3618 </para>
3619 </step>
3621 <step>
3622 <title>Tell Samba that these are driver files (<command>adddriver</command>).</title>
3624 <para>
3625 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3626 <screen>
3627 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'adddriver "Windows NT x86" \
3628         "mydrivername:cupsdrvr.dll:mysmbtstprn.PPD: \
3629   cupsui.dll:cups.hlp:NULL:RAW:NULL"' \
3630   localhost</userinput>
3631 Printer Driver mydrivername successfully installed.
3632 </screen></para>
3634 <para>
3635 You cannot repeat this step if it fails. It could fail even
3636 as a result of a simple typo. It will most likely have moved a part of
3637 the driver files into the <quote>2</quote> subdirectory. If this step fails, you
3638 need to go back to the fourth step and repeat it before you can try
3639 this one again. In this step, you need to choose a name for your
3640 driver. It is normally a good idea to use the same name as is used for
3641 the printer name; however, in big installations you may use this driver
3642 for a number of printers that obviously have different names, so the
3643 name of the driver is not fixed.
3644 </para>
3645 </step>
3647 <step>
3648 <title>Verify where the driver files are now.</title>
3650 <para><screen>
3651 &rootprompt;<userinput>ls -l /etc/samba/drivers/W32X86/</userinput>
3652 total 1
3653 drwxr-sr-x    2 root     ntadmin       532 May 25 23:22 2
3654 drwxr-sr-x    2 root     ntadmin       670 May 16 03:15 3
3656 &rootprompt;<userinput>ls -l /etc/samba/drivers/W32X86/2</userinput>
3657 total 5039
3658 [....]
3659 -rwxr--r--    1 root     ntadmin     14234 May 25 23:21 cups.hlp
3660 -rwxr--r--    1 root     ntadmin    278380 May 13 13:53 cupsdrvr.dll
3661 -rwxr--r--    1 root     ntadmin    215848 May 13 13:53 cupsui.dll
3662 -rwxr--r--    1 root     ntadmin    169458 May 25 23:21 mysmbtstprn.PPD
3663 </screen></para>
3665 <para>
3666 Notice how step 6 also moved the driver files to the appropriate
3667 subdirectory. Compare this with the situation after step 5.
3668 </para>
3669 </step>
3671 <step>
3672 <title>(Optional) Verify if Samba now recognizes the driver.</title>
3674 <para>
3675 <indexterm><primary>rpcclient</primary><secondary>enumdrivers</secondary></indexterm>
3676 <screen>
3677 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'enumdrivers 3' \
3678         localhost | grep -B2 -A5 mydrivername</userinput>
3679 Printer Driver Info 3:
3680 Version: [2]
3681 Driver Name: [mydrivername]
3682 Architecture: [Windows NT x86]
3683 Driver Path: [\\kde-bitshop\print$\W32X86\2\cupsdrvr.dll]
3684 Datafile: [\\kde-bitshop\print$\W32X86\2\mysmbtstprn.PPD]
3685 Configfile: [\\kde-bitshop\print$\W32X86\2\cupsui.dll]
3686 Helpfile: [\\kde-bitshop\print$\W32X86\2\cups.hlp]
3687 </screen></para>
3689 <para>
3690 Remember, this command greps for the name you chose for the
3691 driver in step 6. This command must succeed before you can proceed.
3692 </para>
3693 </step>
3695 <step>
3696 <para>Tell Samba which printer should use these driver files (<command>setdriver</command>).</para>
3699 <para>
3700 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
3701 <screen>
3702 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'setdriver mysmbtstprn mydrivername' \
3703         localhost</userinput>
3704 Successfully set mysmbtstprn to driver mydrivername
3705 </screen></para>
3707 <para>
3708 Since you can bind any printername (print queue) to any driver, this
3709 is a convenient way to setup many queues that use the same
3710 driver. You do not need to repeat all the previous steps for the
3711 setdriver command to succeed. The only preconditions are:
3712 <command>enumdrivers</command> must find the driver and
3713 <command>enumprinters</command> must find the printer.
3714 </para>
3715 </step>
3717 <step>
3718         <title>(Optional) Verify if Samba has recognized this association.</title>
3720 <para>
3721 <indexterm><primary>rpcclient</primary><secondary>getprinter</secondary></indexterm>
3722 <indexterm><primary>rpcclient</primary><secondary>getdriver</secondary></indexterm>
3723 <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3724 <screen>
3725 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' localhost \
3726   | grep driver</userinput>
3727 drivername:[mydrivername]
3729 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' localhost \
3730   | grep -C4 driv</userinput>
3731 servername:[\\kde-bitshop]
3732 printername:[\\kde-bitshop\mysmbtstprn]
3733 sharename:[mysmbtstprn]
3734 portname:[Done]
3735 drivername:[mydrivername]
3736 comment:[mysmbtstprn]
3737 location:[]
3738 sepfile:[]
3739 printprocessor:[winprint]
3741 &rootprompt;<userinput>rpcclient -U root%xxxx -c 'getdriver mysmbtstprn' localhost</userinput>
3742 [Windows NT x86]
3743 Printer Driver Info 3:
3744      Version: [2]
3745      Driver Name: [mydrivername]
3746      Architecture: [Windows NT x86]
3747      Driver Path: [\\kde-bitshop\print$\W32X86\2\cupsdrvr.dll]
3748      Datafile: [\\kde-bitshop\print$\W32X86\2\mysmbtstprn.PPD]
3749      Configfile: [\\kde-bitshop\print$\W32X86\2\cupsui.dll]
3750      Helpfile: [\\kde-bitshop\print$\W32X86\2\cups.hlp]
3751      Monitorname: []
3752      Defaultdatatype: [RAW]
3753      Monitorname: []
3754      Defaultdatatype: [RAW]
3756 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'enumprinters' localhost \
3757         | grep mysmbtstprn</userinput>
3758      name:[\\kde-bitshop\mysmbtstprn]
3759      description:[\\kde-bitshop\mysmbtstprn,mydrivername,mysmbtstprn]
3760      comment:[mysmbtstprn]
3762 </screen></para>
3764 <para>
3765 <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3766 Compare these results with the ones from steps 2 and 3. Every one of these commands show the driver is installed. Even
3767 the <command>enumprinters</command> command now lists the driver
3768 on the <quote>description</quote> line.
3769 </para>
3770 </step>
3772 <step>
3773 <title>(Optional) Tickle the driver into a correct
3774 device mode.</title>
3776 <para>
3777 <indexterm><primary>"Printers" folder</primary></indexterm>
3778 You certainly know how to install the driver on the client. In case
3779 you are not particularly familiar with Windows, here is a short
3780 recipe: Browse the Network Neighborhood, go to the Samba server, and look
3781 for the shares. You should see all shared Samba printers.
3782 Double-click on the one in question. The driver should get
3783 installed and the network connection set up. An alternate way is to
3784 open the <guilabel>Printers (and Faxes)</guilabel> folder, right-click on the printer in
3785 question and select <guilabel>Connect</guilabel> or <guilabel>Install</guilabel>. As a result, a new printer
3786 should have appeared in your client's local <guilabel>Printers (and Faxes)</guilabel>
3787 folder, named something like <guilabel>printersharename on Sambahostname</guilabel>.
3788 </para>
3790 <para>
3791 It is important that you execute this step as a Samba printer admin
3792 (as defined in &smb.conf;). Here is another method
3793 to do this on Windows XP. It uses a command line, which you may type
3794 into the <quote>DOS box</quote> (type root's smbpassword when prompted):
3795 </para>
3797 <para><screen>
3798 &dosprompt;<userinput>runas /netonly /user:root "rundll32 printui.dll,PrintUIEntry \
3799         /in /n \\sambaserver\mysmbtstprn"</userinput>
3800 </screen></para>
3802 <para>
3803 Change any printer setting once (like changing <emphasis><guilabel>portrait</guilabel> to
3804         <guilabel>landscape</guilabel></emphasis>), click on <guibutton>Apply</guibutton>; change the setting
3805 back.
3806 </para>
3807 </step>
3809 <step>
3810 <title>Install the printer on a client
3811 (Point'n'Print).</title>
3814 <para>
3815 <indexterm significance="preferred"><primary>point 'n' print</primary></indexterm>
3816         <screen>
3817 &dosprompt;<userinput>rundll32 printui.dll,PrintUIEntry /in /n &quot;\\sambaserver\mysmbtstprn&quot;</userinput>
3818 </screen></para>
3820 <para>
3821 If it does not work it could be a permission problem with the
3822 <smbconfsection>[print$]</smbconfsection> share.
3823 </para>
3824 </step>
3826 <step>
3827 <title>(Optional) Print a test page.</title>
3829 <para><screen>
3830 &dosprompt;<userinput>rundll32 printui.dll,PrintUIEntry /p /n "\\sambaserver\mysmbtstprn"</userinput>
3831 </screen></para>
3833 <para>
3834 Then hit [TAB] five times, [ENTER] twice, [TAB] once and [ENTER] again
3835 and march to the printer.
3836 </para>
3837 </step>
3839 <step>
3840 <title>(Recommended) Study the test page.</title>
3842 <para>
3843 Hmmm.... just kidding! By now you know everything about printer
3844 installations and you do not need to read a word. Just put it in a
3845 frame and bolt it to the wall with the heading "MY FIRST
3846 RPCCLIENT-INSTALLED PRINTER" &smbmdash; why not just throw it away!
3847 </para>
3848 </step>
3850 <step>
3851 <title>(Obligatory) Enjoy. Jump. Celebrate your
3852 success.</title>
3854 <para><screen>
3855 &rootprompt;<userinput>echo "Cheeeeerioooooo! Success..." &gt;&gt; /var/log/samba/log.smbd</userinput>
3856 </screen></para>
3857 </step>
3858 </procedure>
3859 </sect2>
3861 <sect2>
3862 <title>Troubleshooting Revisited</title>
3864 <para>
3865 The setdriver command will fail, if in Samba's mind the queue is not
3866 already there. You had promising messages about the:
3867 </para>
3869 <para><screen>
3870  Printer Driver ABC successfully installed.
3871 </screen></para>
3873 <para>
3874 after the <command>adddriver</command> parts of the procedure?  But you are also seeing
3875 a disappointing message like this one?
3876 </para>
3878 <para><computeroutput>
3879  result was NT_STATUS_UNSUCCESSFUL
3880 </computeroutput></para>
3882 <para>
3883 <indexterm><primary>lpstat</primary></indexterm>
3884 It is not good enough that you
3885 can see the queue in CUPS, using
3886 the <command>lpstat -p ir85wm</command> command. A
3887 bug in most recent versions of Samba prevents the proper update of
3888 the queue-list. The recognition of newly installed CUPS printers
3889 fails unless you restart Samba or send a HUP to all smbd
3890 processes. To verify if this is the reason why Samba does not
3891 execute the <command>setdriver</command> command successfully, check if Samba <quote>sees</quote>
3892 the printer: 
3893 </para>
3895 <para>
3896 <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3897         <screen>
3898 &rootprompt;<userinput>rpcclient transmeta -N -U'root%xxxx' -c 'enumprinters 0'|grep ir85wm</userinput>
3899         printername:[ir85wm]
3900 </screen></para>
3902 <para>
3903 An alternate command could be this: 
3904 </para>
3906 <para>
3907 <indexterm><primary>rpcclient</primary><secondary>getprinter</secondary></indexterm>
3908         <screen>
3909 &rootprompt;<userinput>rpcclient transmeta -N -U'root%secret' -c 'getprinter ir85wm' </userinput>
3910         cmd = getprinter ir85wm
3911         flags:[0x800000]
3912         name:[\\transmeta\ir85wm]
3913         description:[\\transmeta\ir85wm,ir85wm,DPD]
3914         comment:[CUPS PostScript-Treiber for Windows NT/200x/XP]
3915 </screen></para>
3917 <para>
3918 By the way, you can use these commands, plus a few more, of course,
3919 to install drivers on remote Windows NT print servers too!
3920 </para>
3921 </sect2>
3922 </sect1>
3924 <sect1>
3925 <title>The Printing <filename>*.tdb</filename> Files</title>
3927 <para>
3928 <indexterm><primary>TDB</primary></indexterm>
3929 <indexterm><primary>connections.tdb</primary><seealso>TDB</seealso></indexterm>
3930 <indexterm><primary>printing.tdb</primary><seealso>TDB</seealso></indexterm>
3931 <indexterm><primary>share_info.tdb</primary><seealso>TDB</seealso></indexterm>
3932 <indexterm><primary>ntdrivers.tdb</primary><seealso>TDB</seealso></indexterm>
3933 <indexterm><primary>unexpected.tdb</primary><seealso>TDB</seealso></indexterm>
3934 <indexterm><primary>brlock.tdb</primary><seealso>TDB</seealso></indexterm>
3935 <indexterm><primary>locking.tdb</primary><seealso>TDB</seealso></indexterm>
3936 <indexterm><primary>ntforms.tdb</primary><seealso>TDB</seealso></indexterm>
3937 <indexterm><primary>messages.tdb</primary><seealso>TDB</seealso></indexterm>
3938 <indexterm><primary>ntprinters.tdb</primary><seealso>TDB</seealso></indexterm>
3939 <indexterm><primary>sessionid.tdb</primary><seealso>TDB</seealso></indexterm>
3940 <indexterm><primary>secrets.tdb</primary><seealso>TDB</seealso></indexterm>
3941 Some mystery is associated with the series of files with a
3942 tdb suffix appearing in every Samba installation. They are
3943 <filename>connections.tdb</filename>,
3944 <filename>printing.tdb</filename>,
3945 <filename>share_info.tdb</filename>,
3946 <filename>ntdrivers.tdb</filename>,
3947 <filename>unexpected.tdb</filename>,
3948 <filename>brlock.tdb</filename>,
3949 <filename>locking.tdb</filename>,
3950 <filename>ntforms.tdb</filename>,
3951 <filename>messages.tdb</filename> ,
3952 <filename>ntprinters.tdb</filename>,
3953 <filename>sessionid.tdb</filename> and
3954 <filename>secrets.tdb</filename>. What is their purpose?
3955 </para>
3957 <sect2>
3958 <title>Trivial Database Files</title>
3960 <para>
3961 <indexterm><primary>TDB</primary></indexterm>
3962 A Windows NT (print) server keeps track of all information needed to serve
3963 its duty toward its clients by storing entries in the Windows
3964 registry. Client queries are answered by reading from the registry,
3965 Administrator or user configuration settings that are saved by writing into
3966 the registry. Samba and UNIX obviously do not have such a
3967 Registry. Samba instead keeps track of all client related information in a
3968 series of <filename>*.tdb</filename> files. (TDB = Trivial Data
3969 Base). These are often located in <filename>/var/lib/samba/</filename>
3970 or <filename>/var/lock/samba/</filename>. The printing related files
3971 are <filename>ntprinters.tdb</filename>,
3972 <filename>printing.tdb</filename>,<filename>ntforms.tdb</filename> and
3973 <filename>ntdrivers.tdb</filename>.
3974 </para>
3975 </sect2>
3977 <sect2>
3978 <title>Binary Format</title>
3980 <para>
3981 <filename>*.tdb</filename> files are not human readable. They are
3982 written in a binary format. <quote>Why not ASCII?</quote>, you may ask. <quote>After all,
3983 ASCII configuration files are a good and proven tradition on UNIX.</quote>
3984 The reason for this design decision by the Samba team is mainly
3985 performance. Samba needs to be fast; it runs a separate
3986 <command>smbd</command> process for each client connection, in some
3987 environments many thousands of them. Some of these smbds might need to
3988 write-access the same <filename>*.tdb</filename> file <emphasis>at the
3989 same time</emphasis>. The file format of Samba's
3990 <filename>*.tdb</filename> files allows for this provision. Many smbd
3991 processes may write to the same <filename>*.tdb</filename> file at the
3992 same time. This wouldn't be possible with pure ASCII files.
3993 </para>
3994 </sect2>
3996 <sect2>
3997 <title>Losing <filename>*.tdb</filename> Files</title>
3999 <para>
4000 It is very important that all <filename>*.tdb</filename> files remain
4001 consistent over all write and read accesses. However, it may happen
4002 that these files <emphasis>do</emphasis> get corrupted. (A
4003 <command>kill -9 `pidof smbd'</command> while a write access is in
4004 progress could do the damage as well as a power interruption,
4005 etc.). In cases of trouble, a deletion of the old printing-related
4006 <filename>*.tdb</filename> files may be the only option. After that you need to
4007 re-create all print-related setup or you have made a
4008 backup of the <filename>*.tdb</filename> files in time.
4009 </para>
4010 </sect2>
4012 <sect2>
4013 <title>Using <command>tdbbackup</command></title>
4016 <para>
4017 <indexterm><primary>TDB</primary><secondary>backing up</secondary><see>tdbbackup</see></indexterm>
4018 <indexterm><primary>tdbbackup</primary></indexterm>
4019 Samba ships with a little utility that helps the root user of your
4020 system to backup your <filename>*.tdb</filename> files. If you run it
4021 with no argument, it prints a usage message:
4022 </para>
4024 <para><screen>
4025 &rootprompt;<userinput>tdbbackup</userinput>
4026  Usage: tdbbackup [options] &lt;fname...&gt;
4028  Version:3.0a
4029    -h            this help message
4030    -s suffix     set the backup suffix
4031    -v            verify mode (restore if corrupt)
4033 </screen></para>
4035 <para>
4036 Here is how I backed up my <filename>printing.tdb</filename> file:
4037 </para>
4039 <para><screen>
4040 &rootprompt;<userinput>ls</userinput>
4041 .              browse.dat     locking.tdb     ntdrivers.tdb printing.tdb
4042 ..             share_info.tdb connections.tdb messages.tdb  ntforms.tdb
4043 printing.tdbkp unexpected.tdb brlock.tdb      gmon.out      namelist.debug  
4044 ntprinters.tdb sessionid.tdb
4046 &rootprompt;<userinput>tdbbackup -s .bak printing.tdb</userinput>
4047  printing.tdb : 135 records
4049 &rootprompt;<userinput>ls -l printing.tdb*</userinput>
4050  -rw-------    1 root     root        40960 May  2 03:44 printing.tdb
4051  -rw-------    1 root     root        40960 May  2 03:44 printing.tdb.bak
4053 </screen></para>
4054 </sect2>
4055 </sect1>
4057 <sect1>
4058 <title>CUPS Print Drivers from Linuxprinting.org</title>
4061 <para>
4062 <indexterm><primary>Linuxprinting.org</primary></indexterm>
4063 CUPS ships with good support for HP LaserJet-type printers. You can
4064 install the generic driver as follows:
4065 </para>
4068 <para>
4069 <indexterm><primary>lpadmin</primary></indexterm>
4070         <screen>
4071 &rootprompt;<userinput>lpadmin -p laserjet4plus -v parallel:/dev/lp0 -E -m laserjet.ppd</userinput>
4072 </screen></para>
4074 <para>
4075 The <option>-m</option> switch will retrieve the
4076 <filename>laserjet.ppd</filename> from the standard repository for
4077 not-yet-installed-PPDs, which CUPS typically stores in
4078 <filename>/usr/share/cups/model</filename>. Alternately, you may use
4079 <option>-P /path/to/your.ppd</option>.
4080 </para>
4082 <para>
4083 The generic <filename>laserjet.ppd,</filename> however, does not support every special option
4084 for every LaserJet-compatible model. It constitutes a sort of <quote>least common
4085 denominator</quote> of all the models. If for some reason
4086 you must pay for the commercially available ESP Print Pro drivers, your
4087 first move should be to consult the database on the
4088 <ulink noescape="1" url="http://www.linuxprinting.org/printer_list.cgi">Linuxprinting</ulink> web site.
4089 Linuxprinting.org has excellent recommendations about which driver is
4090 best used for each printer. Its database is kept current by the
4091 tireless work of Till Kamppeter from MandrakeSoft, who is also the
4092 principal author of the <command>foomatic-rip</command> utility.
4093 </para>
4095 <note><para>
4096 <indexterm><primary>foomatic-rip</primary></indexterm>
4097 The former <command>cupsomatic</command> concept is now being replaced by the new
4098 successor, a much
4099 more powerful <command>foomatic-rip</command>.
4100 <command>cupsomatic</command> is no longer maintained. Here is the new URL
4101 to the <ulink noescape="1" url="http://www.linuxprinting.org/driver_list.cgi">Foomatic-3.0</ulink> database.
4102 If you upgrade to <command>foomatic-rip</command>, remember to also upgrade to the
4103 new-style PPDs for your Foomatic-driven printers. foomatic-rip will
4104 not work with PPDs generated for the old <command>cupsomatic</command>. The new-style
4105 PPDs are 100% compliant to the Adobe PPD specification. They are
4106 also intended to be used by Samba and the cupsaddsmb utility, to
4107 provide the driver files for the Windows clients!
4108 </para></note>
4110 <sect2>
4111 <title>foomatic-rip and Foomatic Explained</title>
4114 <para>
4115 <indexterm significance="preferred"><primary>foomatic</primary></indexterm>
4116 <indexterm significance="preferred"><primary>foomatic-rip</primary></indexterm>
4117 Nowadays, most Linux distributions rely on the utilities of Linuxprinting.org
4118 to create their printing-related software (which, by the way, works on all
4119 UNIXes and on Mac OS X or Darwin, too). It is not known as well as it
4120 should be, that it also has a very end-user-friendly interface that
4121 allows for an easy update of drivers and PPDs for all supported
4122 models, all spoolers, all operating systems, and all package formats
4123 (because there is none). Its history goes back a few years.
4124 </para>
4126 <para>
4127 Recently, Foomatic has achieved the astonishing milestone of <ulink
4128 url="http://www.linuxprinting.org/printer_list.cgi?make=Anyone">1000
4129 listed</ulink> printer models. Linuxprinting.org keeps all the
4130 important facts about printer drivers, supported models and which
4131 options are available for the various driver/printer combinations in
4132 its <ulink
4133 url="http://www.linuxprinting.org/foomatic.html">Foomatic</ulink>
4134 database. Currently there are <ulink
4135 url="http://www.linuxprinting.org/driver_list.cgi">245 drivers</ulink>
4136 in the database. Many drivers support various models, and many models
4137 may be driven by different drivers &smbmdash; its your choice!
4138 </para>
4140 <sect3>
4141 <title>690 <quote>Perfect</quote> Printers</title>
4143 <para>
4144 At present, there are 690 devices dubbed as working perfectly, 181
4145 mostly, 96 partially, and 46 are paperweights. Keeping in mind
4146 that most of these are non-PostScript models (PostScript printers are
4147 automatically supported by CUPS to perfection, by using
4148 their own manufacturer-provided Windows-PPD), and that a
4149 multi-functional device never qualifies as working perfectly if it
4150 does not also scan and copy and fax under GNU/Linux &smbmdash; then this is a
4151 truly astonishing achievement! Three years ago the number was not
4152 more than 500, and Linux or UNIX printing at the time wasn't
4153 anywhere near the quality it is today.
4154 </para>
4155 </sect3>
4157 <sect3>
4158 <title>How the Printing HOWTO Started It All</title>
4160 <para>
4161 A few years ago <ulink url="http://www2.picante.com:81/~gtaylor/">Grant Taylor</ulink>
4162 started it all. The roots of today's Linuxprinting.org are in the
4163 first <ulink url="http://www.linuxprinting.org/foomatic2.9/howto/">Linux Printing
4164 HOWTO</ulink> that he authored. As a side-project to this document,
4165 which served many Linux users and Admins to guide their first steps in
4166 this complicated and delicate setup (to a scientist, printing is
4167 <quote>applying a structured deposition of distinct patterns of ink or toner
4168 particles on paper substrates</quote>, he started to
4169 build in a little Postgres database with information about the
4170 hardware and driver zoo that made up Linux printing of the time. This
4171 database became the core component of today's Foomatic collection of
4172 tools and data. In the meantime, it has moved to an XML representation
4173 of the data.
4174 </para>
4175 </sect3>
4177 <sect3>
4178 <title>Foomatic's Strange Name</title>
4181 <para>
4182 <indexterm><primary>foomatic</primary></indexterm>
4183 <quote>Why the funny name?</quote> you ask. When it really took off, around spring
4184 2000, CUPS was far less popular than today, and most systems used LPD,
4185 LPRng or even PDQ to print. CUPS shipped with a few generic drivers
4186 (good for a few hundred different printer models). These didn't
4187 support many device-specific options. CUPS also shipped with its own
4188 built-in rasterization filter (<parameter>pstoraster</parameter>, derived from
4189 Ghostscript). On the other hand, CUPS provided brilliant support for
4190 <emphasis>controlling</emphasis> all printer options through
4191 standardized and well-defined PPD files (PostScript Printers
4192 Description files). Plus, CUPS was designed to be easily extensible.
4193 </para>
4195 <para>
4196 Taylor already had in his database a respectable compilation
4197 of facts about many more printers and the Ghostscript <quote>drivers</quote>
4198 they run with. His idea, to generate PPDs from the database information
4199 and use them to make standard Ghostscript filters work within CUPS,
4200 proved to work very well. It also killed several birds with one
4201 stone:
4202 </para>
4204 <itemizedlist>
4205 <listitem><para>It made all current and future Ghostscript filter
4206 developments available for CUPS.</para></listitem>
4208 <listitem><para>It made available a lot of additional printer models
4209 to CUPS users (because often the traditional Ghostscript way of
4210 printing was the only one available).</para></listitem>
4212 <listitem><para>It gave all the advanced CUPS options (Web interface,
4213 GUI driver configurations) to users wanting (or needing) to use
4214 Ghostscript filters.</para></listitem>
4215 </itemizedlist>
4216 </sect3>
4218 <sect3>
4219 <title>cupsomatic, pdqomatic, lpdomatic, directomatic</title>
4222 <para>
4223 <indexterm><primary>cupsomatic</primary></indexterm>
4224 <indexterm><primary>CUPS-PPD</primary></indexterm>
4225 <indexterm><primary>PPD</primary><secondary>CUPS</secondary><see>CUPS-PPD</see></indexterm>
4226 CUPS worked through a quickly-hacked up filter script named <ulink
4227 url="http://www.linuxprinting.org/download.cgi?filename=cupsomatic&amp;show=0">cupsomatic.</ulink>
4228 cupsomatic ran the printfile through Ghostscript, constructing
4229 automatically the rather complicated command line needed. It just
4230 needed to be copied into the CUPS system to make it work. To
4231 configure the way cupsomatic controls the Ghostscript rendering
4232 process, it needs a CUPS-PPD. This PPD is generated directly from the
4233 contents of the database. For CUPS and the respective printer/filter
4234 combo, another Perl script named CUPS-O-Matic did the PPD
4235 generation. After that was working, Taylor implemented within a few
4236 days a similar thing for two other spoolers. Names chosen for the
4237 config-generator scripts were <ulink
4238 url="http://www.linuxprinting.org/download.cgi?filename=lpdomatic&amp;show=0">PDQ-O-Matic</ulink>
4239 (for PDQ) and <ulink
4240 url="http://www.linuxprinting.org/download.cgi?filename=lpdomatic&amp;show=0">LPD-O-Matic</ulink>
4241 (for &smbmdash; you guessed it &smbmdash; LPD); the configuration here didn't use PPDs
4242 but other spooler-specific files.
4243 </para>
4245 <para>
4246 From late summer of that year, <ulink url="http://www.linuxprinting.org/till/">Till Kamppeter</ulink>
4247 started to put work into the database. Kamppeter had been newly employed by
4248 <ulink url="http://www.mandrakesoft.com/">MandrakeSoft</ulink> to
4249 convert its printing system over to CUPS, after they had seen his
4250 <ulink url="http://www.fltk.org/">FLTK</ulink>-based <ulink
4251 url="http://cups.sourceforge.net/xpp/">XPP</ulink> (a GUI front-end to
4252 the CUPS lp-command). He added a huge amount of new information and new
4253 printers. He also developed the support for other spoolers, like
4254 <ulink url="http://ppr.sourceforge.net/">PPR</ulink> (via ppromatic),
4255 <ulink url="http://sourceforge.net/projects/lpr/">GNUlpr</ulink> and
4256 <ulink url="http://www.lprng.org/">LPRng</ulink> (both via an extended
4257 lpdomatic) and spooler-less printing (<ulink
4258 url="http://www.linuxprinting.org/download.cgi?filename=directomatic&amp;show=0">directomatic</ulink>).
4259 </para>
4261 <para>
4262 So, to answer your question: <quote>Foomatic</quote> is the general name for all
4263 the overlapping code and data behind the <quote>*omatic</quote> scripts.
4264 Foomatic, up to versions 2.0.x, required (ugly) Perl data structures
4265 attached to Linuxprinting.org PPDs for CUPS. It had a different
4266 <quote>*omatic</quote> script for every spooler, as well as different printer
4267 configuration files.
4268 </para>
4269 </sect3>
4271 <sect3>
4272 <title>The <emphasis>Grand Unification</emphasis> Achieved</title>
4275 <para>
4276 <indexterm><primary>foomatic-rip</primary></indexterm>
4277 This has all changed in Foomatic versions 2.9 (beta) and released as
4278 <quote>stable</quote> 3.0. It has now achieved the convergence of all *omatic
4279 scripts and is called the <ulink
4280 url="http://www.linuxprinting.org/foomatic2.9/download.cgi?filename=foomatic-rip&amp;show=0">foomatic-rip.</ulink>
4281 This single script is the unification of the previously different
4282 spooler-specific *omatic scripts. foomatic-rip is used by all the
4283 different spoolers alike and because it can read PPDs (both the
4284 original PostScript printer PPDs and the Linuxprinting.org-generated
4285 ones), all of a sudden all supported spoolers can have the power of
4286 PPDs at their disposal. Users only need to plug foomatic-rip into
4287 their system. For users there is improved media type and source
4288 support &smbmdash; paper sizes and trays are easier to configure.
4289 </para>
4291 <para>
4292 Also, the New Generation of Linuxprinting.org PPDs no longer contains
4293 Perl data structures. If you are a distro maintainer and have
4294 used the previous version of Foomatic, you may want to give the new
4295 one a spin, but remember to generate a new-version set of PPDs
4296 via the new <ulink
4297 url="http://www.linuxprinting.org/download/foomatic/foomatic-db-engine-3.0.0beta1.tar.gz">foomatic-db-engine!</ulink>
4298 Individual users just need to generate a single new PPD specific to
4299 their model by <ulink
4300 url="http://www.linuxprinting.org/kpfeifle/LinuxKongress2002/Tutorial/II.Foomatic-User/II.tutorial-handout-foomatic-user.html">following
4301 the steps</ulink> outlined in the Foomatic tutorial or in this chapter. This new development is truly amazing.
4302 </para>
4304 <para>
4305 foomatic-rip is a very clever wrapper around the need to run
4306 Ghostscript with a different syntax, options, device selections, and/or filters for each different printer
4307 or spooler. At the same time it can read the PPD associated
4308 with a print queue and modify the print job according to the user
4309 selections. Together with this comes the 100% compliance of the new
4310 Foomatic PPDs with the Adobe spec. Some innovative features of
4311 the Foomatic concept may surprise users. It will support custom paper
4312 sizes for many printers and will support printing on media drawn
4313 from different paper trays within the same job (in both cases, even
4314 where there is no support for this from Windows-based vendor printer
4315 drivers).
4316 </para>
4317 </sect3>
4319 <sect3>
4320 <title>Driver Development Outside</title>
4322 <para>
4323 Most driver development itself does not happen within
4324 Linuxprinting.org. Drivers are written by independent maintainers.
4325 Linuxprinting.org just pools all the information and stores it in its
4326 database. In addition, it also provides the Foomatic glue to integrate
4327 the many drivers into any modern (or legacy) printing system known to
4328 the world.
4329 </para>
4331 <para>
4332 Speaking of the different driver development groups, most of
4333 the work is currently done in three projects. These are:
4334 </para>
4336 <itemizedlist>
4337 <listitem><para><ulink
4338 url="http://www-124.ibm.com/developerworks/oss/linux/projects/omni/">Omni</ulink>
4339 &smbmdash; a free software project by IBM that tries to convert their printer
4340 driver knowledge from good-ol' OS/2 times into a modern, modular,
4341 universal driver architecture for Linux/UNIX (still beta). This
4342 currently supports 437 models.</para></listitem>
4344 <listitem><para><ulink url="http://hpinkjet.sf.net/">HPIJS</ulink> &smbmdash;
4345 a free software project by HP to provide the support for their own
4346 range of models (very mature, printing in most cases is perfect and
4347 provides true photo quality). This currently supports 369
4348 models.</para></listitem>
4350 <listitem><para><ulink
4351 url="http://gimp-print.sf.net/">Gimp-Print</ulink> &smbmdash; a free software
4352 effort, started by Michael Sweet (also lead developer for CUPS), now
4353 directed by Robert Krawitz, which has achieved an amazing level of
4354 photo print quality (many Epson users swear that its quality is
4355 better than the vendor drivers provided by Epson for the Microsoft
4356 platforms). This currently supports 522 models.</para></listitem>
4357 </itemizedlist>
4358 </sect3>
4360 <sect3>
4361 <title>Forums, Downloads, Tutorials, Howtos &smbmdash; also for Mac OS X and Commercial UNIX</title>
4363 <para>
4364 Linuxprinting.org today is the one-stop shop to download printer
4365 drivers. Look for printer information and <ulink
4366 url="http://www.linuxprinting.org//kpfeifle/LinuxKongress2002/Tutorial/">tutorials</ulink>
4367 or solve printing problems in its popular <ulink
4368 url="http://www.linuxprinting.org/newsportal/">forums.</ulink> This forum 
4369 it's not just for GNU/Linux users, but admins of <ulink
4370 url="http://www.linuxprinting.org/macosx/">commercial UNIX
4371 systems</ulink> are also going there, and the relatively new <ulink
4372 url="http://www.linuxprinting.org/newsportal/thread.php3?name=linuxprinting.macosx.general">Mac
4373 OS X forum</ulink> has turned out to be one of the most frequented
4374 forums after only a few weeks.
4375 </para>
4377 <para>
4378 Linuxprinting.org and the Foomatic driver wrappers around Ghostscript
4379 are now a standard tool-chain for printing on all the important
4380 distros. Most of them also have CUPS underneath. While in recent years
4381 most printer data had been added by Kamppeter (who works at Mandrake), many
4382 additional contributions came from engineers with SuSE, Red Hat,
4383 Conectiva, Debian, and others. Vendor-neutrality is an important goal
4384 of the Foomatic project.
4385 </para>
4387 <note><para>
4388 Till Kamppeter from MandrakeSoft is doing an excellent job in his
4389 spare time to maintain Linuxprinting.org and Foomatic. So if you use
4390 it often, please send him a note showing your appreciation.
4391 </para></note>
4392 </sect3>
4394 <sect3>
4395 <title>Foomatic Database-Generated PPDs</title>
4397 <para>
4398 The Foomatic database is an amazing piece of ingenuity in itself. Not
4399 only does it keep the printer and driver information, but it is
4400 organized in a way that it can generate PPD files on the fly from
4401 its internal XML-based datasets. While these PPDs are modeled to the
4402 Adobe specification of PostScript Printer Descriptions (PPDs), the
4403 Linuxprinting.org/Foomatic-PPDs do not normally drive PostScript
4404 printers. They are used to describe all the bells and whistles you
4405 could ring or blow on an Epson Stylus inkjet, or a HP Photosmart, or
4406 what-have-you. The main trick is one little additional line, not
4407 envisaged by the PPD specification, starting with the <parameter>*cupsFilter</parameter>
4408 keyword. It tells the CUPS daemon how to proceed with the PostScript
4409 print file (old-style Foomatic-PPDs named the
4410 cupsomatic filter script, while the new-style
4411 PPDs are now call foomatic-rip). This filter
4412 script calls Ghostscript on the host system (the recommended variant
4413 is ESP Ghostscript) to do the rendering work. foomatic-rip knows which
4414 filter or internal device setting it should ask from Ghostscript to
4415 convert the PostScript print job into a raster format ready for the
4416 target device. This usage of PPDs to describe the options of non-PS
4417 printers was the invention of the CUPS developers. The rest is easy.
4418 GUI tools (like KDE's marvelous <ulink
4419 url="http://printing.kde.org/overview/kprinter.phtml">kprinter,</ulink>
4420 or the GNOME <ulink
4421 url="http://gtklp.sourceforge.net/">gtklp,</ulink> xpp and the CUPS
4422 Web interface) read the PPD as well and use this information to present
4423 the available settings to the user as an intuitive menu selection.
4424 </para>
4425 </sect3>
4426 </sect2>
4428 <sect2>
4429 <title>foomatic-rip and Foomatic-PPD Download and Installation</title>
4431 <para>
4432 Here are the steps to install a foomatic-rip driven LaserJet 4 Plus-compatible
4433 printer in CUPS (note that recent distributions of SuSE, UnitedLinux and
4434 Mandrake may ship with a complete package of Foomatic-PPDs plus the
4435 <command>foomatic-rip</command> utility. Going directly to
4436 Linuxprinting.org ensures that you get the latest driver/PPD files):
4437 </para>
4439 <itemizedlist>
4440 <listitem><para>Open your browser at the Linuxprinting.org printer list<ulink url="http://www.linuxprinting.org/printer_list.cgi">page.</ulink>
4441 </para></listitem>
4443 <listitem><para>Check the complete list of printers in the 
4444 <ulink url="http://www.linuxprinting.org/printer_list.cgi?make=Anyone">database.</ulink>.
4445 </para></listitem>
4447 <listitem><para>Select your model and click on the link.
4448 </para></listitem>
4450 <listitem><para>You'll arrive at a page listing all drivers working with this
4451 model (for all printers, there will always be <emphasis>one</emphasis>
4452 recommended driver. Try this one first).
4453 </para></listitem>
4455 <listitem><para>In our case (HP LaserJet 4 Plus), we'll arrive at the default driver for the
4456 <ulink url="http://www.linuxprinting.org/show_printer.cgi?recnum=HP-LaserJet_4_Plus">HP-LaserJet 4 Plus.</ulink>
4457 </para></listitem>
4459 <listitem><para>The recommended driver is ljet4.</para></listitem>
4461 <listitem><para>Several links are provided here. You should visit them all if you
4462 are not familiar with the Linuxprinting.org database.
4463 </para></listitem>
4465 <listitem><para>There is a link to the database page for the
4466 <ulink url="http://www.linuxprinting.org/show_driver.cgi?driver=ljet4">ljet4.</ulink>
4467 On the driver's page, you'll find important and detailed information
4468 about how to use that driver within the various available
4469 spoolers.</para></listitem>
4471 <listitem><para>Another link may lead you to the home-page of the
4472 driver author or the driver.</para></listitem>
4474 <listitem><para>Important links are the ones that provide hints with
4475 setup instructions for <ulink noescape="1" url="http://www.linuxprinting.org/cups-doc.html">CUPS</ulink>,
4476 <ulink url="http://www.linuxprinting.org/pdq-doc.html">PDQ</ulink>,
4477 <ulink url="http://www.linuxprinting.org/lpd-doc.html">LPD, LPRng and GNUlpr</ulink>)
4478 as well as <ulink url="http://www.linuxprinting.org/ppr-doc.html">PPR</ulink>
4479 or <quote>spooler-less</quote> <ulink url="http://www.linuxprinting.org/direct-doc.html">printing.</ulink>
4480 </para></listitem>
4482 <listitem><para>You can view the PPD in your browser through this link:
4483 <ulink noescape="1" url="http://www.linuxprinting.org/ppd-o-matic.cgi?driver=ljet4&amp;printer=HP-LaserJet_4_Plus&amp;show=1">http://www.linuxprinting.org/ppd-o-matic.cgi?driver=ljet4&amp;printer=HP-LaserJet_4_Plus&amp;show=1</ulink>
4484 </para></listitem> <listitem><para>Most importantly, you can also generate and download
4485 the <ulink url="http://www.linuxprinting.org/ppd-o-matic.cgi?driver=ljet4&amp;printer=HP-LaserJet_4_Plus&amp;show=0">PPD.</ulink>
4486 </para></listitem>
4488 <listitem><para>The PPD contains all the information needed to use our
4489 model and the driver; once installed, this works transparently
4490 for the user. Later you'll only need to choose resolution, paper size,
4491 and so on from the Web-based menu, or from the print dialog GUI, or from
4492 the command line.</para></listitem>
4494 <listitem><para>If you ended up on the drivers
4495 <ulink url="http://www.linuxprinting.org/show_driver.cgi?driver=ljet4">page</ulink>
4496 you can choose to use the <quote>PPD-O-Matic</quote> online PPD generator
4497 program.</para></listitem>
4499 <listitem><para>Select the exact model and check either <guilabel>Download</guilabel> or
4500 <guilabel>Display PPD file</guilabel> and click <guilabel>Generate PPD file</guilabel>.</para></listitem>
4502 <listitem><para>If you save the PPD file from the browser view, please
4503 do not use cut and paste (since it could possibly damage line endings
4504 and tabs, which makes the PPD likely to fail its duty), but use <guimenuitem>Save
4505 as...</guimenuitem> in your browsers menu. (It is best to use the <guilabel>Download</guilabel> option
4506 directly from the Web page).</para></listitem>
4508 <listitem><para>Another interesting part on each driver page is
4509 the <guimenuitem>Show execution details</guimenuitem> button. If you
4510 select your printer model and click on that button,
4511 a complete Ghostscript command line will be displayed, enumerating all options
4512 available for that combination of driver and printer model. This is a great way to
4513 <quote>learn Ghostscript by doing</quote>. It is also an excellent cheat sheet
4514 for all experienced users who need to re-construct a good command line
4515 for that damn printing script, but can't remember the exact
4516 syntax. </para></listitem>
4518 <listitem><para>Some time during your visit to Linuxprinting.org, save
4519 the PPD to a suitable place on your hard-disk, say
4520 <filename>/path/to/my-printer.ppd</filename> (if you prefer to install
4521 your printers with the help of the CUPS Web interface, save the PPD to
4522 the <filename>/usr/share/cups/model/</filename> path and restart
4523 cupsd).</para></listitem>
4525 <listitem><para>Then install the printer with a suitable command line,
4526 like this: 
4527 </para>
4529 <para><screen>
4530 &rootprompt;<userinput>lpadmin -p laserjet4plus -v parallel:/dev/lp0 -E \
4531         -P path/to/my-printer.ppd</userinput>
4532 </screen></para></listitem>
4534 <listitem><para>For all the new-style <quote>Foomatic-PPDs</quote>
4535 from Linuxprinting.org, you also need a special CUPS filter named
4536 foomatic-rip. 
4537 </para></listitem>
4539 <listitem><para>The foomatic-rip Perl script itself also makes some
4540 interesting <ulink url="http://www.linuxprinting.org/foomatic2.9/download.cgi?filename=foomatic-rip&amp;show=1">reading</ulink>
4541 because it is well documented by Kamppeter's in-line comments (even
4542 non-Perl hackers will learn quite a bit about printing by reading
4543 it).</para></listitem>
4545 <listitem><para>Save foomatic-rip either directly in
4546 <filename>/usr/lib/cups/filter/foomatic-rip</filename> or somewhere in
4547 your $PATH (and remember to make it world-executable). Again,
4548 do not save by copy and paste but use the appropriate link or the
4549 <guimenuitem>Save as...</guimenuitem>  menu item in your browser.</para></listitem>
4551 <listitem><para>If you save foomatic-rip in your $PATH, create a symlink:
4552 <screen>
4553 &rootprompt;<userinput>cd /usr/lib/cups/filter/ ; ln -s `which foomatic-rip'</userinput>
4554 </screen>
4555 </para>
4557 <para>
4558 CUPS will discover this new available filter at startup after restarting
4559 cupsd.</para></listitem>
4560 </itemizedlist>
4562 <para>
4563 Once you print to a print queue set up with the Foomatic-PPD, CUPS will
4564 insert the appropriate commands and comments into the resulting
4565 PostScript jobfile. foomatic-rip is able to read and act upon
4566 these and uses some specially encoded Foomatic comments
4567 embedded in the jobfile. These in turn are used to construct
4568 (transparently for you, the user) the complicated Ghostscript command
4569 line telling the printer driver exactly how the resulting raster
4570 data should look and which printer commands to embed into the
4571 data stream. You need:
4572 </para>
4574 <itemizedlist>
4576 <listitem><para>A <quote>foomatic+something</quote> PPD &smbmdash; but this is not enough
4577 to print with CUPS (it is only <emphasis>one</emphasis> important
4578 component).</para></listitem>
4580 <listitem><para>The <parameter>foomatic-rip</parameter> filter script (Perl) in
4581 <filename>/usr/lib/cups/filters/</filename>.</para></listitem>
4583 <listitem><para>Perl to make foomatic-rip run.</para></listitem>
4585 <listitem><para>Ghostscript (because it is doing the main work,
4586 controlled by the PPD/foomatic-rip combo) to produce the raster data
4587 fit for your printer model's consumption.</para></listitem>
4589 <listitem><para>Ghostscript <emphasis>must</emphasis> (depending on
4590 the driver/model) contain support for a certain device representing
4591 the selected driver for your model (as shown by <command>gs
4592         -h</command>).</para></listitem>
4594 <listitem><para>foomatic-rip needs a new version of PPDs (PPD versions
4595 produced for cupsomatic do not work with
4596 foomatic-rip).</para></listitem>
4597 </itemizedlist>
4598 </sect2>
4599 </sect1>
4601 <sect1>
4602 <title>Page Accounting with CUPS</title>
4605 <para>
4606 <indexterm><primary>CUPS</primary><secondary>Page Accounting</secondary></indexterm>
4607 Often there are questions regarding print quotas where Samba users
4608 (that is, Windows clients) should not be able to print beyond a
4609 certain number of pages or data volume per day, week or month. This
4610 feature is dependent on the real print subsystem you're using.
4611 Samba's part is always to receive the job files from the clients
4612 (filtered <emphasis>or</emphasis> unfiltered) and hand it over to this
4613 printing subsystem.
4614 </para>
4616 <para>
4617 Of course one could hack things with one's own scripts. But then
4618 there is CUPS. CUPS supports quotas that can be based on the size of
4619 jobs or on the number of pages or both, and span any time
4620 period you want.
4621 </para>
4623 <sect2>
4624 <title>Setting Up Quotas</title>
4626 <para>
4627 <indexterm><primary>CUPS</primary><secondary>quotas</secondary></indexterm>
4628 This is an example command of how root would set a print quota in CUPS,
4629 assuming an existing printer named <quote>quotaprinter</quote>:
4630 </para>
4633 <para>
4634 <indexterm><primary>lpadmin</primary></indexterm>
4635         <screen>
4636 &rootprompt;<userinput>lpadmin -p quotaprinter -o job-quota-period=604800 \
4637         -o job-k-limit=1024 -o job-page-limit=100</userinput>
4638 </screen></para>
4640 <para>
4641 This would limit every single user to print 100 pages or 1024 KB of
4642 data (whichever comes first) within the last 604,800 seconds ( = 1
4643 week).
4644 </para>
4645 </sect2>
4647 <sect2>
4648 <title>Correct and Incorrect Accounting</title>
4650 <para>
4651 For CUPS to count correctly, the printfile needs to pass the CUPS
4652 pstops filter, otherwise it uses a dummy count of <quote>one</quote>. Some
4653 print files do not pass it (e.g., image files) but then those are mostly one-
4654 page jobs anyway. This also means that proprietary drivers for the
4655 target printer running on the client computers and CUPS/Samba, which
4656 then spool these files as <quote>raw</quote> (i.e., leaving them untouched, not
4657 filtering them), will be counted as one-pagers too!
4658 </para>
4660 <para>
4661 You need to send PostScript from the clients (i.e., run a PostScript
4662 driver there) to have the chance to get accounting done. If the
4663 printer is a non-PostScript model, you need to let CUPS do the job to
4664 convert the file to a print-ready format for the target printer. This
4665 is currently working for about a thousand different printer models.
4666 Linuxprinting has a driver
4667 <ulink url="http://www.linuxprinting.org/printer_list.cgi">list.</ulink>
4668 </para>
4669 </sect2>
4671 <sect2>
4672 <title>Adobe and CUPS PostScript Drivers for Windows Clients</title>
4674 <para>
4675 Before CUPS 1.1.16, your only option was to use the Adobe PostScript
4676 Driver on the Windows clients. The output of this driver was not
4677 always passed through the <command>pstops</command> filter on the CUPS/Samba side, and
4678 therefore was not counted correctly (the reason is that it often,
4679 depending on the PPD being used, wrote a PJL-header in front of
4680 the real PostScript which caused CUPS to skip <command>pstops</command> and go directly
4681 to the <command>pstoraster</command> stage).
4682 </para>
4684 <para>
4685 From CUPS 1.1.16 onward, you can use the CUPS PostScript Driver for
4686 Windows <?latex \linebreak ?>NT/200x/XP clients (which is tagged in the download area of
4687 <filename>http://www.cups.org/</filename> as the <filename>cups-samba-1.1.16.tar.gz</filename>
4688 package). It does <emphasis>not</emphasis> work for Windows 9x/ME clients, but it guarantees:
4689 </para>
4691 <itemizedlist>
4693 <listitem><para> <indexterm><primary>PJL</primary></indexterm> To not write a PJL-header.</para></listitem>
4695 <listitem><para>To still read and support all PJL-options named in the
4696 driver PPD with its own means.</para></listitem>
4698 <listitem><para>That the file will pass through the <command>pstops</command> filter
4699 on the CUPS/Samba server.</para></listitem>
4701 <listitem><para>To page-count correctly the print file.</para></listitem>
4702 </itemizedlist>
4704 <para>
4705 You can read more about the setup of this combination in the man page
4706 for <command>cupsaddsmb</command> (which is only present with CUPS installed, and only
4707 current from CUPS 1.1.16).
4708 </para>
4709 </sect2>
4711 <sect2>
4712 <title>The page_log File Syntax</title>
4714 <para>
4715 <indexterm><primary>page_log</primary></indexterm>
4716 These are the items CUPS logs in the <filename>page_log</filename> for every
4717 page of a job:
4718 </para>
4720 <itemizedlist>
4721 <listitem><para>Printer name</para></listitem>
4723 <listitem><para>User name</para></listitem>
4725 <listitem><para>Job ID</para></listitem>
4727 <listitem><para>Time of printing</para></listitem>
4729 <listitem><para>The page number</para></listitem>
4731 <listitem><para>The number of copies</para></listitem>
4733 <listitem><para>A billing information string (optional)</para></listitem>
4735 <listitem><para>The host that sent the job (included since version 1.1.19)</para></listitem>
4736 </itemizedlist>
4738 <para>
4739 Here is an extract of my CUPS server's <filename>page_log</filename> file to illustrate the
4740 format and included items:
4741 </para>
4743 <para><screen>
4744 tec_IS2027 kurt 401 [22/Apr/2003:10:28:43 +0100] 1 3 #marketing 10.160.50.13
4745 tec_IS2027 kurt 401 [22/Apr/2003:10:28:43 +0100] 2 3 #marketing 10.160.50.13
4746 tec_IS2027 kurt 401 [22/Apr/2003:10:28:43 +0100] 3 3 #marketing 10.160.50.13
4747 tec_IS2027 kurt 401 [22/Apr/2003:10:28:43 +0100] 4 3 #marketing 10.160.50.13
4748 Dig9110 boss 402 [22/Apr/2003:10:33:22 +0100] 1 440 finance-dep 10.160.51.33
4749 </screen></para>
4751 <para>
4752 This was job ID <parameter>401</parameter>, printed on <parameter>tec_IS2027</parameter>
4753 by user <parameter>kurt</parameter>, a 64-page job printed in three copies and billed to
4754 <parameter>#marketing</parameter>, sent from IP address <constant>10.160.50.13.</constant>
4755  The next job had ID <parameter>402</parameter>, was sent by user <parameter>boss</parameter>
4756 from IP address <constant>10.160.51.33</constant>, printed from one page 440 copies and
4757 is set to be billed to <parameter>finance-dep</parameter>.
4758 </para>
4759 </sect2>
4761 <sect2>
4762 <title>Possible Shortcomings</title>
4764 <para>
4765 What flaws or shortcomings are there with this quota system?
4766 </para>
4768 <itemizedlist>
4769 <listitem><para>The ones named above (wrongly logged job in case of
4770 printer hardware failure, and so on).</para></listitem>
4772 <listitem><para>In reality, CUPS counts the job pages that are being
4773 processed in <emphasis>software</emphasis> (that is, going through the
4774 RIP) rather than the physical sheets successfully leaving the
4775 printing device. Thus if there is a jam while printing the fifth sheet out
4776 of a thousand and the job is aborted by the printer, the page count will
4777 still show the figure of a thousand for that job.</para></listitem>
4779 <listitem><para>All quotas are the same for all users (no flexibility
4780 to give the boss a higher quota than the clerk) and no support for
4781 groups.</para></listitem>
4783 <listitem><para>No means to read out the current balance or the
4784 <quote>used-up</quote> number of current quota.</para></listitem>
4786 <listitem><para>A user having used up 99 sheets of a 100 quota will
4787 still be able to send and print a thousand sheet job.</para></listitem>
4789 <listitem><para>A user being denied a job because of a filled-up quota
4790 does not get a meaningful error message from CUPS other than
4791 <quote>client-error-not-possible</quote>.</para></listitem>
4792 </itemizedlist>
4793 </sect2>
4795 <sect2>
4796 <title>Future Developments</title>
4798 <para>
4799 This is the best system currently available, and there are huge
4800 improvements under development for CUPS 1.2:
4801 </para>
4803 <itemizedlist>
4804 <listitem><para>Page counting will go into the backends (these talk
4805 directly to the printer and will increase the count in sync with the
4806 actual printing process; thus, a jam at the fifth sheet will lead to a
4807 stop in the counting).</para></listitem>
4809 <listitem><para>Quotas will be handled more flexibly.</para></listitem>
4811 <listitem><para>Probably there will be support for users to inquire
4812 about their accounts in advance.</para></listitem>
4814 <listitem><para>Probably there will be support for some other tools
4815 around this topic.</para></listitem>
4816 </itemizedlist>
4817 </sect2>
4819 <!-- FIXME
4820 <sect2>
4821 <title>Other Accounting Tools</title>
4823 <para>
4824 PrintAnalyzer, pyKota, printbill, LogReport.
4825 </para>
4826 </sect2>
4828 </sect1>
4830 <sect1>
4831 <title>Additional Material</title>
4833 <para>
4834 A printer queue with <emphasis>no</emphasis> PPD associated to it is a
4835 <quote>raw</quote> printer and all files will go directly there as received by the
4836 spooler. The exceptions are file types <parameter>application/octet-stream</parameter>
4837 that need pass-through feature enabled. <quote>Raw</quote> queues do not do any
4838 filtering at all, they hand the file directly to the CUPS backend.
4839 This backend is responsible for sending the data to the device
4840 (as in the <quote>device URI</quote> notation: <filename>lpd://, socket://,
4841 smb://, ipp://, http://, parallel:/, serial:/, usb:/</filename>, and so on).
4842 </para>
4844 <para>
4845 cupsomatic/Foomatic are <emphasis>not</emphasis> native CUPS drivers
4846 and they do not ship with CUPS. They are a third party add-on
4847 developed at Linuxprinting.org. As such, they are a brilliant hack to
4848 make all models (driven by Ghostscript drivers/filters in traditional
4849 spoolers) also work via CUPS, with the same (good or bad!) quality as
4850 in these other spoolers. <parameter>cupsomatic</parameter> is only a vehicle to execute a
4851 Ghostscript command-line at that stage in the CUPS filtering chain,
4852 where normally the native CUPS <parameter>pstoraster</parameter> filter would kick
4853 in. cupsomatic bypasses pstoraster, kidnaps the printfile from CUPS
4854 away and redirects it to go through Ghostscript. CUPS accepts this,
4855 because the associated cupsomatic/foomatic-PPD specifies:
4857 <programlisting>
4858   *cupsFilter:  "application/vnd.cups-postscript 0 cupsomatic"
4859 </programlisting>
4861 This line persuades CUPS to hand the file to cupsomatic, once it has
4862 successfully converted it to the MIME type
4863 <parameter>application/vnd.cups-postscript</parameter>. This conversion will not happen for
4864 Jobs arriving from Windows that are auto-typed
4865 <parameter>application/octet-stream</parameter>, with the according changes in
4866 <filename>/etc/cups/mime.types</filename> in place.
4867 </para>
4869 <para>
4870 CUPS is widely configurable and flexible, even regarding its filtering
4871 mechanism. Another workaround in some situations would be to have in
4872 <filename>/etc/cups/mime.types</filename> entries as follows:
4874 <programlisting>
4875  application/postscript           application/vnd.cups-raw  0  -
4876  application/vnd.cups-postscript  application/vnd.cups-raw  0  -
4877 </programlisting>
4879 This would prevent all PostScript files from being filtered (rather,
4880 they will through the virtual <emphasis>nullfilter</emphasis>
4881 denoted with <quote>-</quote>). This could only be useful for PS printers. If you
4882 want to print PS code on non-PS printers (provided they support ASCII
4883 text printing), an entry as follows could be useful:
4885 <programlisting>
4886  */*           application/vnd.cups-raw  0  -
4887 </programlisting>
4889 and would effectively send <emphasis>all</emphasis> files to the
4890 backend without further processing.
4891 </para>
4893 <para>
4894 You could have the following entry:
4896 <programlisting>
4897 application/vnd.cups-postscript application/vnd.cups-raw 0 \
4898         my_PJL_stripping_filter
4899 </programlisting>
4901 You will need to write a <parameter>my_PJL_stripping_filter</parameter>
4902 (which could be a shell script) that parses the PostScript and removes the
4903 unwanted PJL. This needs to conform to CUPS filter design
4904 (mainly, receive and pass the parameters printername, job-id,
4905 username, jobtitle, copies, print options and possibly the
4906 filename). It is installed as world executable into
4907 <filename>/usr/lib/cups/filters/</filename> and is called by CUPS
4908 if it encounters a MIME type <parameter>application/vnd.cups-postscript</parameter>.
4909 </para>
4911 <para>
4912 CUPS can handle <parameter>-o job-hold-until=indefinite</parameter>.
4913 This keeps the job in the queue on hold. It will only be printed
4914 upon manual release by the printer operator. This is a requirement in
4915 many central reproduction departments, where a few operators manage
4916 the jobs of hundreds of users on some big machine, where no user is
4917 allowed to have direct access (such as when the operators often need
4918 to load the proper paper type before running the 10,000 page job
4919 requested by marketing for the mailing, and so on).
4920 </para>
4921 </sect1>
4923 <sect1>
4924 <title>Auto-Deletion or Preservation of CUPS Spool Files</title>
4926 <para>
4927 Samba print files pass through two spool directories. One is the
4928 incoming directory managed by Samba, (set in the
4929 <smbconfoption name="path">/var/spool/samba</smbconfoption>
4930 directive in the <smbconfsection>[printers]</smbconfsection> section of
4931 &smb.conf;). The other is the spool directory of
4932 your UNIX print subsystem. For CUPS it is normally
4933 <filename>/var/spool/cups/</filename>, as set by the <filename>cupsd.conf</filename>
4934 directive <filename>RequestRoot /var/spool/cups</filename>.
4935 </para>
4937 <sect2>
4938 <title>CUPS Configuration Settings Explained</title>
4940 <para>
4941 Some important parameter settings in the CUPS configuration file
4942 <filename>cupsd.conf</filename> are:
4943 </para>
4945 <variablelist>
4947 <varlistentry><term>PreserveJobHistory Yes</term>
4948 <listitem><para>
4949 This keeps some details of jobs in cupsd's mind (well it keeps the
4950 c12345, c12346, and so on, files in the CUPS spool directory, which do a
4951 similar job as the old-fashioned BSD-LPD control files). This is set
4952 to <quote>Yes</quote> as a default.
4953 </para></listitem></varlistentry>
4955 <varlistentry><term>PreserveJobFiles Yes</term>
4956 <listitem><para>
4957 This keeps the job files themselves in cupsd's mind
4958 (it keeps the d12345, d12346 etc. files in the CUPS spool
4959 directory). This is set to <quote>No</quote> as the CUPS
4960 default.
4961 </para></listitem></varlistentry>
4963 <varlistentry><term><emphasis><quote>MaxJobs 500</quote></emphasis></term>
4964 <listitem><para>
4965 This directive controls the maximum number of jobs
4966 that are kept in memory. Once the number of jobs reaches the limit,
4967 the oldest completed job is automatically purged from the system to
4968 make room for the new one. If all of the known jobs are still
4969 pending or active, then the new job will be rejected. Setting the
4970 maximum to 0 disables this functionality. The default setting is
4972 </para></listitem></varlistentry>
4973 </variablelist>
4975 <para>
4976 (There are also additional settings for <parameter>MaxJobsPerUser</parameter> and
4977 <parameter>MaxJobsPerPrinter</parameter>...)
4978 </para>
4979 </sect2>
4981 <sect2>
4982 <title>Pre-Conditions</title>
4984 <para>
4985 For everything to work as announced, you need to have three
4986 things:
4987 </para>
4989 <itemizedlist>
4990 <listitem><para>A Samba-smbd that is compiled against <filename>libcups</filename> (check
4991 on Linux by running <userinput>ldd `which smbd'</userinput>).</para></listitem>
4993 <listitem><para>A Samba-&smb.conf; setting of
4994                 <smbconfoption name="printing">cups</smbconfoption>.</para></listitem>
4996 <listitem><para>Another Samba-&smb.conf; setting of
4997                 <smbconfoption name="printcap">cups</smbconfoption>.</para></listitem>
4998 </itemizedlist>
5000 <note><para>
5001 In this case, all other manually set printing-related commands (like
5002 <smbconfoption name="print command"/>, 
5003 <smbconfoption name="lpq command"/>, 
5004 <smbconfoption name="lprm command"/>, 
5005 <smbconfoption name="lppause command"/> or
5006 <smbconfoption name="lpresume command"/>) are ignored and they should normally have no
5007 influence whatsoever on your printing.
5008 </para></note>
5009 </sect2>
5011 <sect2>
5012 <title>Manual Configuration</title>
5014 <para>
5015 If you want to do things manually, replace the <smbconfoption name="printing">cups</smbconfoption>
5016 by <smbconfoption name="printing">bsd</smbconfoption>. Then your manually set commands may work
5017 (I haven't tested this), and a <smbconfoption name="print command">lp -d %P %s; rm %s"</smbconfoption>
5018 may do what you need.
5019 </para>
5020 </sect2>
5021 </sect1>
5023 <sect1>
5024 <title>Printing from CUPS to Windows Attached Printers</title>
5026 <para>
5027 >From time to time the question arises, how can you print
5028 <emphasis>to</emphasis> a Windows attached printer
5029 <emphasis>from</emphasis> Samba? Normally the local connection
5030 from Windows host to printer would be done by USB or parallel
5031 cable, but this does not matter to Samba. From here only an SMB
5032 connection needs to be opened to the Windows host. Of course, this
5033 printer must be shared first. As you have learned by now, CUPS uses
5034 <emphasis>backends</emphasis> to talk to printers and other
5035 servers. To talk to Windows shared printers, you need to use the
5036 <filename>smb</filename> (surprise, surprise!) backend. Check if this
5037 is in the CUPS backend directory. This usually resides in
5038 <filename>/usr/lib/cups/backend/</filename>. You need to find an <filename>smb</filename>
5039 file there. It should be a symlink to <filename>smbspool</filename>
5040 and the file must exist and be executable:
5041 </para>
5043 <para><screen>
5044 &rootprompt;<userinput>ls -l /usr/lib/cups/backend/</userinput>
5045 total 253
5046 drwxr-xr-x    3 root   root     720 Apr 30 19:04 .
5047 drwxr-xr-x    6 root   root     125 Dec 19 17:13 ..
5048 -rwxr-xr-x    1 root   root   10692 Feb 16 21:29 canon
5049 -rwxr-xr-x    1 root   root   10692 Feb 16 21:29 epson
5050 lrwxrwxrwx    1 root   root       3 Apr 17 22:50 http -&gt; ipp
5051 -rwxr-xr-x    1 root   root   17316 Apr 17 22:50 ipp
5052 -rwxr-xr-x    1 root   root   15420 Apr 20 17:01 lpd
5053 -rwxr-xr-x    1 root   root    8656 Apr 20 17:01 parallel
5054 -rwxr-xr-x    1 root   root    2162 Mar 31 23:15 pdfdistiller
5055 lrwxrwxrwx    1 root   root      25 Apr 30 19:04 ptal -&gt; /usr/sbin/ptal-cups
5056 -rwxr-xr-x    1 root   root    6284 Apr 20 17:01 scsi
5057 lrwxrwxrwx    1 root   root      17 Apr  2 03:11 smb -&gt; /usr/bin/smbspool
5058 -rwxr-xr-x    1 root   root    7912 Apr 20 17:01 socket
5059 -rwxr-xr-x    1 root   root    9012 Apr 20 17:01 usb
5061 &rootprompt;<userinput>ls -l `which smbspool`</userinput>
5062 -rwxr-xr-x    1 root   root  563245 Dec 28 14:49 /usr/bin/smbspool
5063 </screen></para>
5065 <para>
5066 If this symlink does not exist, create it:
5067 </para>
5069 <para><screen>
5070 &rootprompt;<userinput>ln -s `which smbspool` /usr/lib/cups/backend/smb</userinput>
5071 </screen></para>
5073 <para>
5074 <command>smbspool</command> has been written by Mike Sweet from the CUPS folks. It is
5075 included and ships with Samba. It may also be used with print
5076 subsystems other than CUPS, to spool jobs to Windows printer shares. To
5077 set up printer <replaceable>winprinter</replaceable> on CUPS, you need to have a driver for
5078 it. Essentially this means to convert the print data on the CUPS/Samba
5079 host to a format that the printer can digest (the Windows host is
5080 unable to convert any files you may send). This also means you should
5081 be able to print to the printer if it were hooked directly at your
5082 Samba/CUPS host. For troubleshooting purposes, this is what you
5083 should do to determine if that part of the process chain is in
5084 order. Then proceed to fix the network connection/authentication to
5085 the Windows host, and so on.
5086 </para>
5088 <para>
5089 To install a printer with the <parameter>smb</parameter> backend on CUPS, use this command:
5090 </para>
5092 <para><screen>
5093 &rootprompt;<userinput>lpadmin -p winprinter -v smb://WINDOWSNETBIOSNAME/printersharename \
5094   -P /path/to/PPD</userinput>
5095 </screen></para>
5097 <para>
5098 The PPD must be able to direct CUPS to generate
5099 the print data for the target model. For PostScript printers, just use
5100 the PPD that would be used with the Windows NT PostScript driver. But
5101 what can you do if the printer is only accessible with a password? Or
5102 if the printer's host is part of another workgroup? This is provided
5103 for: You can include the required parameters as part of the
5104 <filename>smb://</filename> device-URI like this:
5105 </para>
5107 <itemizedlist>
5108         <listitem><para><filename>smb://WORKGROUP/WINDOWSNETBIOSNAME/printersharename</filename></para></listitem>
5109         <listitem><para><filename>smb://username:password@WORKGROUP/WINDOWSNETBIOSNAME/printersharename</filename></para></listitem>
5110         <listitem><para><filename>smb://username:password@WINDOWSNETBIOSNAME/printersharename</filename></para></listitem>
5111 </itemizedlist>
5113 <para>
5114 Note that the device-URI will be visible in the process list of the
5115 Samba server (e.g., when someone uses the <command>ps -aux</command>
5116 command on Linux), even if the username and passwords are sanitized
5117 before they get written into the log files. So this is an inherently
5118 insecure option, however, it is the only one. Don't use it if you want
5119 to protect your passwords. Better share the printer in a way that
5120 does not require a password! Printing will only work if you have a
5121 working netbios name resolution up and running. Note that this is a
5122 feature of CUPS and you do not necessarily need to have smbd running.
5124 </para>
5125 </sect1>
5127 <sect1>
5128 <title>More CUPS-Filtering Chains</title>
5130 <para>
5131 The following diagrams reveal how CUPS handles print jobs.
5132 </para>
5134 <image id="cups1">
5135         <imagedescription>Filtering chain 1.</imagedescription>
5136         <imagefile>cups1</imagefile>
5137 </image>
5139 <image id="cups2">
5140         <imagedescription>Filtering chain with cupsomatic</imagedescription>
5141         <imagefile>cups2</imagefile>
5142 </image>
5144 </sect1>
5146 <sect1>
5147         <title>Common Errors</title>
5149         <sect2>
5150                 <title>Windows 9x/ME Client Can't Install Driver</title>
5152                 <para>For Windows 9x/ME, clients require the printer names to be eight
5153 characters (or <quote>8 plus 3 chars suffix</quote>) max; otherwise, the driver files
5154 will not get transferred when you want to download them from
5155 Samba.</para>
5157         </sect2>
5159         <sect2 id="root-ask-loop">
5160                 <title><quote>cupsaddsmb</quote> Keeps Asking for Root Password in Never-ending Loop</title>
5162                 <para>Have you <smbconfoption name="security">user</smbconfoption>? Have
5163                 you used <command>smbpasswd</command> to give root a Samba account?
5164                 You can do two things: open another terminal and execute
5165                 <command>smbpasswd -a root</command> to create the account and
5166                 continue entering the password into the first terminal. Or break
5167                 out of the loop by pressing ENTER twice (without trying to type a
5168                 password).</para>
5170                 <para>
5171                 If the error is: <quote>tree connect failed: NT_STATUS_BAD_NETWORK_NAME</quote>, 
5172                 you may have forgotten to create the <filename>/etc/samba/drivers</filename> directory.
5173                 </para>
5174         </sect2>
5176         <sect2>
5177                 <title><quote>cupsaddsmb</quote> or <quote>rpcclient addriver</quote> Keeps Giving WERR_BAD_PASSWORD</title>
5179                 <para>See <link linkend="root-ask-loop">the previous common error</link>.</para>
5180         </sect2>
5182         <sect2>
5183                 <title><quote>cupsaddsmb</quote> Errors</title>
5185                 <para>
5186                 The use of <quote>cupsaddsmb</quote> gives <quote>No PPD file for printer...</quote> 
5187                 Message While PPD File Is Present.  What might the problem be?
5188                 </para>
5190                 <para>Have you enabled printer sharing on CUPS? This means:
5191                 Do you have a <parameter>&lt;Location
5192                 /printers&gt;....&lt;/Location&gt;</parameter> section in CUPS
5193                 server's <filename>cupsd.conf</filename> that does not deny access to
5194                 the host you run <quote>cupsaddsmb</quote> from?  It <emphasis>could</emphasis> be
5195                 an issue if you use cupsaddsmb remotely, or if you use it with a
5196                 <option>-h</option> parameter: <userinput>cupsaddsmb -H
5197                 sambaserver -h cupsserver -v printername</userinput>.
5198                 </para>
5200                 <para>Is your <parameter>TempDir</parameter> directive in
5201                 <filename>cupsd.conf</filename> set to a valid value and is it writable?
5202                 </para>
5204         </sect2>
5206         <sect2>
5207                 <title>Client Can't Connect to Samba Printer</title>
5209         <para>Use <command>smbstatus</command> to check which user
5210         you are from Samba's point of view. Do you have the privileges to
5211         write into the <smbconfsection>[print$]</smbconfsection>
5212         share?</para>
5214         </sect2>
5216         <sect2>
5217         <title>New Account Reconnection from Windows 200x/XP Troubles</title>
5219 <para>Once you are connected as the wrong user (for
5220 example, as <constant>nobody</constant>, which often occurs if you have 
5221 <smbconfoption name="map to guest">bad user</smbconfoption>), Windows Explorer will not accept an
5222 attempt to connect again as a different user. There will not be any byte
5223 transfered on the wire to Samba, but still you'll see a stupid error
5224 message that makes you think Samba has denied access. Use
5225 <command>smbstatus</command> to check for active connections. Kill the
5226 PIDs. You still can't re-connect and you get the dreaded
5227 <computeroutput>You can't connect with a second account from the same
5228 machine</computeroutput> message, as soon as you are trying. And you
5229 do not see any single byte arriving at Samba (see logs; use <quote>ethereal</quote>)
5230 indicating a renewed connection attempt. Shut all Explorer Windows.
5231 This makes Windows forget what it has cached in its memory as
5232 established connections. Then reconnect as the right user. The best
5233 method is to use a DOS terminal window and <emphasis>first</emphasis>
5234 do <userinput>net use z: \\&example.server.samba;\print$ /user:root</userinput>. Check
5235 with <command>smbstatus</command> that you are connected under a
5236 different account. Now open the <guilabel>Printers</guilabel> folder (on the Samba server
5237 in the <guilabel>Network Neighborhood</guilabel>), right-click on the
5238 printer in question and select
5239 <guibutton>Connect...</guibutton></para></sect2>
5241 <sect2>
5242 <title>Avoid Being Connected to the Samba Server as the Wrong User</title>
5243         
5244 <para>You see per <command>smbstatus</command> that you are
5245 connected as user nobody; while you want to be root or
5246 printer admin. This is probably due to 
5247 <smbconfoption name="map to guest">bad user</smbconfoption>, which silently connects you under the guest account
5248 when you gave (maybe by accident) an incorrect username. Remove
5249 <smbconfoption name="map to guest"/>, if you want to prevent
5250 this.</para></sect2>
5252 <sect2>
5253 <title>Upgrading to CUPS Drivers from Adobe Drivers</title>
5255 <para>
5256 This information came from a mailing list posting regarding problems experienced when
5257 upgrading from Adobe drivers to CUPS drivers on Microsoft Windows NT/200x/XP Clients.
5258 </para>
5260 <para>First delete all old Adobe-using printers. Then
5261 delete all old Adobe drivers. (On Windows 200x/XP, right-click in
5262 the background of <guilabel>Printers</guilabel> folder, select <guimenuitem>Server Properties...</guimenuitem>, select
5263 tab <guilabel>Drivers</guilabel> and delete here).</para></sect2>
5265 <sect2><title>Can't Use <quote>cupsaddsmb</quote> on Samba Server Which Is a PDC</title>
5266 <para>Do you use the <quote>naked</quote> root user name? Try to do it
5267 this way: <userinput>cupsaddsmb -U <replaceable>DOMAINNAME</replaceable>\\root -v
5268 <replaceable>printername</replaceable></userinput>> (note the two backslashes: the first one is
5269 required to <quote>escape</quote> the second one).</para></sect2>
5271 <sect2><title>Deleted Windows 200x Printer Driver Is Still Shown</title>
5272 <para>Deleting a printer on the client will not delete the
5273 driver too (to verify, right-click on the white background of the
5274 <guilabel>Printers</guilabel> folder, select <guimenuitem>Server Properties</guimenuitem> and click on the
5275 <guilabel>Drivers</guilabel> tab). These same old drivers will be re-used when you try to
5276 install a printer with the same name. If you want to update to a new
5277 driver, delete the old ones first. Deletion is only possible if no
5278 other printer uses the same driver.</para></sect2>
5280 <sect2><title>Windows 200x/XP "Local Security Policies"</title>
5281 <para>Local Security Policies may not
5282 allow the installation of unsigned drivers. <quote>Local Security Policies</quote>
5283 may not allow the installation of printer drivers at
5284 all.</para></sect2>
5286 <sect2><title>Administrator Cannot Install Printers for All Local Users</title>
5287 <para>Windows XP handles SMB printers on a <quote>per-user</quote> basis.
5288 This means every user needs to install the printer himself. To have a
5289 printer available for everybody, you might want to use the built-in
5290 IPP client capabilities of Win XP. Add a printer with the print path of
5291 <parameter>http://cupsserver:631/printers/printername</parameter>.
5292 We're still looking into this one. Maybe a logon script could
5293 automatically install printers for all
5294 users.</para></sect2>
5296 <sect2><title>Print Change Notify Functions on NT-clients</title>
5297 <para>For print change, notify functions on NT++ clients.
5298 These need to run the <command>Server</command> service first (renamed to
5299 <command>File &amp; Print Sharing for MS Networks</command> in
5300 XP).</para></sect2>
5302 <sect2>
5303 <title>Win XP-SP1</title>
5305 <para>Win XP-SP1 introduced a Point and Print Restriction Policy (this restriction does not apply to
5306 <quote>Administrator</quote> or <quote>Power User</quote> groups of users). In Group Policy
5307 Object Editor, go to <guimenu>User Configuration -> Administrative Templates ->
5308  Control Panel -> Printers</guimenu>. The policy is automatically set to
5309 <constant>Enabled</constant> and the <constant>Users can only Point
5310 and Print to machines in their Forest</constant> . You probably need
5311 to change it to <constant>Disabled</constant> or <constant>Users can
5312 only Point and Print to these servers</constant> to make
5313 driver downloads from Samba possible.
5314 </para>
5315 </sect2>
5317 <sect2>
5318 <title>Print Options for All Users Can't Be Set on Windows 200x/XP</title>
5320 <para>How are you doing it? I bet the wrong way (it is not
5321 easy to find out, though). There are three different ways to bring
5322 you to a dialog that <emphasis>seems</emphasis> to set everything. All
5323 three dialogs <emphasis>look</emphasis> the same, yet only one of them
5324 does what you intend. You need to be
5325 Administrator or Print Administrator to do this for all users. Here
5326 is how I do in on XP:
5327 </para>
5329 <orderedlist numeration="upperalpha">
5331 <listitem><para>The first wrong way:
5333 <orderedlist>
5334 <listitem><para>Open the <guilabel>Printers</guilabel>
5335 folder.</para></listitem>
5337 <listitem><para>Right-click on the printer
5338 (<guilabel>remoteprinter on cupshost</guilabel>) and
5339 select in context menu <guimenuitem>Printing
5340 Preferences...</guimenuitem></para></listitem>
5342 <listitem><para>Look at this dialog closely and remember what it looks
5343 like.</para></listitem>
5344 </orderedlist>
5345 </para>
5346 </listitem>
5348 <listitem><para>The second wrong way:
5350 <orderedlist>
5351 <listitem><para>Open the <guilabel>Printers</guilabel>
5352 folder.</para></listitem>
5354 <listitem><para>Right-click on the printer (<guilabel>remoteprinter on
5355 cupshost</guilabel>) and select the context menu
5356 <guimenuitem>Properties</guimenuitem>.</para></listitem>
5358 <listitem><para>Click on the <guilabel>General</guilabel>
5359 tab.</para></listitem>
5361 <listitem><para>Click on the button <guibutton>Printing
5362 Preferences...</guibutton></para></listitem>
5364 <listitem><para>A new dialog opens. Keep this dialog open and go back
5365 to the parent dialog.</para></listitem>
5366 </orderedlist>
5367 </para>
5368 </listitem>
5370 <listitem><para>The third, and the correct way: 
5372 <orderedlist>
5374 <listitem><para>Open the <guilabel>Printers</guilabel>
5375 folder.</para></listitem>
5377 <listitem><para>Click on the <guilabel>Advanced</guilabel>
5378 tab. (If everything is <quote>grayed out,</quote> then you are not logged
5379 in as a user with enough privileges).</para></listitem>
5381 <listitem><para>Click on the <guibutton>Printing
5382 Defaults...</guibutton> button.</para></listitem>
5384 <listitem><para>On any of the two new tabs, click on the
5385 <guibutton>Advanced...</guibutton>
5386 button.</para></listitem>
5388 <listitem><para>A new dialog opens. Compare this one to the other
5389 identical looking one from <quote>B.5</quote> or A.3".</para></listitem>
5390 </orderedlist>
5391 </para>
5392 </listitem>
5393 </orderedlist>
5395 <para>
5396 Do you see any difference? I don't either. However, only the last
5397 one, which you arrived at with steps <quote>C.1.-6.</quote>, will save any settings
5398 permanently and be the defaults for new users. If you want all clients
5399 to get the same defaults, you need to conduct these steps <emphasis>as
5400 Administrator</emphasis> (<smbconfoption name="printer admin"/> in
5401 &smb.conf;) <emphasis>before</emphasis> a client
5402 downloads the driver (the clients can later set their own
5403 <emphasis>per-user defaults</emphasis> by following the
5404 procedures <emphasis>A</emphasis> or <emphasis>B</emphasis>
5405 above).</para></sect2>
5407 <sect2><title>Most Common Blunders in Driver Settings on Windows Clients</title>
5408 <para>Don't use <parameter>Optimize for
5409 Speed</parameter>, but use <parameter>Optimize for
5410 Portability</parameter> instead (Adobe PS Driver). Don't use
5411 <parameter>Page Independence: No</parameter>: always
5412 settle with  <parameter>Page Independence:
5413 Yes</parameter> (Microsoft PS Driver and CUPS PS Driver for
5414 Windows NT/200x/XP). If there are problems with fonts, use
5415 <parameter>Download as Softfont into
5416 printer</parameter> (Adobe PS Driver). For
5417 <guilabel>TrueType Download Options</guilabel>
5418 choose <constant>Outline</constant>. Use PostScript
5419 Level 2, if you are having trouble with a non-PS printer and if
5420 there is a choice.</para></sect2>
5422 <sect2><title><command>cupsaddsmb</command> Does Not Work with Newly Installed Printer</title>
5423 <para>Symptom: The last command of
5424 <command>cupsaddsmb</command> does not complete successfully:
5425 <command>cmd = setdriver printername printername</command> result was
5426 NT_STATUS_UNSUCCESSFUL then possibly the printer was not yet
5427 recognized by Samba. Did it show up in Network
5428 Neighborhood? Did it show up i n <command>rpcclient
5429 hostname -c `enumprinters'</command>? Restart smbd (or send a
5430 <command>kill -HUP</command> to all processes listed by
5431 <command>smbstatus</command> and try
5432 again.</para></sect2>
5434 <sect2>
5435 <title>Permissions on <filename>/var/spool/samba/</filename> Get Reset After Each Reboot</title>
5436 <para>Have you ever by accident set the CUPS spool directory to
5437 the same location? (<parameter>RequestRoot /var/spool/samba/</parameter> in <filename>cupsd.conf</filename> or
5438 the other way round: <filename>/var/spool/cups/</filename> is set as
5439 <smbconfoption name="path"/>> in the <smbconfsection>[printers]</smbconfsection>
5440 section). These <parameter>must</parameter> be different. Set
5441 <!--FIXME-->
5442 <parameter>RequestRoot /var/spool/cups/</parameter> in
5443 <filename>cupsd.conf</filename> and <smbconfoption name="path"/>
5444 /var/spool/samba</smbconfoption> in the <smbconfsection>[printers]</smbconfsection>
5445 section of &smb.conf;. Otherwise cupsd will
5446 sanitize permissions to its spool directory with each restart and
5447 printing will not work reliably.</para></sect2>
5449 <sect2>
5450 <title>Print Queue Called <quote>lp</quote> Mis-handles Print Jobs</title>
5452 <para>
5453 In this case a print queue called <quote>lp</quote> intermittently swallows jobs and
5454 spits out completely different ones from what was sent.
5455 </para>
5457 <para>It is a bad idea to name any printer <quote>lp</quote>. This
5458 is the traditional UNIX name for the default printer. CUPS may be set
5459 up to do an automatic creation of Implicit Classes. This means, to
5460 group all printers with the same name to a pool of devices, and
5461 load-balancing the jobs across them in a round-robin fashion. Chances
5462 are high that someone else has a printer named <quote>lp</quote> too. You may
5463 receive his jobs and send your own to his device unwittingly. To have
5464 tight control over the printer names, set <parameter>BrowseShortNames
5465 No</parameter>. It will present any printer as <replaceable>printername@cupshost</replaceable>
5466 and then gives you better control over what may happen in a large
5467 networked environment.</para></sect2>
5469 <sect2><title>Location of Adobe PostScript Driver Files for <quote>cupsaddsmb</quote></title>
5470 <para>Use <command>smbclient</command> to connect to any
5471 Windows box with a shared PostScript printer: <command>smbclient
5472 //windowsbox/print\$ -U guest</command>. You can navigate to the
5473 <filename>W32X86/2</filename> subdir to <command>mget ADOBE*</command>
5474 and other files or to <filename>WIN40/0</filename> to do the same.
5475 Another option is to download the <filename>*.exe</filename> packaged
5476 files from the Adobe Web site.</para></sect2>
5478 </sect1>
5480 <sect1>
5481 <title>Overview of the CUPS Printing Processes</title>
5483 <para>A complete overview of the CUPS printing processes can be found in <link linkend="a_small">the next flowchart</link>.</para>
5485 <image id="a_small">
5486         <imagedescription>CUPS printing overview.</imagedescription>
5487         <imagefile>a_small</imagefile>
5488 </image>
5489 </sect1>
5491 </chapter>