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