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