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