syncing docs from 3.0 tree (thanks jelmer).
[Samba.git] / docs / docbook / projdoc / CUPS-printing.xml
blob945092d4136f877d3378116e1041e55d37c1d96d
1 <chapter id="CUPS-printing">
3 <chapterinfo>
5         <author>
6                 <firstname>Kurt</firstname><surname>Pfeifle</surname>
7                 <affiliation>
8                         <orgname>Danka Deutschland GmbH </orgname>
9                         <address><email>kpfeifle@danka.de</email></address>
10                 </affiliation>
11         </author>
12         <author>
13                 <firstname>Ciprian</firstname><surname>Vizitiu</surname>
14                 <affiliation>
15                         <address><email>CVizitiu@gbif.org</email></address>
16                 </affiliation>
17                 <contrib>drawings</contrib>
18         </author>
20         <author>&person.jelmer;<contrib>drawings</contrib></author>
22         <pubdate> (3 June 2003) </pubdate>
23 </chapterinfo>
25 <title>CUPS Printing Support in Samba 3.0</title>
27 <sect1>
29         <title>Introduction</title>
31         <sect2>
32                 <title>Features and Benefits</title>
34                 <para>
35                         The Common UNIX Print System (<ulink
36                         url="http://www.cups.org/">CUPS</ulink>) has become very popular. All
37                         major Linux distributions now ship it as their default printing
38                         system. To many it is still a very mystical tool.  Mostly, it
39                         "just works" (TM). People tend to regard it as a "black box"
40                         which they don't want to look into, as long as it works. But once
41                         there is a little problem, they are in trouble to find out where to
42                         start debugging it.  Refer to the "Classical Printing" chapter also, it
43                         contains a lot of information that is relevant for CUPS.
44                 </para>
46                 <para>
47                         CUPS sports quite a few unique and powerful features. While their
48                         basic functions may be grasped quite easily, they are also
49                         new. Because they are different from other, more traditional printing
50                         systems, it is best to try and not apply any prior knowledge about
51                         printing upon this new system. Rather, try to understand CUPS
52                         from the beginning. This documentation will lead you to a
53                         complete understanding of CUPS. Let's start with the most basic
54                         things first.
55                 </para>
57         </sect2>
59         <sect2>
60                 <title>Overview</title>
62                 <para>
63                         CUPS is more than just a print spooling system. It is a complete
64                         printer management system that complies with the new IPP
65                         (<emphasis>Internet Printing Protocol</emphasis>). IPP is an industry
66                         and IETF (<emphasis>Internet Engineering Task Force</emphasis>)
67                         standard for network printing. Many of its functions can be managed
68                         remotely (or locally) via a web browser (giving you a
69                         platform-independent access to the CUPS print server). Additionally, it
70                         has the traditional command line and several more modern GUI interfaces
71                         (GUI interfaces developed by 3rd parties, like KDE's
72                         overwhelming <ulink url="http://printing.kde.org/">KDEPrint</ulink>).
73                 </para>
75                 <para>
76                         CUPS allows creation of "raw" printers (ie: NO print file
77                         format translation) as well as "smart" printers (i.e. CUPS does
78                         file format conversion as required for the printer). In many ways
79                         this gives CUPS similar capabilities to the MS Windows print
80                         monitoring system. Of course, if you are a CUPS advocate, you would
81                         argue that CUPS is better! In any case, let us now move on to
82                         explore how one may configure CUPS for interfacing with MS Windows
83                         print clients via Samba.
84                 </para>
85         </sect2>
86 </sect1>
88 <sect1>
89         <title>Basic Configuration of CUPS support</title>
91         <para>
92                 Printing with CUPS in the most basic &smb.conf; setup in Samba 3.0 (as was true for 2.2.x) only needs two
93                 settings: <smbconfoption><name>printing</name><value>cups</value></smbconfoption> and
94                 <smbconfoption><name>printcap</name><value>cups</value></smbconfoption>. CUPS does not need a printcap file.
95                 However, the <filename>cupsd.conf</filename> configuration file knows of two related directives that control
96                 how such a file will be automatically created and maintained by CUPS for the convenience of third party
97                 applications (example: <parameter>Printcap /etc/printcap</parameter> and <parameter>PrintcapFormat BSD</parameter>).
98                 Legacy programs often require the existence of a printcap file containing printer names or they will refuse to
99                 print. Make sure CUPS is set to generate and maintain a printcap file! For details see
100                 <command>man cupsd.conf</command> and other CUPS-related documentation, like the wealth of documents on your CUPS server
101                 itself: <ulink noescape="1" url="http://localhost:631/documentation.html">http://localhost:631/documentation.html</ulink>.
102         </para>
104         <sect2>
105                 <title>Linking of smbd with libcups.so</title>
107                 <para>
108                         Samba has a very special relationship to CUPS. Samba can be compiled with CUPS library support.
109                         Most recent installations have this support enabled. Per default CUPS linking is compiled
110                         into smbd and other Samba binaries. Of course, you can use CUPS even
111                         if Samba is not linked against <filename>libcups.so</filename> -- but
112                         there are some differences in required or supported configuration
113                         then.
114                 </para>
116                 <para>
117                         When Samba is compiled against libcups, <smbconfoption><name>printcap</name><value>cups</value></smbconfoption>
118                         uses the CUPS API to list printers, submit jobs, query queues, etc.  Otherwise it maps to the System V
119                         commands with an additional <command>-oraw</command> option for printing. On a Linux
120                         system, you can use the <command>ldd</command> utility to find out details (ldd may not be present on
121                         other OS platforms, or its function may be embodied by a different command):
122                 </para>
124 <para><screen>
125 &rootprompt;<userinput>ldd `which smbd`</userinput>
126 libssl.so.0.9.6 =&gt; /usr/lib/libssl.so.0.9.6 (0x4002d000)
127 libcrypto.so.0.9.6 =&gt; /usr/lib/libcrypto.so.0.9.6 (0x4005a000)
128 libcups.so.2 =&gt; /usr/lib/libcups.so.2 (0x40123000)
129 [....]
130 </screen></para>
132                 <para>
133                         The line <computeroutput>libcups.so.2 =&gt; /usr/lib/libcups.so.2 (0x40123000)</computeroutput> shows
134                         there is CUPS support compiled into this version of Samba. If this is the case, and printing = cups
135                         is set, then <emphasis>any otherwise manually set print command in &smb.conf; is ignored</emphasis>.
136                         This is an important point to remember!
137                 </para>
139                 <tip><para> Should it be necessary, for any reason, to set your own print commands, you can do this by setting
140                 <smbconfoption><name>printing</name><value>sysv</value></smbconfoption>. However, you will loose all the benefits
141                 of tight CUPS/Samba integration. When you do this you must manually configure the printing system commands
142                 (most important: <smbconfoption><name>print command</name></smbconfoption>; other commands are
143                                 <smbconfoption><name>lppause command</name></smbconfoption>,
144                                 <smbconfoption><name>lpresume command</name></smbconfoption>,
145                                 <smbconfoption><name>lpq command</name></smbconfoption>,
146                                 <smbconfoption><name>lprm command</name></smbconfoption>,
147                                 <smbconfoption><name>queuepause command</name></smbconfoption> and
148                                 <smbconfoption><name>queue resume command</name></smbconfoption>).</para></tip>
149         </sect2>
151         <sect2>
152                 <title>Simple &smb.conf; Settings for CUPS</title>
154                 <para>
155                         To summarize, here is the simplest printing-related setup for &smb.conf; to enable basic CUPS support:
156                 </para>
158                 <para><smbconfexample>
159                 <title>Simplest printing-related smb.conf</title>
160                 <smbconfsection>[global]</smbconfsection>
161                 <smbconfoption><name>load printers</name><value>yes</value></smbconfoption>
162                 <smbconfoption><name>printing</name><value>cups</value></smbconfoption>
163                 <smbconfoption><name>printcap name</name><value>cups</value></smbconfoption>
165                 <smbconfsection>[printers]</smbconfsection>
166                 <smbconfoption><name>comment</name><value>All Printers</value></smbconfoption>
167                 <smbconfoption><name>path</name><value>/var/spool/samba</value></smbconfoption>
168                 <smbconfoption><name>browseable</name><value>no</value></smbconfoption>
169                 <smbconfoption><name>public</name><value>yes</value></smbconfoption>
170                 <smbconfoption><name>guest ok</name><value>yes</value></smbconfoption>
171                 <smbconfoption><name>writable</name><value>no</value></smbconfoption>
172                 <smbconfoption><name>printable</name><value>yes</value></smbconfoption>
173                 <smbconfoption><name>printer admin</name><value>root, @ntadmins</value></smbconfoption>
175                 </smbconfexample></para>
177                 <para>
178                         This is all you need for basic printing setup for CUPS. It will print
179                         all Graphic, Text, PDF and PostScript file submitted from Windows
180                         clients. However, most of your Windows users would not know how to
181                         send these kind of files to print without opening a GUI
182                         application. Windows clients tend to have local printer drivers
183                         installed. And the GUI application's print buttons start a printer
184                         driver. Your users also very rarely send files from the command
185                         line. Unlike UNIX clients, they hardly submit graphic, text or PDF
186                         formatted files directly to the spooler. They nearly exclusively print
187                         from GUI applications, with a "printer driver" hooked in between the
188                         applications native format and the print data stream.  If the backend
189                         printer is not a PostScript device, the print data stream is "binary",
190                         sensible only for the target printer. Read on to learn which problem
191                         this may cause and how to avoid it.
192                 </para>
193         </sect2>
195 <sect2>
196 <title>More complex &smb.conf; Settings for
197 CUPS</title>
199 <para>
200 Here is a slightly more complex printing-related setup
201 for &smb.conf;. It enables general CUPS printing
202 support for all printers, but defines one printer share which is set
203 up differently.
204 </para>
206 <para><smbconfexample>
207 <title>Overriding global CUPS settings for one printer</title>
208 <smbconfsection>[global]</smbconfsection>
209 <smbconfoption><name>printing</name><value>cups</value></smbconfoption>
210 <smbconfoption><name>printcap name</name><value>cups</value></smbconfoption>
211 <smbconfoption><name>load printers</name><value>yes</value></smbconfoption>
213 <smbconfsection>[printers]</smbconfsection>
214 <smbconfoption><name>comment</name><value>All Printers</value></smbconfoption>
215 <smbconfoption><name>path</name><value>/var/spool/samba</value></smbconfoption>
216 <smbconfoption><name>public</name><value>yes</value></smbconfoption>
217 <smbconfoption><name>guest ok</name><value>yes</value></smbconfoption>
218 <smbconfoption><name>writable</name><value>no</value></smbconfoption>
219 <smbconfoption><name>printable</name><value>yes</value></smbconfoption>
220 <smbconfoption><name>printer admin</name><value>root, @ntadmins</value></smbconfoption>
222 <smbconfsection>[special_printer]</smbconfsection>
223 <smbconfoption><name>comment</name><value>A special printer with his own settings</value></smbconfoption>
224 <smbconfoption><name>path</name><value>/var/spool/samba-special</value></smbconfoption>
225 <smbconfoption><name>printing</name><value>sysv</value></smbconfoption>
226 <smbconfoption><name>printcap</name><value>lpstat</value></smbconfoption>
227 <smbconfoption><name>print command</name><value>echo "NEW: `date`: printfile %f" >> /tmp/smbprn.log ; \</value></smbconfoption>
228 <member><parameter>echo "     `date`: p-%p s-%s f-%f" >> /tmp/smbprn.log ; \</parameter></member>
229 <member><parameter>echo "     `date`: j-%j J-%J z-%z c-%c" >> /tmp/smbprn.log : rm %f</parameter></member>
230 <smbconfoption><name>public</name><value>no</value></smbconfoption>
231 <smbconfoption><name>guest ok</name><value>no</value></smbconfoption>
232 <smbconfoption><name>writeable</name><value>no</value></smbconfoption>
233 <smbconfoption><name>printable</name><value>yes</value></smbconfoption>
234 <smbconfoption><name>printer admin</name><value>kurt</value></smbconfoption>
235 <smbconfoption><name>hosts deny</name><value>0.0.0.0</value></smbconfoption>
236 <smbconfoption><name>hosts allow</name><value>turbo_xp, 10.160.50.23, 10.160.51.60</value></smbconfoption>
237 </smbconfexample></para>
239 <para>
240 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
241 known to Samba into the <filename>/tmp/smbprn.log</filename> file and deletes the jobfile. Moreover, the
242 <smbconfoption><name>printer admin</name></smbconfoption> of this share is "kurt" (not the "@ntadmins" group);
243 guest access is not allowed; the share isn not published to the Network Neighbourhood (so you need to know it is there), and it only
244 allows access from only three hosts. To prevent CUPS kicking in and taking over the print jobs for that share, we need to set
245 <smbconfoption><name>printing</name><value>sysv</value></smbconfoption> and
246 <smbconfoption><name>printcap</name><value>lpstat</value></smbconfoption>.
247 </para>
248 </sect2>
249 </sect1>
251 <sect1>
252 <title>Advanced Configuration</title>
254 <para>
255 Before we delve into all the configuration options, let us clarify a few
256 points. <emphasis>Network printing needs to be organized and setup
257 correctly</emphasis>. Often this is not done correctly. Legacy systems
258 or small business LAN environments often lack design and good housekeeping.
259 </para>
262 <sect2>
263 <title>Central spooling vs. "Peer-to-Peer" printing</title>
265 <indexterm><primary>spooling</primary><secondary>central</secondary></indexterm>
266 <indexterm><primary>spooling</primary><secondary>peer-to-peer</secondary></indexterm>
268 <para>
269 Many small office or home networks, as well as badly organized larger
270 environments, allow each client a direct access to available network
271 printers. This is generally a bad idea. It often blocks one client's
272 access to the printer when another client's job is printing. It also
273 might freeze the first client's application while it is waiting to get
274 rid of the job. Also, there are frequent complaints about various jobs
275 being printed with their pages mixed with each other. A better concept
276 is the usage of a "print server": it routes all jobs through one
277 central system, which responds immediately, takes jobs from multiple
278 concurrent clients at the same time and in turn transfers them to the
279 printer(s) in the correct order.
280 </para>
281 </sect2>
283 <sect2>
284 <title>CUPS/Samba as a "spooling-only" Print Server; "raw" printing
285 with Vendor Drivers on Windows Clients</title>
287 <indexterm><primary>spooling-only</primary></indexterm>
288 <indexterm><primary>"raw" printing</primary></indexterm>
290 <para>
291 Most traditionally configured UNIX print servers acting on behalf of
292 Samba's Windows clients represented a really simple setup. Their only
293 task was to manage the "raw" spooling of all jobs handed to them by
294 Samba. This approach meant that the Windows clients were expected to
295 prepare the print job file that it s ready to be sent to the printing
296 device. Here a native (vendor-supplied) Windows printer
297 driver for the target device needed to be installed on each and every
298 client.
299 </para>
301 <para>
302 It is possible to configure CUPS, Samba and your Windows clients in the
303 same, traditional and simple way. When CUPS printers are configured
304 for RAW print-through mode operation it is the responsibility of the
305 Samba client to fully render the print job (file). The file must be
306 sent in a format that is suitable for direct delivery to the
307 printer. Clients need to run the vendor-provided drivers to do
308 this. In this case CUPS will NOT do any print file format conversion
309 work.
310 </para>
311 </sect2>
313 <sect2>
314 <title>Driver Installation Methods on Windows Clients</title>
316 <para>
317 The printer drivers on the Windows clients may be installed
318 in two functionally different ways:
319 </para>
321 <itemizedlist>
322 <listitem><para>manually install the drivers locally on each client,
323 one by one; this yields the old <emphasis>LanMan</emphasis> style
324 printing; it uses a <filename>\\sambaserver\printershare</filename>
325 type of connection.</para></listitem>
328 <listitem><para>
329 <indexterm><primary>point and print</primary></indexterm>
330                 deposit and prepare the drivers (for later download) on
331 the print server (Samba); this enables the clients to use
332 "Point and Print" to get drivers semi-automatically installed the
333 first time they access the printer; with this method NT/2K/XP
334 clients use the <emphasis>SPOOLSS/MS-RPC</emphasis>
335 type printing calls.</para></listitem>
336 </itemizedlist>
338 <para>
339 The second method is recommended for use over the first.
340 </para>
341 </sect2>
343 <sect2>
344 <title>Explicitly enable "raw" printing for
345 <emphasis>application/octet-stream</emphasis>!</title>
347 <indexterm><primary>application/octet-stream</primary></indexterm>
349 <para>
350 If you use the first option (drivers are installed on the client
351 side), there is one setting to take care of: CUPS needs to be told
352 that it should allow "raw" printing of deliberate (binary) file
353 formats. The CUPS files that need to be correctly set for RAW mode
354 printers to work are:
355 </para>
357 <itemizedlist>
358 <listitem><para>/etc/cups/mime.types
359 </para></listitem>
361 <listitem><para>/etc/cups/mime.convs</para></listitem>
362 </itemizedlist>
364 <para>
365 Both contain entries (at the end of the respective files) which must
366 be uncommented to allow RAW mode operation.
367 In<filename>/etc/cups/mime.types</filename> make sure this line is
368 present:
369 </para>
371 <para><screen>
372  application/octet-stream
373 </screen></para>
375 <para>
376 In <filename>/etc/cups/mime.convs</filename>,
377 have this line:
378 </para>
380 <indexterm><primary>application/vnd.cups-raw</primary></indexterm>
382 <para><screen>
383  application/octet-stream   application/vnd.cups-raw   0   - 
384 </screen></para>
386 <para>
387 If these two files are not set up correctly for raw Windows client
388 printing, you may encounter the dreaded <computeroutput>Unable to
389 convert file 0</computeroutput> in your CUPS error_log file. 
390 </para>
392 <note><para>editing the <filename>mime.convs</filename> and the
393 <filename>mime.types</filename> file does not
394 <emphasis>enforce</emphasis> "raw" printing, it only
395 <emphasis>allows</emphasis> it.
396 </para></note>
398 <formalpara><title>Background</title>
400 <indexterm><primary>application/octet-stream</primary></indexterm>
402 <para>
403 CUPS being a more security-aware printing system than traditional ones
404 does not by default allow a user to send deliberate (possibly binary)
405 data to printing devices. This could be easily abused to launch a
406 "Denial of Service" attack on your printer(s), causing at the least
407 the loss of a lot of paper and ink. "Unknown" data are tagged by CUPS
408 as <emphasis>MIME type: application/octet-stream</emphasis> and not
409 allowed to go to the printer. By default, you can only send other
410 (known) MIME types "raw". Sending data "raw" means that CUPS does not
411 try to convert them and passes them to the printer untouched (see next
412 chapter for even more background explanations).
413 </para>
414 </formalpara>
416 <para>
417 This is all you need to know to get the CUPS/Samba combo printing
418 "raw" files prepared by Windows clients, which have vendor drivers
419 locally installed. If you are not interested in background information about
420 more advanced CUPS/Samba printing, simply skip the remaining sections
421 of this chapter.
422 </para>
423 </sect2>
425 <sect2>
426 <title>Three familiar Methods for driver upload plus a new one</title>
428 <indexterm><primary>point and print</primary></indexterm>
430 <para>
431 If you want to use the MS-RPC type printing, you must upload the
432 drivers onto the Samba server first (<smbconfsection>[print$]</smbconfsection>
433 share). For a discussion on how to deposit printer drivers on the
434 Samba host (so that the Windows clients can download and use them via
435 "Point'n'Print") please also refer to the previous chapter of this
436 HOWTO Collection. There you will find a description or reference to
437 three methods of preparing the client drivers on the Samba server:
438 </para>
440 <indexterm><primary>add printer wizard</primary></indexterm>
442 <itemizedlist>
443 <listitem><para>the GUI, "Add Printer Wizard"
444 <emphasis>upload-from-a-Windows-client</emphasis>
445 method;</para></listitem>
447 <listitem><para>the commandline, "smbclient/rpcclient"
448 <emphasis>upload-from-a-UNIX-workstation</emphasis>
449 method;</para></listitem>
452 <listitem><para>
453 <indexterm><primary>imprints</primary></indexterm>
454                 the <emphasis>Imprints</emphasis> Toolset
455 method.</para></listitem>
456 </itemizedlist>
458 <para>
459 These 3 methods apply to CUPS all the same. A new and more
460 convenient way to load the Windows drivers into Samba is provided
461 if you use CUPS:
462 </para>
464 <indexterm><primary>cupsaddsmb</primary></indexterm>
466 <itemizedlist>
467 <listitem><para>the <emphasis>cupsaddsmb</emphasis>
468 utility.</para></listitem>
469 </itemizedlist>
471 <para>
472 cupsaddsmb is discussed in much detail further below. But we will
473 first explore the CUPS filtering system and compare the Windows and
474 UNIX printing architectures.
475 </para>
476 </sect2>
477 </sect1>
479 <sect1>
480 <title>Using CUPS/Samba in an advanced Way -- intelligent printing
481 with PostScript Driver Download</title>
483 <indexterm><primary>PostScript</primary><seealso>Ghostscript</seealso></indexterm>
485 <para>
486 Are you still following this? Good. Let's go into more detail then. We now know
487 how to set up a "dump" printserver, that is, a server which is spooling
488 printjobs "raw", leaving the print data untouched.
489 </para>
491 <para>
492 Possibly you need to setup CUPS in a more smart way. The reasons could
493 be manifold:
494 </para>
496 <itemizedlist>
497 <listitem><para>Maybe your boss wants to get monthly statistics: Which
498 printer did how many pages? What was the average data size of a job?
499 What was the average print run per day? What are the typical hourly
500 peaks in printing? Which departments prints how
501 much?</para></listitem>
503 <listitem><para>Maybe you are asked to setup a print quota system:
504 users should not be able to print more jobs, once they have surpassed
505 a given limit per period?</para></listitem>
507 <listitem><para>Maybe your previous network printing setup is a mess
508 and shall be re-organized from a clean beginning?</para></listitem>
510 <listitem><para>Maybe you have experiencing too many "Blue Screens",
511 originating from poorly debugged printer drivers running in NT "kernel
512 mode"?</para></listitem>
513 </itemizedlist>
515 <para>
516 These goals cannot be achieved by a raw print server. To build a
517 server meeting these requirements, you'll first need to learn about
518 how CUPS works and how you can enable its features.
519 </para>
521 <para>
522 What follows is the comparison of some fundamental concepts for
523 Windows and UNIX printing; then is the time for a description of the
524 CUPS filtering system, how it works and how you can tweak it.
525 </para>
527 <sect2 id="gdipost">
528 <title>GDI on Windows -- PostScript on UNIX</title>
530 <indexterm><primary>GDI</primary></indexterm>
531 <indexterm><primary>PostScript</primary></indexterm>
533 <para>
534 Network printing is one of the most complicated and error-prone
535 day-to-day tasks any user or an administrator may encounter. This is
536 true for all OS platforms. And there are reasons for this.
537 </para>
539 <indexterm><primary>PCL</primary></indexterm>
540 <indexterm><primary>PDL</primary></indexterm>
542 <para>
543 You can't expect for most file formats to just throw them towards
544 printers and they get printed. There needs to be a file format
545 conversion in between. The problem is: there is no common standard for
546 print file formats across all manufacturers and printer types.  While
547 <emphasis>PostScript</emphasis> (trademark held by Adobe), and, to an
548 extent, <emphasis>PCL</emphasis> (trademark held by HP), have developed
549 into semi-official "standards", by being the most widely used PDLs
550 (<emphasis>Page Description Languages</emphasis>), there are still
551 many manufacturers who "roll their own" (their reasons may be
552 unacceptable license fees for using printer-embedded PostScript
553 interpreters, etc.).
554 </para>
555 </sect2>
557 <sect2>
558 <title>Windows Drivers, GDI and EMF</title>
560 <indexterm><primary>GDI</primary></indexterm>
561 <indexterm><primary>EMF</primary></indexterm>
562 <indexterm><primary>WYSIWYG</primary></indexterm>
564 <para>
565 In Windows OS, the format conversion job is done by the printer
566 drivers. On MS Windows OS platforms all application programmers have
567 at their disposal a built-in API, the GDI (<emphasis>Graphical Device
568 Interface</emphasis>), as part and parcel of the OS itself, to base
569 themselves on. This GDI core is used as one common unified ground, for
570 all Windows programs, to draw pictures, fonts and documents
571 <emphasis>on screen</emphasis> as well as <emphasis>on
572 paper</emphasis> (=print). Therefore printer driver developers can
573 standardize on a well-defined GDI output for their own driver
574 input. Achieving WYSIWYG ("What You See Is What You Get") is
575 relatively easy, because the on-screen graphic primitives, as well as
576 the on-paper drawn objects, come from one common source. This source,
577 the GDI, produces often a file format called EMF (<emphasis>Enhanced
578 MetaFile</emphasis>). The EMF is processed by the printer driver and
579 converted to the printer-specific file format.
580 </para>
582 <note><para>
583 <indexterm><primary>PDF</primary></indexterm>
584 To the GDI foundation in MS Windows, Apple has chosen to
585 put paper and screen output on a common foundation for their
586 (BSD-UNIX-based, did you know??) Mac OS X and Darwin Operating
587 Systems. Their <emphasis>Core Graphic Engine</emphasis> uses a
588 <emphasis>PDF</emphasis> derivative for all display work.
589 </para></note>
591 <para>
593 <image id="small1"><imagedescription>Windows Printing to a local Printer</imagedescription><imagefile>1small</imagefile></image>
594 </para>
595 </sect2>
597 <sect2>
598 <title>UNIX Printfile Conversion and GUI Basics</title>
600 <indexterm><primary>X Window System</primary></indexterm>
601 <indexterm><primary>PostScript</primary></indexterm>
602 <indexterm><primary>PCL</primary></indexterm>
603 <indexterm><primary>Xprint</primary></indexterm>
605 <para>
606 In UNIX and Linux, there is no comparable layer built into the OS
607 kernel(s) or the X (screen display) server. Every application is
608 responsible for itself to create its print output.  Fortunately, most
609 use PostScript. That gives at least some common ground. Unfortunately,
610 there are many different levels of quality for this PostScript. And
611 worse: there is a huge difference (and no common root) in the way how
612 the same document is displayed on screen and how it is presented on
613 paper. WYSIWYG is more difficult to achieve. This goes back to the
614 time decades ago, when the predecessors of <emphasis>X.org</emphasis>,
615 designing the UNIX foundations and protocols for Graphical User
616 Interfaces refused to take over responsibility for "paper output"
617 also, as some had demanded at the time, and restricted itself to
618 "on-screen only".  (For some years now, the "Xprint" project has been
619 under development, attempting to build printing support into the X
620 framework, including a PostScript and a PCL driver, but it is not yet
621 ready for prime time.) You can see this unfavorable inheritance up to
622 the present day by looking into the various "font" directories on your
623 system; there are separate ones for fonts used for X display and fonts
624 to be used on paper.
625 </para>
627 <formalpara>
628 <title>Background</title>
630 <indexterm><primary>PostScript</primary></indexterm>
632 <para>
633 The PostScript programming language is an "invention" by Adobe Inc.,
634 but its specifications have been published to the full. Its strength
635 lies in its powerful abilities to describe graphical objects (fonts,
636 shapes, patterns, lines, curves, dots...), their attributes (color,
637 linewidth...) and the way to manipulate (scale, distort, rotate,
638 shift...) them.  Because of its open specification, anybody with the
639 skill can start writing his own implementation of a PostScript
640 interpreter and use it to display PostScript files on screen or on
641 paper. Most graphical output devices are based on the concept of
642 "raster images" or "pixels" (one notable exception are pen
643 plotters). Of course, you can look at a PostScript file in its textual
644 form and you will be reading its PostScript code, the language
645 instructions which need to be interpreted by a rasterizer. Rasterizers
646 produce pixel images, which may be displayed on screen by a viewer
647 program or on paper by a printer.
648 </para>
649 </formalpara>
650 </sect2>
652 <sect2 id="post-and-ghost">
653 <title>PostScript and Ghostscript</title>
655 <indexterm><primary>PostScript</primary></indexterm>
656 <indexterm><primary>GhostScript</primary><seealso>PostScript</seealso></indexterm>
657 <indexterm><primary>PostScript</primary><secondary>RIP</secondary></indexterm>
659 <para>
660 So, UNIX is lacking a common ground for printing on paper and
661 displaying on screen. Despite this unfavorable legacy for UNIX, basic
662 printing is fairly easy: if you have PostScript printers at your
663 disposal! The reason is: these devices have a built-in PostScript
664 language "interpreter", also called a <emphasis>Raster Image
665 Processor</emphasis> (RIP), (which makes them more expensive than
666 other types of printers); throw PostScript towards them, and they will
667 spit out your printed pages. Their RIP is doing all the hard work of
668 converting the PostScript drawing commands into a bitmap picture as
669 you see it on paper, in a resolution as done by your printer. This is
670 no different to PostScript printing of a file from a Windows origin.
671 </para>
673 <note><para>
674 <indexterm><primary>PPD</primary></indexterm>
675 Traditional UNIX programs and printing systems -- while
676 using PostScript -- are largely not PPD-aware. PPDs are "PostScript
677 Printer Description" files. They enable you to specify and control all
678 options a printer supports: duplexing, stapling, punching... Therefore
679 UNIX users for a long time couldn't choose many of the supported
680 device and job options, unlike Windows or Apple users. But now there
681 is CUPS....
682 </para>
683 </note>
685 <para>
686         <image id="small2"><imagedescription>Printing to a Postscript Printer</imagedescription>
687                 <imagefile>2small</imagefile></image>
688 </para>
690 <indexterm><primary>PDL</primary></indexterm>
692 <para>
693 However, there are other types of printers out there. These don't know
694 how to print PostScript. They use their own <emphasis>Page Description
695 Language</emphasis> (PDL, often proprietary). To print to them is much
696 more demanding. Since your UNIX applications mostly produce
697 PostScript, and since these devices don't understand PostScript, you
698 need to convert the printfiles to a format suitable for your printer
699 on the host, before you can send it away.
700 </para>
701 </sect2>
703 <sect2>
704 <title>Ghostscript -- the Software RIP for non-PostScript Printers</title>
706 <indexterm><primary>GhostScript</primary></indexterm>
708 <para>
709 Here is where <emphasis>Ghostscript</emphasis> kicks in. Ghostscript is
710 the traditional (and quite powerful) PostScript interpreter used on
711 UNIX platforms. It is a RIP in software, capable to do a
712 <emphasis>lot</emphasis> of file format conversions, for a very broad
713 spectrum of hardware devices as well as software file formats.
714 Ghostscript technology and drivers is what enables PostScript printing
715 to non-PostScript hardware.
716 </para>
718 <para>
719         <image id="small3"><imagedescription>Ghostscript as a RIP for non-postscript printers</imagedescription>
720         <imagefile>3small</imagefile>
721 </image>
722 </para>
724 <tip><para>
725 Use the "gs -h" command to check for all built-in "devices" of your
726 Ghostscript version. If you specify e.g. a parameter of
727 <parameter>-sDEVICE=png256</parameter> on your Ghostscript command
728 line, you are asking Ghostscript to convert the input into a PNG
729 file. Naming a "device" on the commandline is the most important
730 single parameter to tell Ghostscript how exactly it should render the
731 input. New Ghostscript versions are released at fairly regular
732 intervals, now by artofcode LLC. They are initially put under the
733 "AFPL" license, but re-released under the GNU GPL as soon as the next
734 AFPL version appears. GNU Ghostscript is probably the version
735 installed on most Samba systems. But it has got some
736 deficiencies. <indexterm><primary>Ghostscript</primary><secondary>ESP</secondary><see>ESP GhostScript</see></indexterm>Therefore ESP Ghostscript was developed as an
737 enhancement over GNU Ghostscript, with lots of bug-fixes, additional
738 devices and improvements. It is jointly maintained by developers from
739 CUPS, Gimp-Print, MandrakeSoft, SuSE, RedHat and Debian. It includes
740 the "cups" device (essential to print to non-PS printers from CUPS).
741 </para></tip>
742 </sect2>
744 <sect2>
745 <title>PostScript Printer Description (PPD) Specification</title>
747 <indexterm><primary>PPD</primary></indexterm>
749 <para>
750 While PostScript in essence is a <emphasis>Page Description
751 Language</emphasis> (PDL) to represent the page layout in a
752 <emphasis>device independent</emphasis> way, real world print jobs are
753 always ending up to be output on a hardware with device-specific
754 features. To take care of all the differences in hardware, and to
755 allow for innovations, Adobe has specified a syntax and file format
756 for <emphasis>PostScript Printer Description</emphasis> (PPD)
757 files. Every PostScript printer ships with one of these files.
758 </para>
760 <para>
761 PPDs contain all information about general and special features of the
762 given printer model: Which different resolutions can it handle? Does
763 it have a Duplexing Unit? How many paper trays are there? What media
764 types and sizes does it take? For each item it also names the special
765 command string to be sent to the printer (mostly inside the PostScript
766 file) in order to enable it.
767 </para>
769 <para>
770 Information from these PPDs is meant to be taken into account by the
771 printer drivers. Therefore, installed as part of the Windows
772 PostScript driver for a given printer is the printer's PPD. Where it
773 makes sense, the PPD features are presented in the drivers' UI dialogs
774 to display to the user as choice of print options. In the end, the
775 user selections are somehow written (in the form of special
776 PostScript, PJL, JCL or vendor-dependent commands) into the PostScript
777 file created by the driver.
778 </para>
780 <warning><para>
781 <indexterm><primary>PDF</primary></indexterm>
782 A PostScript file that was created to contain device-specific commands
783 for achieving a certain print job output (e.g. duplexed, stapled and
784 punched) on a specific target machine, may not print as expected, or
785 may not be printable at all on other models; it also may not be fit
786 for further processing by software (e.g. by a PDF distilling program).
787 </para></warning>
788 </sect2>
790 <sect2>
791 <title>CUPS can use all Windows-formatted Vendor PPDs</title>
793 <para>
794 CUPS can handle all spec-compliant PPDs as supplied by the
795 manufacturers for their PostScript models. Even if a
796 UNIX/Linux-illiterate vendor might not have mentioned our favorite
797 OS in his manuals and brochures -- you can safely trust this:
798 <emphasis>if you get hold of the Windows NT version of the PPD, you
799 can use it unchanged in CUPS</emphasis> and thus access the full
800 power of your printer just like a Windows NT user could!
801 </para>
803 <tip><para>
804 To check the spec compliance of any PPD online, go to <ulink
805 noescape="1" url="http://www.cups.org/testppd.php">http://www.cups.org/testppd.php</ulink>
806 and upload your PPD. You will see the results displayed
807 immediately. CUPS in all versions after 1.1.19 has a much more strict
808 internal PPD parsing and checking code enabled; in case of printing
809 trouble this online resource should be one of your first pitstops.
810 </para></tip>
812 <warning><para>
813 <indexterm><primary>foomatic</primary></indexterm>
814 <indexterm><primary>cupsomatic</primary></indexterm>
815 For real PostScript printers <emphasis>don't</emphasis> use the
816 <emphasis>Foomatic</emphasis> or <emphasis>cupsomatic</emphasis>
817 PPDs from Linuxprinting.org. With these devices the original
818 vendor-provided PPDs are always the first choice!
819 </para></warning>
821 <tip><para>
822 If you are looking for an original vendor-provided PPD of a specific
823 device, and you know that an NT4 box (or any other Windows box) on
824 your LAN has the PostScript driver installed, just use
825 <command>smbclient //NT4-box/print\$ -U username</command> to
826 access the Windows directory where all printer driver files are
827 stored. First look in the <filename>W32X86/2</filename> subdir for
828 the PPD you are seeking.
829 </para></tip>
830 </sect2>
832 <sect2>
833 <title>CUPS also uses PPDs for non-PostScript Printers</title>
835 <para>
836 CUPS also uses specially crafted PPDs to handle non-PostScript
837 printers. These PPDs are usually not available from the vendors (and
838 no, you can't just take the PPD of a Postscript printer with the same
839 model name and hope it works for the non-PostScript version too). To
840 understand how these PPDs work for non-PS printers we first need to
841 dive deeply into the CUPS filtering and file format conversion
842 architecture. Stay tuned.
843 </para>
844 </sect2>
845 </sect1>
847 <sect1>
848 <title>The CUPS Filtering Architecture</title>
850 <para>
851 The core of the CUPS filtering system is based on
852 <emphasis>Ghostscript</emphasis>. In addition to Ghostscript, CUPS
853 uses some other filters of its own. You (or your OS vendor) may have
854 plugged in even more filters. CUPS handles all data file formats under
855 the label of various <emphasis>MIME types</emphasis>. Every incoming
856 printfile is subjected to an initial
857 <emphasis>auto-typing</emphasis>. The auto-typing determines its given
858 MIME type. A given MIME type implies zero or more possible filtering
859 chains relevant to the selected target printer. This section discusses
860 how MIME types recognition and conversion rules interact. They are
861 used by CUPS to automatically setup a working filtering chain for any
862 given input data format.
863 </para>
865 <para>
866 If CUPS rasterizes a PostScript file <emphasis>natively</emphasis> to
867 a bitmap, this is done in 2 stages:
868 </para>
870 <itemizedlist>
871 <listitem><para>the first stage uses a Ghostscript device named "cups"
872 (this is since version 1.1.15) and produces a generic raster format
873 called "CUPS raster".
874 </para></listitem>
876 <listitem><para>the second stage uses a "raster driver" which converts
877 the generic CUPS raster to a device specific raster.</para></listitem>
878 </itemizedlist>
880 <para>
881 Make sure your Ghostscript version has the "cups" device compiled in
882 (check with <command>gs -h | grep cups</command>).  Otherwise you
883 may encounter the dreaded <computeroutput>Unable to convert file
884 0</computeroutput> in your CUPS error_log file. To have "cups" as a
885 device in your Ghostscript, you either need to <emphasis>patch GNU
886 Ghostscript</emphasis> and re-compile or use <indexterm><primary>ESP</primary><secondary>Ghostscript</secondary></indexterm><ulink
887 url="http://www.cups.org/ghostscript.php">ESP Ghostscript</ulink>. The
888 superior alternative is ESP Ghostscript: it supports not just CUPS,
889 but 300 other devices too (while GNU Ghostscript supports only about
890 180). Because of this broad output device support, ESP Ghostscript is
891 the first choice for non-CUPS spoolers too. It is now recommended by
892 Linuxprinting.org for all spoolers.
893 </para>
895 <para>
896 <indexterm><primary>cupsomatic</primary></indexterm>
897 <indexterm><primary>foomatic</primary></indexterm>
898 CUPS printers may be setup to use <emphasis>external</emphasis>
899 rendering paths. One of the most common ones is provided by the
900 <emphasis>Foomatic/cupsomatic</emphasis> concept, from <ulink
901 url="http://www.linuxprinting.org/">Linuxprinting.org</ulink>.  This
902 uses the classical Ghostscript approach, doing everything in one
903 step. It doesn't use the "cups" device, but one of the many
904 others. However, even for Foomatic/cupsomatic usage, best results and
905 <indexterm><primary>ESP</primary><secondary>Ghostscript</secondary></indexterm>
906 broadest printer model support is provided by ESP Ghostscript (more
907 about cupsomatic/Foomatic, particularly the new version called now
908 <emphasis>foomatic-rip</emphasis>, follows below).
909 </para>
911 <sect2>
912 <title>MIME types and CUPS Filters</title>
914 <para>
915         <indexterm><primary>MIME</primary></indexterm>
916 CUPS reads the file <filename>/etc/cups/mime.types</filename>
917 (and all other files carrying a <filename>*.types</filename> suffix
918 in the same directory) upon startup. These files contain the MIME
919 type recognition rules which are applied when CUPS runs its
920 auto-typing routines. The rule syntax is explained in the man page
921 for <filename>mime.types</filename> and in the comments section of the
922 <filename>mime.types</filename> file itself. A simple rule reads
923 like this:
924 </para>
926 <para>
927 <indexterm><primary>application/pdf</primary></indexterm>
928 <screen>
929  application/pdf         pdf string(0,%PDF)
930 </screen></para>
932 <para>
933 This means: if a filename has either a
934 <filename>.pdf</filename> suffix, or if the magic
935 string <emphasis>%PDF</emphasis> is right at the
936 beginning of the file itself (offset 0 from the start), then it is
937 a PDF file (<emphasis>application/pdf</emphasis>).
938 Another rule is this: 
939 </para>
941 <para><screen>
942  application/postscript  ai eps ps string(0,%!) string(0,&lt;04&gt;%!)
943 </screen></para>
945 <para>
946 Its meaning: if the filename has one of the suffixes
947 <filename>.ai</filename>, <filename>.eps</filename>,
948 <filename>.ps</filename> or if the file itself starts with one of the
949 strings <emphasis>%!</emphasis> or <emphasis><![CDATA[<04>%!]]></emphasis>, it
950 is a generic PostScript file
951 (<emphasis>application/postscript</emphasis>).
952 </para>
954 <note><para>
955 There is a very important difference between two similar MIME type in
956 CUPS: one is <emphasis>application/postscript</emphasis>, the other is
957 <emphasis>application/vnd.cups-postscript</emphasis>. While
958 <emphasis>application/postscript</emphasis> is meant to be device
959 independent (job options for the file are still outside the PS file
960 content, embedded in commandline or environment variables by CUPS),
961 <emphasis>application/vnd.cups-postscript</emphasis> may have the job
962 options inserted into the PostScript data itself (were
963 applicable). The transformation of the generic PostScript
964 (application/postscript) to the device-specific version
965 (application/vnd.cups-postscript) is the responsibility of the
966 CUPS <emphasis>pstops</emphasis> filter. pstops uses information
967 contained in the PPD to do the transformation.
968 </para></note>
970 <warning><para>
971 Don't confuse the other mime.types file your system might be using
972 with the one in the <filename>/etc/cups/</filename> directory.
973 </para></warning>
975 <para>
976 CUPS can handle ASCII text, HP-GL, PDF, PostScript, DVI and a
977 lot of image formats (GIF. PNG, TIFF, JPEG, Photo-CD, SUN-Raster,
978 PNM, PBM, SGI-RGB and some more) and their associated MIME types
979 with its filters.
980 </para>
981 </sect2>
983 <sect2>
984 <title>MIME type Conversion Rules</title>
986 <indexterm><primary>MIME</primary></indexterm>
988 <para>
989 CUPS reads the file <filename>/etc/cups/mime.convs</filename>
990 (and all other files named with a <filename>*.convs</filename>
991 suffix in the same directory) upon startup. These files contain
992 lines naming an input MIME type, an output MIME type, a format
993 conversion filter which can produce the output from the input type
994 and virtual costs associated with this conversion. One example line
995 reads like this:
996 </para>
998 <para><screen>
999  application/pdf         application/postscript   33   pdftops
1000 </screen></para>
1002 <para>
1003 This means that the <emphasis>pdftops</emphasis> filter will take
1004 <emphasis>application/pdf</emphasis> as input and produce
1005 <emphasis>application/postscript</emphasis> as output, the virtual
1006 cost of this operation is 33 CUPS-$. The next filter is more
1007 expensive, costing 66 CUPS-$:
1008 </para>
1010 <indexterm><primary>pdf</primary></indexterm>
1012 <para><screen>
1013  application/vnd.hp-HPGL application/postscript   66   hpgltops
1014 </screen></para>
1016 <para>
1017 This is the <emphasis>hpgltops</emphasis>, which processes HP-GL
1018 plotter files to PostScript.
1019 </para>
1021 <indexterm><primary>application/octet-stream</primary></indexterm>
1023 <para><screen>
1024  application/octet-stream
1025 </screen></para>
1027 <para>
1028 Here are two more examples: 
1029 </para>
1031 <indexterm><primary>text/plain</primary></indexterm>
1033 <para><screen>
1034  application/x-shell     application/postscript   33    texttops
1035  text/plain              application/postscript   33    texttops
1036 </screen></para>
1038 <para>
1039 The last two examples name the <emphasis>texttops</emphasis> filter
1040 to work on "text/plain" as well as on "application/x-shell". (Hint:
1041 this differentiation is needed for the syntax highlighting feature of
1042 "texttops").
1043 </para>
1044 </sect2>
1046 <sect2>
1047 <title>Filter Requirements</title>
1049 <indexterm><primary>MIME</primary></indexterm>
1051 <para>
1052 There are many more combinations named in mime.convs.  However, you
1053 are not limited to use the ones pre-defined there. You can plug in any
1054 filter you like into the CUPS framework. It must meet, or must be made
1055 to meet some minimal requirements. If you find (or write) a cool
1056 conversion filter of some kind, make sure it complies to what CUPS
1057 needs, and put in the right lines in <filename>mime.types</filename>
1058 and <filename>mime.convs</filename>, then it will work seamlessly
1059 inside CUPS!
1060 </para>
1062 <tip><para>
1063 The mentioned "CUPS requirements" for filters are simple. Take
1064 filenames or <filename>stdin</filename> as input and write to
1065 <filename>stdout</filename>. They should take these 5 or 6 arguments:
1066 <emphasis>printer job user title copies options [filename]</emphasis>
1067 </para>
1069 <variablelist>
1070 <varlistentry><term>Printer</term>
1071 <listitem><para>The name of the printer queue (normally this is the
1072 name of the filter being run)</para></listitem>
1073 </varlistentry>
1075 <varlistentry><term>job</term>
1076 <listitem><para>The numeric job ID for the job being
1077 printed</para></listitem>
1078 </varlistentry>
1080 <varlistentry><term>user</term>
1081 <listitem><para>The string from the originating-user-name
1082 attribute</para></listitem>
1083 </varlistentry>
1085 <varlistentry><term>title</term>
1086 <listitem><para>The string from the job-name attribute</para></listitem>
1087 </varlistentry>
1089 <varlistentry><term>copies</term>
1090 <listitem><para>The numeric value from the number-copies
1091 attribute</para></listitem>
1092 </varlistentry>
1094 <varlistentry><term>options</term>
1095 <listitem><para>The job options</para></listitem>
1096 </varlistentry>
1098 <varlistentry><term>filename</term>
1099 <listitem><para>(Optionally) The print request file (if missing,
1100 filters expected data fed through <filename>stdin</filename>). In most
1101 cases it is very easy to write a simple wrapper script around existing
1102 filters to make them work with CUPS.</para></listitem>
1103 </varlistentry>
1104 </variablelist>
1105 </tip>
1106 </sect2>
1108 <sect2>
1109 <title>Prefilters</title>
1111 <indexterm><primary>PostScript</primary></indexterm>
1113 <para>
1114 As was said, PostScript is the central file format to any UNIX based
1115 printing system. From PostScript, CUPS generates raster data to feed
1116 non-PostScript printers.
1117 </para>
1119 <para>
1120 But what is happening if you send one of the supported non-PS formats
1121 to print? Then CUPS runs "pre-filters" on these input formats to
1122 generate PostScript first. There are pre-filters to create PS from
1123 ASCII text, PDF, DVI or HP-GL. The outcome of these filters is always
1124 of MIME type <emphasis>application/postscript</emphasis> (meaning that
1125 any device-specific print options are not yet embedded into the
1126 PostScript by CUPS, and that the next filter to be called is
1127 pstops). Another pre-filter is running on all supported image formats,
1128 the <emphasis>imagetops</emphasis> filter. Its outcome is always of
1129 MIME type <emphasis>application/vnd.cups-postscript</emphasis>
1130 (<emphasis>not</emphasis> application/postscript), meaning it has the
1131 print options already embedded into the file.
1132 </para>
1134 <para>
1135         <image id="small4" scale="25"><imagedescription>Prefiltering in CUPS to form Postscript</imagedescription>
1136         <imagefile>4small</imagefile>
1137 </image>
1138 </para>
1139 </sect2>
1141 <sect2>
1142 <title>pstops</title>
1144 <para>
1145 <emphasis>pstops</emphasis>is the filter to convert
1146 <emphasis>application/postscript</emphasis> to
1147 <emphasis>application/vnd.cups-postscript</emphasis>. It was said
1148 above that this filter inserts all device-specific print options
1149 (commands to the printer to ask for the duplexing of output, or
1150 stapling an punching it, etc.) into the PostScript file.
1151 </para>
1153 <para>
1154         <image id="small5" scale="25"><imagedescription>Adding Device-specific Print Options</imagedescription>
1155                 <imagefile>5small</imagefile>
1156         </image>
1157 </para>
1159 <para>
1160 This is not all: other tasks performed by it are:
1161 </para>
1163 <itemizedlist>
1164 <listitem><para>
1165 selecting the range of pages to be printed (if you choose to
1166 print only pages "3, 6, 8-11, 16, 19-21", or only the odd numbered
1167 ones)
1168 </para></listitem>
1170 <listitem><para>
1171 putting 2 or more logical pages on one sheet of paper (the
1172 so-called "number-up" function)
1173 </para></listitem>
1175 <listitem><para>counting the pages of the job to insert the accounting
1176 information into the <filename>/var/log/cups/page_log</filename>
1177 </para></listitem>
1178 </itemizedlist>
1179 </sect2>
1181 <sect2>
1182 <title>pstoraster</title>
1184 <para>
1185 <emphasis>pstoraster</emphasis> is at the core of the CUPS filtering
1186 system. It is responsible for the first stage of the rasterization
1187 process. Its input is of MIME type application/vnd.cups-postscript;
1188 its output is application/vnd.cups-raster. This output format is not
1189 yet meant to be printable. Its aim is to serve as a general purpose
1190 input format for more specialized <emphasis>raster drivers</emphasis>,
1191 that are able to generate device-specific printer data.
1192 </para>
1194 <para>
1195         <image id="small6" scale="25"><imagedescription>Postscript to intermediate Raster format</imagedescription><imagefile>6small</imagefile></image>
1196 </para>
1198 <para>
1199 CUPS raster is a generic raster format with powerful features. It is
1200 able to include per-page information, color profiles and more to be
1201 used by the following downstream raster drivers. Its MIME type is
1202 registered with IANA and its specification is of course completely
1203 open. It is designed to make it very easy and inexpensive for
1204 manufacturers to develop Linux and UNIX raster drivers for their
1205 printer models, should they choose to do so. CUPS always takes care
1206 for the first stage of rasterization so these vendors don't need to care
1207 about Ghostscript complications (in fact, there is currently more
1208 than one vendor financing the development of CUPS raster drivers).
1209 </para>
1211 <para>
1212         <image id="small7"><imagedescription>CUPS-raster production using Ghostscript</imagedescription>
1213                 <imagefile>7small</imagefile>
1214         </image>
1215 </para>
1217 <para>
1218 CUPS versions before version 1.1.15 were shipping a binary (or source
1219 code) standalone filter, named "pstoraster". pstoraster was derived
1220 from GNU Ghostscript 5.50, and could be installed besides and in
1221 addition to any GNU or AFPL Ghostscript package without conflicting.
1222 </para>
1224 <para>
1225 From version 1.1.15, this has changed. The functions for this has been
1226 integrated back into Ghostscript (now based on GNU Ghostscript version
1227 7.05). The "pstoraster" filter is now a simple shell script calling
1228 <command>gs</command> with the <command>-sDEVICE=cups</command>
1229 parameter. If your Ghostscript doesn't show a success on asking for
1230 <command>gs -h |grep cups</command>, you might not be able to
1231 print. Update your Ghostscript then!
1232 </para>
1233 </sect2>
1235 <sect2>
1236 <title>imagetops and imagetoraster</title>
1238 <para>
1239 Above in the section about prefilters, we mentioned the prefilter
1240 that generates PostScript from image formats. The imagetoraster
1241 filter is used to convert directly from image to raster, without the
1242 intermediate PostScript stage. It is used more often than the above
1243 mentioned prefilters. Here is a summarizing flowchart of image file
1244 filtering:
1245 </para>
1247 <para>
1248         <image id="small8"><imagedescription>Image format to CUPS-raster format conversion</imagedescription>
1249                 <imagefile>8small</imagefile>
1250         </image>
1251 </para>
1253 </sect2>
1255 <sect2>
1256 <title>rasterto [printers specific]</title>
1258 <para>
1259 CUPS ships with quite some different raster drivers processing CUPS
1260 raster. On my system I find in /usr/lib/cups/filter/ these:
1261 <parameter>rastertoalps</parameter>, <parameter>rastertobj</parameter>, <parameter>rastertoepson</parameter>, <parameter>rastertoescp</parameter>,
1262 <parameter>rastertopcl</parameter>, <parameter>rastertoturboprint</parameter>, <parameter>rastertoapdk</parameter>, <parameter>rastertodymo</parameter>,
1263 <parameter>rastertoescp</parameter>, <parameter>rastertohp</parameter> and
1264 <parameter>rastertoprinter</parameter>. Don't worry if you have less
1265 than this; some of these are installed by commercial add-ons to CUPS
1266 (like <parameter>rastertoturboprint</parameter>), others (like
1267 <parameter>rastertoprinter</parameter>) by 3rd party driver
1268 development projects (such as Gimp-Print) wanting to cooperate as
1269 closely as possible with CUPS.
1270 </para>
1272 <para>
1273         <image id="small9"><imagedescription>Raster to Printer Specific formats</imagedescription>
1274                 <imagefile>9small</imagefile>
1275         </image>
1276 </para>
1277 </sect2>
1279 <sect2>
1280 <title>CUPS Backends</title>
1282 <para>
1283 The last part of any CUPS filtering chain is a "backend".  Backends
1284 are special programs that send the print-ready file to the final
1285 device. There is a separate backend program for any transfer
1286 "protocol" of sending printjobs over the network, or for every local
1287 interface. Every CUPS printqueue needs to have a CUPS "device-URI"
1288 associated with it. The device URI is the way to encode the backend
1289 used to send the job to its destination. Network device-URIs are using
1290 two slashes in their syntax, local device URIs only one, as you can
1291 see from the following list. Keep in mind that local interface names
1292 may vary much from my examples, if your OS is not Linux:
1293 </para>
1295 <variablelist>
1296 <varlistentry><term>usb</term>
1297 <listitem><para>
1298 This backend sends printfiles to USB-connected printers. An
1299 example for the CUPS device-URI to use is:
1300 <filename>usb:/dev/usb/lp0</filename>
1301 </para></listitem></varlistentry>
1303 <varlistentry><term>serial</term>
1304 <listitem><para>
1305 This backend sends printfiles to serially connected printers.
1306 An example for the CUPS device-URI to use is:
1307 <filename>serial:/dev/ttyS0?baud=11500</filename>
1308 </para></listitem></varlistentry>
1310 <varlistentry><term>parallel</term>
1311 <listitem><para>
1312 This backend sends printfiles to printers connected to the
1313 parallel port. An example for the CUPS device-URI to use is:
1314 <filename>parallel:/dev/lp0</filename>
1315 </para></listitem></varlistentry>
1317 <varlistentry><term>scsi</term>
1318 <listitem><para>
1319 This backend sends printfiles to printers attached to the
1320 SCSI interface. An example for the CUPS device-URI to use is:
1321 <filename>scsi:/dev/sr1</filename>
1322 </para></listitem></varlistentry>
1324 <varlistentry><term>lpd</term>
1325 <listitem><para>
1326 This backend sends printfiles to LPR/LPD connected network
1327 printers. An example for the CUPS device-URI to use is:
1328 <filename>lpd://remote_host_name/remote_queue_name</filename>
1329 </para></listitem></varlistentry>
1331 <varlistentry><term>AppSocket/HP JetDirect</term>
1332 <listitem><para>
1333 This backend sends printfiles to AppSocket (a.k.a. "HP
1334 JetDirect") connected network printers. An example for the CUPS
1335 device-URI to use is:
1336 <filename>socket://10.11.12.13:9100</filename>
1337 </para></listitem></varlistentry>
1339 <varlistentry><term>ipp</term>
1340 <listitem><para>
1341 This backend sends printfiles to IPP connected network
1342 printers (or to other CUPS servers). Examples for CUPS device-URIs
1343 to use are:
1344 <filename>ipp:://192.193.194.195/ipp</filename>
1345 (for many HP printers) or
1346 <filename>ipp://remote_cups_server/printers/remote_printer_name</filename>
1347 </para></listitem></varlistentry>
1349 <varlistentry><term>http</term>
1350 <listitem><para>
1351 This backend sends printfiles to HTTP connected printers.
1352 (The http:// CUPS backend is only a symlink to the ipp:// backend.)
1353 Examples for the CUPS device-URIs to use are:
1354 <filename>http:://192.193.194.195:631/ipp</filename>
1355 (for many HP printers) or
1356 <filename>http://remote_cups_server:631/printers/remote_printer_name</filename>
1357 </para></listitem></varlistentry>
1359 <varlistentry><term>smb</term>
1360 <listitem><para>
1361 This backend sends printfiles to printers shared by a Windows
1362 host. An example for CUPS device-URIs to use are:
1363 <filename>smb://workgroup/server/printersharename</filename>
1365 <filename>smb://server/printersharename</filename>
1367 <filename>smb://username:password@workgroup/server/printersharename</filename>
1369 <filename>smb://username:password@server/printersharename</filename>.
1370 The smb:// backend is a symlink to the Samba utility
1371 <emphasis>smbspool</emphasis> (doesn't ship with CUPS). If the
1372 symlink is not present in your CUPS backend directory, have your
1373 root user create it: <command>ln -s `which smbspool`
1374 /usr/lib/cups/backend/smb</command>.
1375 </para></listitem></varlistentry>
1376 </variablelist>
1378 <para>
1379 It is easy to write your own backends as Shell or Perl scripts, if you
1380 need any modification or extension to the CUPS print system. One
1381 reason could be that you want to create "special" printers which send
1382 the printjobs as email (through a "mailto:/" backend), convert them to
1383 PDF (through a "pdfgen:/" backend) or dump them to "/dev/null" (In
1384 fact I have the system-wide default printer set up to be connected to
1385 a "devnull:/" backend: there are just too many people sending jobs
1386 without specifying a printer, or scripts and programs which don't name
1387 a printer. The system-wide default deletes the job and sends a polite
1388 mail back to the $USER asking him to always specify a correct
1389 printername).
1390 </para>
1392 <para>
1393 Not all of the mentioned backends may be present on your system or
1394 usable (depending on your hardware configuration). One test for all
1395 available CUPS backends is provided by the <emphasis>lpinfo</emphasis>
1396 utility. Used with the <option>-v</option> parameter, it lists
1397 all available backends:
1398 </para>
1400 <para><screen>
1401 &prompt;<userinput>lpinfo -v</userinput>
1402 </screen></para>
1403 </sect2>
1405 <sect2>
1406 <title>cupsomatic/Foomatic -- how do they fit into the Picture?</title>
1408 <indexterm><primary>cupsomatic</primary></indexterm>
1409 <indexterm><primary>foomatic</primary></indexterm>
1411 <para>
1412 "cupsomatic" filters may be the most widely used on CUPS
1413 installations. You must be clear about the fact that these were not
1414 developed by the CUPS people. They are a "Third Party" add-on to
1415 CUPS. They utilize the traditional Ghostscript devices to render jobs
1416 for CUPS. When troubleshooting, you should know about the
1417 difference. Here the whole rendering process is done in one stage,
1418 inside Ghostscript, using an appropriate "device" for the target
1419 printer. cupsomatic uses PPDs which are generated from the "Foomatic"
1420 Printer &amp; Driver Database at Linuxprinting.org.
1421 </para>
1423 <para>
1424 You can recognize these PPDs from the line calling the
1425 <emphasis>cupsomatic</emphasis> filter:
1426 </para>
1428 <para><screen>
1429  *cupsFilter: "application/vnd.cups-postscript  0  cupsomatic"
1430 </screen></para>
1432 <para>
1433 This line you may find amongst the first 40 or so lines of the PPD
1434 file. If you have such a PPD installed, the printer shows up in the
1435 CUPS web interface with a <emphasis>foomatic</emphasis> namepart for
1436 the driver description. cupsomatic is a Perl script that runs
1437 Ghostscript, with all the complicated commandline options
1438 auto-constructed from the selected PPD and commandline options give to
1439 the printjob.
1440 </para>
1442 <indexterm><primary>point and print</primary></indexterm>
1444 <para>
1445 However, cupsomatic is now deprecated. Its PPDs (especially the first
1446 generation of them, still in heavy use out there) are not meeting the
1447 Adobe specifications. You might also suffer difficulties when you try
1448 to download them with "Point'n'Print" to Windows clients. A better,
1449 and more powerful successor is now in a very stable Beta-version
1450 available: it is called <emphasis>foomatic-rip</emphasis>. To use
1451 foomatic-rip as a filter with CUPS, you need the new-type PPDs.  These
1452 have a similar, but different line:
1453 </para>
1455 <para><screen>
1457  *cupsFilter: "application/vnd.cups-postscript  0  foomatic-rip"
1459 </screen></para>
1461 <para>
1462 The PPD generating engine at Linuxprinting.org has been revamped.
1463 The new PPDs comply to the Adobe spec. On top, they also provide a
1464 new way to specify different quality levels (hi-res photo, normal
1465 color, grayscale, draft...) with a single click (whereas before you
1466 could have required 5 or more different selections (media type,
1467 resolution, inktype, dithering algorithm...). There is support for
1468 custom-size media built in. There is support to switch
1469 print-options from page to page, in the middle of a job. And the
1470 best thing is: the new foomatic-rip now works seamlessly with all
1471 legacy spoolers too (like LPRng, BSD-LPD, PDQ, PPR etc.), providing
1472 for them access to use PPDs for their printing!
1473 </para>
1474 </sect2>
1476 <sect2>
1477 <title>The Complete Picture</title>
1479 <para>
1480 If you want to see an overview over all the filters and how they
1481 relate to each other, the complete picture of the puzzle is at the end
1482 of this document.
1483 </para>
1484 </sect2>
1486 <sect2>
1487 <title><filename>mime.convs</filename></title>
1489 <para>
1490 CUPS auto-constructs all possible filtering chain paths for any given
1491 MIME type, and every printer installed. But how does it decide in
1492 favor or against a specific alternative?  (There may often be cases,
1493 where there is a choice of two or more possible filtering chains for
1494 the same target printer). Simple: you may have noticed the figures in
1495 the 3rd column of the mime.convs file. They represent virtual costs
1496 assigned to this filter. Every possible filtering chain will sum up to
1497 a total "filter cost". CUPS decides for the most "inexpensive" route.
1498 </para>
1500 <tip><para>
1501 The setting of <parameter>FilterLimit 1000</parameter> in
1502 <filename>cupsd.conf</filename> will not allow more filters to
1503 run concurrently than will consume a total of 1000 virtual filter
1504 cost. This is a very efficient way to limit the load of any CUPS
1505 server by setting an appropriate "FilterLimit" value. A FilterLimit of
1506 200 allows roughly 1 job at a time, while a FilterLimit of 1000 allows
1507 approximately 5 jobs maximum at a time.
1508 </para></tip>
1509 </sect2>
1511 <sect2>
1512 <title>"Raw" printing</title>
1514 <para>
1515 You can tell CUPS to print (nearly) any file "raw". "Raw" means it
1516 will not be filtered. CUPS will send the file to the printer "as is"
1517 without bothering if the printer is able to digest it. Users need to
1518 take care themselves that they send sensible data formats only. Raw
1519 printing can happen on any queue if the "-o raw" option is specified
1520 on the command line. You can also set up raw-only queues by simply not
1521 associating any PPD with it. This command:
1522 </para>
1524 <para><screen>
1525 &prompt;<userinput>lpadmin -P rawprinter -v socket://11.12.13.14:9100 -E</userinput>
1526 </screen></para>
1528 <para>
1529 sets up a queue named "rawprinter", connected via the "socket"
1530 protocol (a.k.a. "HP JetDirect") to the device at IP address
1531 11.12.1.3.14, using port 9100. (If you had added a PPD with
1532 <command>-P /path/to/PPD</command> to this command line, you would
1533 have installed a "normal" printqueue.
1534 </para>
1536 <para>
1537 CUPS will automatically treat each job sent to a queue as a "raw" one,
1538 if it can't find a PPD associated with the queue.  However, CUPS will
1539 only send known MIME types (as defined in its own mime.types file) and
1540 refuse others.
1541 </para>
1542 </sect2>
1544 <sect2>
1545 <title>"application/octet-stream" printing</title>
1547 <para>
1548 Any MIME type with no rule in the
1549 <filename>/etc/cups/mime.types</filename> file is regarded as unknown
1550 or <emphasis>application/octet-stream</emphasis> and will not be
1551 sent. Because CUPS refuses to print unknown MIME types per default,
1552 you will probably have experienced the fact that printjobs originating
1553 from Windows clients were not printed. You may have found an error
1554 message in your CUPS logs like:
1555 </para>
1557 <para><screen>
1558  Unable to convert file 0 to printable format for job
1559 </screen></para>
1561 <para>
1562 To enable the printing of "application/octet-stream" files, edit
1563 these two files:
1564 </para>
1566 <itemizedlist>
1567 <listitem><para><filename>/etc/cups/mime.convs</filename></para></listitem>
1569 <listitem><para><filename>/etc/cups/mime.types</filename></para></listitem>
1570 </itemizedlist>
1572 <para>
1573 Both contain entries (at the end of the respective files) which must
1574 be uncommented to allow RAW mode operation for
1575 application/octet-stream. In <filename>/etc/cups/mime.types</filename>
1576 make sure this line is present:
1577 </para>
1579 <indexterm><primary>application/octet-stream</primary></indexterm>
1581 <para><screen>
1582  application/octet-stream
1583 </screen></para>
1585 <para>
1586 This line (with no specific auto-typing rule set) makes all files
1587 not otherwise auto-typed a member of application/octet-stream. In
1588 <filename>/etc/cups/mime.convs</filename>, have this
1589 line: 
1590 </para>
1592 <para><screen>
1593  application/octet-stream   application/vnd.cups-raw   0   -
1594 </screen></para>
1596 <indexterm><primary>MIME</primary></indexterm>
1598 <para>
1599 This line tells CUPS to use the <emphasis>Null Filter</emphasis>
1600 (denoted as "-", doing... nothing at all) on
1601 <emphasis>application/octet-stream</emphasis>, and tag the result as
1602 <emphasis>application/vnd.cups-raw</emphasis>. This last one is
1603 always a green light to the CUPS scheduler to now hand the file over
1604 to the "backend" connecting to the printer and sending it over.
1605 </para>
1607 <note><para> Editing the <filename>mime.convs</filename> and the
1608 <filename>mime.types</filename> file does not
1609 <emphasis>enforce</emphasis> "raw" printing, it only
1610 <emphasis>allows</emphasis> it.
1611 </para></note>
1613 <formalpara>
1614 <title>Background</title>
1616 <para>
1617 CUPS being a more security-aware printing system than traditional ones
1618 does not by default allow one to send deliberate (possibly binary)
1619 data to printing devices.  (This could be easily abused to launch a
1620 Denial of Service attack on your printer(s), causing at least the loss
1621 of a lot of paper and ink...) "Unknown" data are regarded by CUPS
1622 as <emphasis>MIME type</emphasis>
1623 <emphasis>application/octet-stream</emphasis>. While you
1624 <emphasis>can</emphasis> send data "raw", the MIME type for these must
1625 be one that is known to CUPS and an allowed one. The file
1626 <filename>/etc/cups/mime.types</filename> defines the "rules" how CUPS
1627 recognizes MIME types. The file
1628 <filename>/etc/cups/mime.convs</filename> decides which file
1629 conversion filter(s) may be applied to which MIME types.
1630 </para>
1631 </formalpara>
1632 </sect2>
1634 <sect2>
1635 <title>PostScript Printer Descriptions (PPDs) for non-PS Printers</title>
1637 <indexterm><primary>PPD</primary></indexterm>
1639 <para>
1640 Originally PPDs were meant to be used for PostScript printers
1641 only. Here, they help to send device-specific commands and settings
1642 to the RIP which processes the jobfile. CUPS has extended this
1643 scope for PPDs to cover non-PostScript printers too. This was not
1644 very difficult, because it is a standardized file format. In a way
1645 it was logical too: CUPS handles PostScript and uses a PostScript
1646 RIP (=Ghostscript) to process the jobfiles. The only difference is:
1647 a PostScript printer has the RIP built-in, for other types of
1648 printers the Ghostscript RIP runs on the host computer.
1649 </para>
1651 <para>
1652 PPDs for a non-PS printer have a few lines that are unique to
1653 CUPS. The most important one looks similar to this:
1654 </para>
1656 <indexterm><primary>application/vnd.cups-raster</primary></indexterm>
1658 <para><screen>
1659  *cupsFilter: application/vnd.cups-raster  66   rastertoprinter
1660 </screen></para>
1662 <para>
1663 It is the last piece in the CUPS filtering puzzle. This line tells the
1664 CUPS daemon to use as a last filter "rastertoprinter".  This filter
1665 should be served as input an "application/vnd.cups-raster" MIME type
1666 file. Therefore CUPS should auto-construct a filtering chain, which
1667 delivers as its last output the specified MIME type. This is then
1668 taken as input to the specified "rastertoprinter" filter. After this
1669 the last filter has done its work ("rastertoprinter" is a Gimp-Print
1670 filter), the file should go to the backend, which sends it to the
1671 output device.
1672 </para>
1674 <para>
1675 CUPS by default ships only a few generic PPDs, but they are good for
1676 several hundred printer models. You may not be able to control
1677 different paper trays, or you may get larger margins than your
1678 specific model supports):
1679 </para>
1681 <table frame="all">
1682         <title>PPD's shipped with CUPS</title>
1683         <tgroup cols="2" align="left">
1684                 <colspec align="left"/>
1685                 <colspec align="justify"/>
1686                 <thead><row><entry>PPD file</entry><entry>Printer type</entry></row></thead>
1687                 <tbody>
1688                         <row><entry>deskjet.ppd</entry><entry>older HP inkjet printers and compatible</entry></row>
1690                 <row><entry>deskjet2.ppd</entry> <entry>newer HP inkjet printers and compatible </entry> </row>
1692                 <row><entry>dymo.ppd</entry> <entry>label printers </entry> </row>
1694                 <row><entry>epson9.ppd</entry> <entry>Epson 24pin impact printers and compatible </entry> </row>
1696                 <row><entry>epson24.ppd</entry> <entry>Epson 24pin impact printers and compatible </entry> </row>
1698                 <row><entry>okidata9.ppd</entry> <entry>Okidata 9pin impact printers and compatible </entry> </row>
1700                 <row><entry>okidat24.ppd</entry> <entry>Okidata 24pin impact printers and compatible </entry> </row>
1702                 <row><entry>stcolor.ppd</entry> <entry>older Epson Stylus Color printers </entry> </row>
1704                 <row><entry>stcolor2.ppd</entry> <entry>newer Epson Stylus Color printers </entry> </row>
1706                 <row><entry>stphoto.ppd</entry> <entry>older Epson Stylus Photo printers </entry> </row>
1708                 <row><entry>stphoto2.ppd</entry> <entry>newer Epson Stylus Photo printers </entry> </row>
1710                 <row><entry>laserjet.ppd</entry> <entry>all PCL printers. Further below is a discussion of several other driver/PPD-packages suitable for use with CUPS.  </entry> </row>
1712                 </tbody>
1713         </tgroup>
1714 </table>
1716 </sect2>
1718 <sect2>
1719 <title>Difference between <emphasis>cupsomatic/foomatic-rip</emphasis> and
1720 <emphasis>native CUPS</emphasis> printing</title>
1722 <indexterm><primary>cupsomatic</primary></indexterm>
1723 <indexterm><primary>foomatic-rip</primary></indexterm>
1725 <para>
1726 Native CUPS rasterization works in two steps.
1727 </para>
1729 <itemizedlist>
1730 <listitem><para>
1731 First is the "pstoraster" step. It uses the special "cups"
1732 <indexterm><primary>ESP</primary><secondary>Ghostscript</secondary></indexterm>
1733 device from ESP Ghostscript 7.05.x as its tool
1734 </para></listitem>
1736 <listitem><para>
1737 Second comes the "rasterdriver" step. It uses various
1738 device-specific filters; there are several vendors who provide good
1739 quality filters for this step, some are Free Software, some are
1740 Shareware/Non-Free, some are proprietary.</para></listitem>
1741 </itemizedlist>
1743 <para>
1744 Often this produces better quality (and has several more
1745 advantages) than other methods.
1746 </para>
1748 <para>
1749         <image id="small10"><imagedescription>cupsomatic/foomatic processing versus Native CUPS</imagedescription>
1750                 <imagefile>10small</imagefile>
1751         </image>
1752 </para>
1754 <para>
1755 One other method is the <emphasis>cupsomatic/foomatic-rip</emphasis>
1756 way. Note that cupsomatic is <emphasis>not</emphasis> made by the CUPS
1757 developers. It is an independent contribution to printing development,
1758 made by people from Linuxprinting.org (see also <ulink
1759         noescape="1" url="http://www.cups.org/cups-help.html">http://www.cups.org/cups-help.html</ulink>).
1760 cupsomatic is no longer developed and maintained and is no longer
1761 supported. It has now been replaced by
1762 <emphasis>foomatic-rip</emphasis>. foomatic-rip is a complete re-write
1763 of the old cupsomatic idea, but very much improved and generalized to
1764 other (non-CUPS) spoolers. An upgrade to foomatic-rip is strongly
1765 advised, especially if you are upgrading to a recent version of CUPS
1766 too.
1767 </para>
1769 <para>
1770         <indexterm><primary>cupsomatic</primary></indexterm>
1771         <indexterm><primary>foomatic</primary></indexterm>
1772 Both the cupsomatic (old) and the foomatic-rip (new) methods from
1773 Linuxprinting.org use the traditional Ghostscript print file
1774 processing, doing everything in a single step. It therefore relies on
1775 all the other devices built-in into Ghostscript. The quality is as
1776 good (or bad) as Ghostscript rendering is in other spoolers. The
1777 advantage is that this method supports many printer models not
1778 supported (yet) by the more modern CUPS method.
1779 </para>
1781 <para>
1782 Of course, you can use both methods side by side on one system (and
1783 even for one printer, if you set up different queues), and find out
1784 which works best for you.
1785 </para>
1787 <para>
1788 cupsomatic "kidnaps" the printfile after the
1789 <emphasis>application/vnd.cups-postscript</emphasis> stage and
1790 deviates it through the CUPS-external, system wide Ghostscript
1791 installation: Therefore the printfile bypasses the "pstoraster" filter
1792 (and thus also bypasses the CUPS-raster-drivers
1793 "rastertosomething"). After Ghostscript finished its rasterization,
1794 cupsomatic hands the rendered file directly to the CUPS backend. The
1795 flowchart above illustrates the difference between native CUPS
1796 rendering and the Foomatic/cupsomatic method.
1797 </para>
1798 </sect2>
1800 <sect2>
1801 <title>Examples for filtering Chains</title>
1803 <para>
1804 Here are a few examples of commonly occurring filtering chains to
1805 illustrate the workings of CUPS.
1806 </para>
1808 <para>
1809 Assume you want to print a PDF file to a HP JetDirect-connected
1810 PostScript printer, but you want to print the pages 3-5, 7, 11-13
1811 only, and you want to print them "2-up" and "duplex":
1812 </para>
1814 <itemizedlist>
1815 <listitem><para>your print options (page selection as required, 2-up,
1816 duplex) are passed to CUPS on the commandline;</para></listitem>
1818 <listitem><para>the (complete) PDF file is sent to CUPS and autotyped as
1819 <emphasis>application/pdf</emphasis>;</para></listitem>
1821 <listitem><para>the file therefore first must pass the
1822 <emphasis>pdftops</emphasis> pre-filter, which produces PostScript
1823 MIME type <emphasis>application/postscript</emphasis> (a preview here
1824 would still show all pages of the original PDF);</para></listitem>
1826 <listitem><para>the file then passes the <emphasis>pstops</emphasis>
1827 filter which applies the commandline options: it selects the pages
1828 2-5, 7 and 11-13, creates and imposed layout "2 pages on 1 sheet" and
1829 inserts the correct "duplex" command (as is defined in the printer's
1830 PPD) into the new PostScript file; the file now is of PostScript MIME
1831 type
1832 <emphasis>application/vnd.cups-postscript</emphasis>;</para></listitem>
1834 <listitem><para>the file goes to the <emphasis>socket</emphasis>
1835 backend, which transfers the job to the printers.</para></listitem>
1836 </itemizedlist>
1838 <para>
1839         The resulting filter chain therefore is as drawn in <link linkend="pdftosocket">the image below</link>.
1840 </para>
1842 <image><imagefile>pdftosocket</imagefile><imagedescription>PDF to socket chain</imagedescription></image>
1844 <para>
1845 Assume your want to print the same filter to an USB-connected
1846 Epson Stylus Photo printer, installed with the CUPS
1847 <filename>stphoto2.ppd</filename>. The first few filtering stages
1848 are nearly the same:
1849 </para>
1851 <itemizedlist>
1852 <listitem><para>your print options (page selection as required, 2-up,
1853 duplex) are passed to CUPS on the commandline;</para></listitem>
1855 <listitem><para>the (complete) PDF file is sent to CUPS and autotyped as
1856 <emphasis>application/pdf</emphasis>;</para></listitem>
1858 <listitem><para>the file therefore first must pass the
1859 <emphasis>pdftops</emphasis> pre-filter, which produces PostScript
1860 MIME type <emphasis>application/postscript</emphasis> (a preview here
1861 would still show all pages of the original PDF);</para></listitem>
1863 <listitem><para>the file then passes the "pstops" filter which applies
1864 the commandline options: it selects the pages 2-5, 7 and 11-13,
1865 creates and imposed layout "2 pages on 1 sheet" and inserts the
1866 correct "duplex" command... (OOoops -- this printer and his PPD
1867 don't support duplex printing at all -- this option will be ignored
1868 then) into the new PostScript file; the file now is of PostScript
1869 MIME type 
1870 <emphasis>application/vnd.cups-postscript</emphasis>;</para></listitem>
1872 <listitem><para>the file then passes the
1873 <emphasis>pstoraster</emphasis> stage and becomes MIME type
1874 <emphasis>application/cups-raster</emphasis>;</para></listitem>
1876 <listitem><para>finally, the <emphasis>rastertoepson</emphasis> filter
1877 does its work (as is indicated in the printer's PPD), creating the
1878 printer-specific raster data and embedding any user-selected
1879 print-options into the print data stream;</para></listitem>
1881 <listitem><para>the file goes to the <emphasis>usb</emphasis> backend,
1882 which transfers the job to the printers.</para></listitem>
1883 </itemizedlist>
1885 <para>
1886         The resulting filter chain therefore is as drawn in <link linkend="pdftoepsonusb">the image below</link>.
1887 </para>
1889 <image><imagefile>pdftoepsonusb</imagefile><imagedescription>PDF to USB chain</imagedescription></image>
1890 </sect2>
1892 <sect2>
1893 <title>Sources of CUPS drivers / PPDs</title>
1895 <para>
1896 On the internet you can find now many thousand CUPS-PPD files
1897 (with their companion filters), in many national languages,
1898 supporting more than 1000 non-PostScript models.
1899 </para>
1901 <itemizedlist>
1902 <indexterm><primary>ESP</primary><secondary>Print Pro</secondary></indexterm>
1903 <indexterm><primary>PrintPro</primary><see>ESP Print Pro</see></indexterm>
1904 <listitem><para><ulink url="http://wwwl.easysw.com/printpro/">ESP
1905 PrintPro</ulink> (commercial,
1906 non-Free) is packaged with more than 3000 PPDs, ready for
1907 successful use "out of the box" on Linux, Mac OS X, IBM-AIX,
1908 HP-UX, Sun-Solaris, SGI-IRIX, Compaq Tru64, Digital UNIX and some
1909 more commercial Unices (it is written by the CUPS developers
1910 themselves and its sales help finance the further development of
1911 CUPS, as they feed their creators).</para></listitem>
1913 <listitem><para>the <ulink
1914 url="http://gimp-print.sourceforge.net/">Gimp-Print-Project
1915 </ulink> (GPL, Free Software)
1916 provides around 140 PPDs (supporting nearly 400 printers, many driven
1917 to photo quality output), to be used alongside the Gimp-Print CUPS
1918 filters;</para></listitem>
1920 <listitem><para><ulink url="http://www.turboprint.com/">TurboPrint
1921 </ulink> (Shareware, non-Free) supports
1922 roughly the same amount of printers in excellent
1923 quality;</para></listitem>
1925 <listitem><para><ulink
1926 url="http://www-124.ibm.com/developerworks/oss/linux/projects/omni/">OMNI
1927 </ulink>
1928 (LPGL, Free) is a package made by IBM, now containing support for more
1929 than 400 printers, stemming from the inheritance of IBM OS/2 Know-How
1930 ported over to Linux (CUPS support is in a Beta-stage at
1931 present);</para></listitem>
1933 <listitem><para><ulink url="http://hpinkjet.sourceforge.net/">HPIJS
1934 </ulink> (BSD-style licenses, Free)
1935 supports around 150 of HP's own printers and is also providing
1936 excellent print quality now (currently available only via the Foomatic
1937 path);</para></listitem>
1939 <listitem><para><ulink
1940 url="http://www.linuxprinting.org/">Foomatic/cupsomatic
1941 </ulink> (LPGL, Free) from
1942 Linuxprinting.org are providing PPDs for practically every Ghostscript
1943 filter known to the world (including Omni, Gimp-Print and
1944 HPIJS).</para></listitem>
1945 </itemizedlist>
1947 <note><para>
1948 The cupsomatic/Foomatic trick from Linuxprinting.org works
1949 differently from the other drivers. This is explained elsewhere in this
1950 document.
1951 </para></note>
1952 </sect2>
1954 <sect2>
1955 <title>Printing with Interface Scripts</title>
1957 <para>
1958 CUPS also supports the usage of "interface scripts" as known from
1959 System V AT&amp;T printing systems. These are often used for PCL
1960 printers, from applications that generate PCL print jobs.  Interface
1961 scripts are specific to printer models. They have a similar role as
1962 PPDs for PostScript printers. Interface scripts may inject the Escape
1963 sequences as required into the print data stream, if the user has
1964 chosen to select a certain paper tray, or print landscape, or use A3
1965 paper, etc. Interfaces scripts are practically unknown in the Linux
1966 realm. On HP-UX platforms they are more often used. You can use any
1967 working interface script on CUPS too. Just install the printer with
1968 the <command>-i</command> option:
1969 </para>
1971 <para><screen>
1972 &rootprompt;<userinput>lpadmin -p pclprinter -v socket://11.12.13.14:9100 \
1973   -i /path/to/interface-script</userinput>
1974 </screen></para>
1976 <para>
1977 Interface scripts might be the "unknown animal" to many.  However,
1978 with CUPS they provide the most easy way to plug in your own
1979 custom-written filtering script or program into one specific print
1980 queue (some information about the traditional usage of interface scripts is
1981 to be found at <ulink
1982         noescape="1" url="http://playground.sun.com/printing/documentation/interface.html">http://playground.sun.com/printing/documentation/interface.html</ulink>).
1983 </para>
1984 </sect2>
1985 </sect1>
1987 <sect1>
1988 <title>Network printing (purely Windows)</title>
1990 <para>
1991 Network printing covers a lot of ground. To understand what exactly
1992 goes on with Samba when it is printing on behalf of its Windows
1993 clients, let's first look at a "purely Windows" setup: Windows clients
1994 with a Windows NT print server.
1995 </para>
1997 <sect2>
1998 <title>From Windows Clients to an NT Print Server</title>
2000 <para>
2001 Windows clients printing to an NT-based print server have two
2002 options. They may
2003 </para>
2005 <indexterm><primary>GDI</primary></indexterm>
2006 <indexterm><primary>EMF</primary></indexterm>
2008 <itemizedlist>
2009 <listitem><para>execute the driver locally and render the GDI output
2010 (EMF) into the printer specific format on their own,
2011 or</para></listitem>
2013 <listitem><para>send the GDI output (EMF) to the server, where the
2014 driver is executed to render the printer specific
2015 output.</para></listitem>
2016 </itemizedlist>
2018 <para>
2019 Both print paths are shown in the flowcharts below.
2020 </para>
2021 </sect2>
2023 <sect2>
2024 <title>Driver Execution on the Client</title>
2026 <para>
2027 In the first case the print server must spool the file as "raw",
2028 meaning it shouldn't touch the jobfile and try to convert it in any
2029 way. This is what traditional UNIX-based print server can do too; and
2030 at a better performance and more reliably than NT print server. This
2031 is what most Samba administrators probably are familiar with. One
2032 advantage of this setup is that this "spooling-only" print server may
2033 be used even if no driver(s) for UNIX are available it is sufficient
2034 to have the Windows client drivers available and installed on the
2035 clients.
2036 </para>
2038 <para>
2039         <image id="small11"><imagedescription>Print Driver execution on the Client</imagedescription>
2040                 <imagefile>11small</imagefile>
2041         </image>
2042 </para>
2043 </sect2>
2045 <sect2>
2046 <title>Driver Execution on the Server</title>
2048 <indexterm><primary>PostScript</primary></indexterm>
2049 <indexterm><primary>PCL</primary></indexterm>
2050 <indexterm><primary>ESC/P</primary></indexterm>
2051 <indexterm><primary>EMF</primary></indexterm>
2052 <indexterm><primary>GDI</primary></indexterm>
2054 <para>
2055 The other path executes the printer driver on the server. The clients
2056 transfers print files in EMF format to the server. The server uses the
2057 PostScript, PCL, ESC/P or other driver to convert the EMF file into
2058 the printer-specific language. It is not possible for UNIX to do the
2059 same. Currently there is no program or method to convert a Windows
2060 client's GDI output on a UNIX server into something a printer could
2061 understand.
2062 </para>
2064 <para>
2065         <image id="small12"><imagedescription>Print Driver execution on the Server</imagedescription>
2066                 <imagefile>12small</imagefile>
2067         </image>
2068 </para>
2070 <para>
2071 However, there is something similar possible with CUPS. Read on...
2072 </para>
2073 </sect2>
2074 </sect1>
2076 <sect1>
2077 <title>Network Printing (Windows clients -- UNIX/Samba Print
2078 Servers)</title>
2080 <para>
2081 Since UNIX print servers <emphasis>cannot</emphasis> execute the Win32
2082 program code on their platform, the picture is somewhat
2083 different. However, this doesn't limit your options all that
2084 much. In the contrary, you may have a way here to implement printing
2085 features which are not possible otherwise.
2086 </para>
2088 <sect2>
2089 <title>From Windows Clients to a CUPS/Samba Print Server</title>
2091 <para>
2092 Here is a simple recipe showing how you can take advantage of CUPS
2093 powerful features for the benefit of your Windows network printing
2094 clients:
2095 </para>
2097 <itemizedlist>
2099 <listitem><para>Let the Windows clients send PostScript to the CUPS
2100 server.</para></listitem>
2102 <listitem><para>Let the CUPS server render the PostScript into device
2103 specific raster format.</para></listitem>
2104 </itemizedlist>
2106 <para>
2107 This requires the clients to use a PostScript driver (even if the
2108 printer is a non-PostScript model. It also requires that you have a
2109 "driver" on the CUPS server.
2110 </para>
2112 <para>
2113 Firstly, to enable CUPS based printing through Samba the
2114 following options should be set in your &smb.conf; file [global]
2115 section:
2116 </para>
2118 <itemizedlist>
2119 <listitem><para><smbconfoption><name>printing</name><value>cups</value></smbconfoption></para></listitem>
2121 <listitem><para><smbconfoption><name>printcap</name><value>cups</value></smbconfoption></para></listitem>
2122 </itemizedlist>
2124 <para>
2125 When these parameters are specified, all manually set print directives
2126 (like <smbconfoption><name>print command</name></smbconfoption>, or <smbconfoption><name>lppause command</name></smbconfoption>) in &smb.conf; (as well as
2127 in samba itself) will be ignored. Instead, Samba will directly
2128 interface with CUPS through it's application program interface (API) -
2129 as long as Samba has been compiled with CUPS library (libcups)
2130 support. If Samba has NOT been compiled with CUPS support, and if no
2131 other print commands are set up, then printing will use the
2132 <emphasis>System V</emphasis> AT&amp;T command set, with the -oraw
2133 option automatically passing through (if you want your own defined
2134 print commands to work with a Samba that has CUPS support compiled in,
2135 simply use <smbconfoption><name>printing</name><value>sysv</value></smbconfoption>).
2136 </para>
2138 <para>
2139 <image id="small13"><imagedescription>Printing via CUPS/samba server</imagedescription>
2140         <imagefile>13small</imagefile>
2141 </image>
2142 </para>
2143 </sect2>
2145 <sect2>
2146 <title>Samba receiving Jobfiles and passing them to CUPS</title>
2148 <para>
2149 Samba <emphasis>must</emphasis> use its own spool directory (it is set
2150 by a line similar to <smbconfoption><name>path</name><value>/var/spool/samba</value></smbconfoption>,
2151 in the <smbconfsection>[printers]</smbconfsection> or
2152 <smbconfsection>[printername]</smbconfsection> section of
2153 &smb.conf;). Samba receives the job in its own
2154 spool space and passes it into the spool directory of CUPS (the CUPS
2155 spooling directory is set by the <parameter>RequestRoot</parameter>
2156 directive, in a line that defaults to <parameter>RequestRoot
2157 /var/spool/cups</parameter>).  CUPS checks the access rights of its
2158 spool dir and resets it to healthy values with every re-start. We have
2159 seen quite some people who had used a common spooling space for Samba
2160 and CUPS, and were struggling for weeks with this "problem".
2161 </para>
2163 <para>
2164 A Windows user authenticates only to Samba (by whatever means is
2165 configured). If Samba runs on the same host as CUPS, you only need to
2166 allow "localhost" to print. If they run on different machines, you
2167 need to make sure the Samba host gets access to printing on CUPS.
2168 </para>
2169 </sect2>
2170 </sect1>
2172 <sect1>
2173 <title>Network PostScript RIP: CUPS Filters on Server -- clients use
2174 PostScript Driver with CUPS-PPDs</title>
2176 <indexterm><primary>PostScript</primary></indexterm>
2177 <indexterm><primary>PCL</primary></indexterm>
2178 <indexterm><primary>PJL</primary></indexterm>
2180 <para>
2181 PPDs can control all print device options. They are usually provided
2182 by the manufacturer; if you own a PostScript printer, that is. PPD
2183 files (PostScript Printer Descriptions) are always a component of
2184 PostScript printer drivers on MS Windows or Apple Mac OS systems. They
2185 are ASCII files containing user-selectable print options, mapped to
2186 appropriate PostScript, PCL or PJL commands for the target
2187 printer. Printer driver GUI dialogs translate these options
2188 "on-the-fly" into buttons and drop-down lists for the user to select.
2189 </para>
2191 <para>
2192 CUPS can load, without any conversions, the PPD file from any Windows
2193 (NT is recommended) PostScript driver and handle the options. There is
2194 a web browser interface to the print options (select <ulink
2195 noescape="1" url="http://localhost:631/printers/">http://localhost:631/printers/</ulink>
2196 and click on one <emphasis>Configure Printer</emphasis> button to see
2197 it), or a commandline interface (see <command>man lpoptions</command>
2198 or see if you have lphelp on your system). There are also some
2199 different GUI frontends on Linux/UNIX, which can present PPD options
2200 to users. PPD options are normally meant to be evaluated by the
2201 PostScript RIP on the real PostScript printer.
2202 </para>
2204 <sect2>
2205 <title>PPDs for non-PS Printers on UNIX</title>
2207 <indexterm><primary>PPD</primary></indexterm>
2209 <para>
2210 CUPS doesn't limit itself to "real" PostScript printers in its usage
2211 of PPDs. The CUPS developers have extended the scope of the PPD
2212 concept, to also describe available device and driver options for
2213 non-PostScript printers through CUPS-PPDs.
2214 </para>
2216 <para>
2217 This is logical, as CUPS includes a fully featured PostScript
2218 interpreter (RIP). This RIP is based on Ghostscript. It can process
2219 all received PostScript (and additionally many other file formats)
2220 from clients. All CUPS-PPDs geared to non-PostScript printers contain
2221 an additional line, starting with the keyword
2222 <parameter>*cupsFilter</parameter> . This line tells the CUPS print
2223 system which printer-specific filter to use for the interpretation of
2224 the supplied PostScript. Thus CUPS lets all its printers appear as
2225 PostScript devices to its clients, because it can act as a PostScript
2226 RIP for those printers, processing the received PostScript code into a
2227 proper raster print format.
2228 </para>
2229 </sect2>
2231 <sect2>
2232 <title>PPDs for non-PS Printers on Windows</title>
2234 <indexterm><primary>PPD</primary></indexterm>
2235 <para>
2236 CUPS-PPDs can also be used on Windows-Clients, on top of a
2237 "core" PostScript driver (now recommended is the "CUPS PostScript
2238 Driver for WindowsNT/2K/XP"; you can also use the Adobe one, with
2239 limitations). This feature enables CUPS to do a few tricks no other
2240 spooler can do:
2241 </para>
2243 <itemizedlist>
2245 <listitem><para>act as a networked PostScript RIP (Raster Image
2246 Processor), handling printfiles from all client platforms in a uniform
2247 way;</para></listitem>
2249 <listitem><para>act as a central accounting and billing server, since
2250 all files are passed through the pstops filter and are therefore
2251 logged in the CUPS <filename>page_log</filename> file.
2252 <emphasis>NOTE:</emphasis> this can not happen with "raw" print jobs,
2253 which always remain unfiltered per definition;</para></listitem>
2255 <listitem><para>enable clients to consolidate on a single PostScript
2256 driver, even for many different target printers.</para></listitem>
2257 </itemizedlist>
2259 <para>
2260 Using CUPS PPDs on Windows clients enables these to control
2261 all print job settings just as a UNIX client can do too.
2262 </para>
2263 </sect2>
2264 </sect1>
2266 <sect1>
2267 <title>Windows Terminal Servers (WTS) as CUPS Clients</title>
2269 <para>
2270 This setup may be of special interest to people experiencing major
2271 problems in WTS environments. WTS need often a multitude of
2272 non-PostScript drivers installed to run their clients' variety of
2273 different printer models. This often imposes the price of much
2274 increased instability.
2275 </para>
2277 <sect2>
2278 <title>Printer Drivers running in "Kernel Mode" cause many
2279 Problems</title>
2281 <para>
2282 The reason is that in Win NT printer drivers run in "Kernel
2283 Mode", this introduces a high risk for the stability of the system
2284 if the driver is not really stable and well-tested. And there are a
2285 lot of bad drivers out there! Especially notorious is the example
2286 of the PCL printer driver that had an additional sound module
2287 running, to notify users via soundcard of their finished jobs. Do I
2288 need to say that this one was also reliably causing "Blue Screens
2289 of Death" on a regular basis?
2290 </para>
2292 <para>
2293 PostScript drivers generally are very well tested. They are not known
2294 to cause any problems, even though they run in Kernel Mode too. This
2295 might be because there have so far only been 2 different PostScript
2296 drivers: the ones from Adobe and the one from Microsoft. Both are
2297 very well tested and are as stable as you ever can imagine on
2298 Windows. The CUPS driver is derived from the Microsoft one.
2299 </para>
2300 </sect2>
2302 <sect2>
2303 <title>Workarounds impose Heavy Limitations</title>
2305 <para>
2306 In many cases, in an attempt to work around this problem, site
2307 administrators have resorted to restrict the allowed drivers installed
2308 on their WTS to one generic PCL- and one PostScript driver. This
2309 however restricts the clients in the amount of printer options
2310 available for them; often they can't get out more than simplex
2311 prints from one standard paper tray, while their devices could do much
2312 better, if driven by a different driver! )
2313 </para>
2314 </sect2>
2316 <sect2>
2317 <title>CUPS: a "Magical Stone"?</title>
2319 <indexterm><primary>PPD</primary></indexterm>
2320 <indexterm><primary>PostScript</primary></indexterm>
2322 <para>
2323 Using a PostScript driver, enabled with a CUPS-PPD, seems to be a very
2324 elegant way to overcome all these shortcomings. There are, depending
2325 on the version of Windows OS you use, up to 3 different PostScript
2326 drivers available: Adobe, Microsoft and CUPS PostScript drivers. None
2327 of them is known to cause major stability problems on WTS (even if
2328 used with many different PPDs). The clients will be able to (again)
2329 chose paper trays, duplex printing and other settings. However, there
2330 is a certain price for this too: a CUPS server acting as a PostScript
2331 RIP for its clients requires more CPU and RAM than when just acting as
2332 a "raw spooling" device.  Plus, this setup is not yet widely tested,
2333 although the first feedbacks look very promising.
2334 </para>
2335 </sect2>
2337 <sect2>
2338 <title>PostScript Drivers with no major problems -- even in Kernel
2339 Mode</title>
2341 <indexterm><primary>DDK</primary></indexterm>
2342 <para>
2343 More recent printer drivers on W2K and XP don't run in Kernel mode
2344 (unlike Win NT) any more. However, both operating systems can still
2345 use the NT drivers, running in Kernel mode (you can roughly tell which
2346 is which as the drivers in subdirectory "2" of "W32X86" are "old"
2347 ones).  As was said before, the Adobe as well as the Microsoft
2348 PostScript drivers are not known to cause any stability problems. The
2349 CUPS driver is derived from the Microsoft one. There is a simple
2350 reason for this: The MS DDK (Device Development Kit) for Win NT (which
2351 used to be available at no cost to licensees of Visual Studio)
2352 includes the source code of the Microsoft driver, and licensees of
2353 Visual Studio are allowed to use and modify it for their own driver
2354 development efforts. This is what the CUPS people have done. The
2355 license doesn't allow them to publish the whole of the source code.
2356 However, they have released the "diff" under the GPL, and if you are
2357 owner of an "MS DDK for Win NT", you can check the driver yourself.
2358 </para>
2359 </sect2>
2360 </sect1>
2362 <sect1>
2363 <title>Setting up CUPS for driver Download</title>
2365 <para>
2366 As we have said before: all previously known methods to prepare client
2367 printer drivers on the Samba server for download and "Point'n'Print"
2368 convenience of Windows workstations are working with CUPS too. These
2369 methods were described in the previous chapter. In reality, this is a
2370 pure Samba business, and only relates to the Samba/Win client
2371 relationship.
2372 </para>
2374 <sect2>
2375 <title><emphasis>cupsaddsmb</emphasis>: the unknown Utility</title>
2377 <indexterm><primary>cupsaddsmb</primary></indexterm>
2379 <para>
2380 The cupsaddsmb utility (shipped with all current CUPS versions) is an
2381 alternative method to transfer printer drivers into the Samba
2382 <smbconfsection>[print$]</smbconfsection> share. Remember, this share is where
2383 clients expect drivers deposited and setup for download and
2384 installation.  It makes the sharing of any (or all) installed CUPS
2385 printers very easy. cupsaddsmb can use the Adobe PostScript driver as
2386 well as the newly developed <emphasis>CUPS PostScript Driver for
2387 WinNT/2K/XP</emphasis>. Note, that cupsaddsmb does
2388 <emphasis>not</emphasis> work with arbitrary vendor printer drivers,
2389 but only with the <emphasis>exact</emphasis> driver files that are
2390 named in its man page.
2391 </para>
2393 <para>
2394 The CUPS printer driver is available from the CUPS download site. Its
2395 package name is <filename>cups-samba-[version].tar.gz</filename> . It
2396 is preferred over the Adobe drivers since it has a number of
2397 advantages:
2398 </para>
2400 <itemizedlist>
2401 <listitem><para>it supports a much more accurate page
2402 accounting;</para></listitem>
2404 <listitem><para>it supports banner pages, and page labels on all
2405 printers;</para></listitem>
2407 <listitem><para>it supports the setting of a number of job IPP
2408 attributes (such as job-priority, page-label and
2409 job-billing)</para></listitem>
2410 </itemizedlist>
2412 <para>
2413 However, currently only Windows NT, 2000, and XP are supported by the
2414 CUPS drivers. You will need to get the respective part of Adobe driver
2415 too if you need to support Windows 95, 98, and ME clients.
2416 </para>
2417 </sect2>
2419 <sect2>
2420 <title>Prepare your &smb.conf; for cupsaddsmb</title>
2422 <para>
2423 Prior to running cupsaddsmb, you need the following settings in
2424 &smb.conf;:
2425 </para>
2427 <para><smbconfexample>
2428                 <title>smb.conf for cupsaddsmb usage</title>
2429 <smbconfsection>[global]</smbconfsection>
2430 <smbconfoption><name>load printers</name><value>yes</value></smbconfoption>
2431 <smbconfoption><name>printing</name><value>cups</value></smbconfoption>
2432 <smbconfoption><name>printcap name</name><value>cups</value></smbconfoption>
2434 <smbconfsection>[printers]</smbconfsection>
2435 <smbconfoption><name>comment</name><value>All Printers</value></smbconfoption>
2436 <smbconfoption><name>path</name><value>/var/spool/samba</value></smbconfoption>
2437 <smbconfoption><name>browseable</name><value>no</value></smbconfoption>
2438 <smbconfoption><name>public</name><value>yes</value></smbconfoption>
2439 <smbconfcomment>setting depends on your requirements</smbconfcomment>
2440 <smbconfoption><name>guest ok</name><value>yes</value></smbconfoption>
2441 <smbconfoption><name>writable</name><value>no</value></smbconfoption>
2442 <smbconfoption><name>printable</name><value>yes</value></smbconfoption>
2443 <smbconfoption><name>printer admin</name><value>root</value></smbconfoption>
2444  <smbconfsection>[print$]</smbconfsection>
2445 <smbconfoption><name>comment</name><value>Printer Drivers</value></smbconfoption>
2446 <smbconfoption><name>path</name><value>/etc/samba/drivers</value></smbconfoption>
2447 <smbconfoption><name>browseable</name><value>yes</value></smbconfoption>
2448 <smbconfoption><name>guest ok</name><value>no</value></smbconfoption>
2449 <smbconfoption><name>read only</name><value>yes</value></smbconfoption>
2450 <smbconfoption><name>write list</name><value>root</value></smbconfoption>
2451 </smbconfexample></para>
2452 </sect2>
2454 <sect2>
2455 <title>CUPS Package of "PostScript Driver for WinNT/2k/XP"</title>
2456 <indexterm><primary>PostScript</primary></indexterm>
2458 <para>
2459 CUPS users may get the exactly same packages from <ulink
2460 noescape="1" url="http://www.cups.org/software.html">http://www.cups.org/software.html</ulink>.
2461 It is a separate package from the CUPS base software files, tagged as
2462 <emphasis>CUPS 1.1.x Windows NT/2k/XP Printer Driver for Samba
2463 (tar.gz, 192k)</emphasis>. The filename to download is
2464 <filename>cups-samba-1.1.x.tar.gz</filename>. Upon untar-/unzip-ing,
2465 it will reveal these files:
2466 </para>
2468 <para><screen>
2469 &rootprompt;<userinput>tar xvzf cups-samba-1.1.19.tar.gz</userinput>
2470 cups-samba.install
2471 cups-samba.license
2472 cups-samba.readme
2473 cups-samba.remove
2474 cups-samba.ss
2475 </screen></para>
2477 <para>
2478 <indexterm><primary>ESP</primary><secondary>meta packager</secondary></indexterm>
2479 <indexterm><primary>EPM</primary><see>ESP meta packager</see></indexterm>
2480 These have been packaged with the ESP meta packager software
2481 "EPM". The <filename>*.install</filename> and
2482 <filename>*.remove</filename> files are simple shell scripts, which
2483 untars the <filename>*.ss</filename> (the <filename>*.ss</filename> is
2484 nothing else but a tar-archive, which can be untar-ed by "tar"
2485 too). Then it puts the content into
2486 <filename>/usr/share/cups/drivers/</filename>. This content includes 3
2487 files:
2488 </para>
2490 <para><screen>
2491 &rootprompt;<userinput>tar tv cups-samba.ss</userinput>
2492 cupsdrvr.dll
2493 cupsui.dll
2494 cups.hlp  
2495 </screen></para>
2497 <para>
2498 The <emphasis>cups-samba.install</emphasis> shell scripts is easy to
2499 handle:
2500 </para>
2502 <para><screen>
2503 &rootprompt;<userinput>./cups-samba.install</userinput>
2504 [....]
2505 Installing software...
2506 Updating file permissions...
2507 Running post-install commands...
2508 Installation is complete.        
2509 </screen></para>
2511 <para>
2512 The script should automatically put the driver files into the
2513 <filename>/usr/share/cups/drivers/</filename> directory.
2514 </para>
2516 <warning><para>
2517 Due to a bug, one recent CUPS release puts the
2518 <filename>cups.hlp</filename> driver file
2519 into<filename>/usr/share/drivers/</filename> instead of
2520 <filename>/usr/share/cups/drivers/</filename>. To work around this,
2521 copy/move the file (after running the
2522 <command>./cups-samba.install</command> script) manually to the
2523 right place.
2524 </para></warning>
2526 <para><screen>
2527 &rootprompt;<userinput>cp /usr/share/drivers/cups.hlp /usr/share/cups/drivers/</userinput>
2528 </screen></para>
2530 <indexterm><primary>DDK</primary></indexterm>
2532 <para>
2533 This new CUPS PostScript driver is currently binary-only, but free of
2534 charge. No complete source code is provided (yet). The reason is this:
2535 it has been developed with the help of the <emphasis>Microsoft Driver
2536 Developer Kit</emphasis> (DDK) and compiled with Microsoft Visual
2537 Studio 6. Driver developers are not allowed to distribute the whole of
2538 the source code as Free Software. However, CUPS developers released
2539 the "diff" in source code under the GPL, so anybody with a license of
2540 Visual Studio and a DDK will be able to compile for him/herself.
2541 </para>
2542 </sect2>
2544 <sect2>
2545 <title>Recognize the different Driver Files</title>
2547 <para>
2548 The CUPS drivers don't support the "older" Windows 95/98/ME, but only
2549 the Windows NT/2000/XP client:
2550 </para>
2552 <para>Windows NT, 2000, and XP are supported by:</para>
2554 <para>
2555         <itemizedlist>
2556                 <listitem><para>cups.hlp</para></listitem>
2557                 <listitem><para>cupsdrvr.dll</para></listitem>
2558                 <listitem><para>cupsui.dll</para></listitem>
2559         </itemizedlist>
2560 </para>
2562 <para>
2563 Adobe drivers are available for the older Windows 95/98/ME as well as
2564 the Windows NT/2000/XP clients. The set of files is different for the
2565 different platforms.
2566 </para>
2568 <para>Windows 95, 98, and Me are supported by:</para>
2570 <para>
2571         <itemizedlist>
2572         <listitem><para>ADFONTS.MFM</para></listitem>
2573         <listitem><para>ADOBEPS4.DRV</para></listitem>
2574         <listitem><para>ADOBEPS4.HLP</para></listitem>
2575         <listitem><para>DEFPRTR2.PPD</para></listitem>
2576         <listitem><para>ICONLIB.DLL</para></listitem>
2577         <listitem><para>PSMON.DLL</para></listitem>
2578 </itemizedlist>
2579 </para>
2581 <para>Windows NT, 2000, and XP are supported by:</para>
2583 <para>
2584 <itemizedlist>
2585         <listitem><para>ADOBEPS5.DLL</para></listitem>
2586         <listitem><para>ADOBEPSU.DLL</para></listitem>
2587         <listitem><para>ADOBEPSU.HLP</para></listitem>
2588 </itemizedlist>
2590 </para>
2592 <note><para>
2593 If both, the Adobe driver files and the CUPS driver files for the
2594 support of WinNT/2k/XP are present in , the Adobe ones will be ignored
2595 and the CUPS ones will be used. If you prefer -- for whatever reason
2596 -- to use Adobe-only drivers, move away the 3 CUPS driver files. The
2597 Win95/98/ME clients use the Adobe drivers in any case.
2598 </para></note>
2599 </sect2>
2601 <sect2>
2602 <title>Acquiring the Adobe Driver Files</title>
2604 <para>
2605 Acquiring the Adobe driver files seems to be unexpectedly difficult
2606 for many users. They are not available on the Adobe website as single
2607 files and the self-extracting and/or self-installing Windows-exe is
2608 not easy to locate either. Probably you need to use the included
2609 native installer and run the installation process on one client
2610 once. This will install the drivers (and one Generic PostScript
2611 printer) locally on the client.  When they are installed, share the
2612 Generic PostScript printer.  After this, the client's
2613 <smbconfsection>[print$]</smbconfsection> share holds the Adobe files, from
2614 where you can get them with smbclient from the CUPS host. A more
2615 detailed description about this is in the next (the CUPS printing)
2616 chapter.
2617 </para>
2618 </sect2>
2620 <sect2>
2621 <title>ESP Print Pro Package of "PostScript Driver for
2622 WinNT/2k/XP"</title>
2625 <indexterm><primary>ESP</primary><secondary>Print Pro</secondary></indexterm>
2627 <para>
2628 Users of the ESP Print Pro software are able to install their "Samba
2629 Drivers" package for this purpose with no problem. Retrieve the driver
2630 files from the normal download area of the ESP Print Pro software
2631 at <ulink
2632         noescape="1" url="http://www.easysw.com/software.html">http://www.easysw.com/software.html</ulink>.
2633 You need to locate the link labelled "SAMBA" amongst the
2634 <emphasis>Download Printer Drivers for ESP Print Pro 4.x</emphasis>
2635 area and download the package. Once installed, you can prepare any
2636 driver by simply highlighting the printer in the Printer Manager GUI
2637 and select <emphasis>Export Driver...</emphasis> from the menu. Of
2638 course you need to have prepared Samba beforehand too to handle the
2639 driver files; i.e.  mainly setup the <smbconfsection>[print$]</smbconfsection>
2640 share, etc. The ESP Print Pro package includes the CUPS driver files
2641 as well as a (licensed) set of Adobe drivers for the Windows 95/98/ME
2642 client family.
2643 </para>
2644 </sect2>
2646 <sect2>
2647 <title>Caveats to be considered</title>
2649 <indexterm><primary>cupsaddsmb</primary></indexterm>
2651 <para>
2652 Once you have run the install script (and possibly manually
2653 moved the <filename>cups.hlp</filename> file to
2654 <filename>/usr/share/cups/drivers/</filename>), the driver is
2655 ready to be put into Samba's <smbconfsection>[print$]</smbconfsection> share (which often maps to
2656 <filename>/etc/samba/drivers/</filename> and contains a subdir
2657 tree with <emphasis>WIN40</emphasis> and
2658 <emphasis>W32X86</emphasis> branches): You do this by running
2659 "cupsaddsmb" (see also <command>man cupsaddsmb</command> for
2660 CUPS since release 1.1.16).
2661 </para>
2663 <tip><para>
2664 <indexterm><primary>Single Sign On</primary></indexterm>
2665 You may need to put root into the smbpasswd file by running
2666 <command>smbpasswd</command>; this is especially important if you
2667 should run this whole procedure for the first time, and are not
2668 working in an environment where everything is configured for
2669 <emphasis>Single Sign On</emphasis> to a Windows Domain Controller.
2670 </para></tip>
2672 <para>
2673 Once the driver files are in the <smbconfsection>[print$]</smbconfsection> share
2674 and are initialized, they are ready to be downloaded and installed by
2675 the Win NT/2k/XP clients.
2676 </para>
2678 <note><para>
2679 <orderedlist>
2680 <listitem><para>
2681 Win 9x/ME clients won't work with the CUPS PostScript driver. For
2682 these you'd still need to use the <filename>ADOBE*.*</filename>
2683 drivers as previously.
2684 </para></listitem>
2686 <listitem><para>
2687 It is not harmful if you still have the
2688 <filename>ADOBE*.*</filename> driver files from previous
2689 installations in the <filename>/usr/share/cups/drivers/</filename>
2690 directory. The new <emphasis>cupsaddsmb</emphasis> (from 1.1.16) will
2691 automatically prefer "its own" drivers if it finds both.
2692 </para></listitem>
2694 <listitem><para>
2695 <indexterm><primary>"Printers" folder</primary></indexterm>
2696 Should your Win clients have had the old <filename>ADOBE*.*</filename>
2697 files for the Adobe PostScript driver installed, the download and
2698 installation of the new CUPS PostScript driver for Windows NT/2k/XP
2699 will fail at first. You need to wipe the old driver from the clients
2700 first. It is not enough to "delete" the printer, as the driver files
2701 will still be kept by the clients and re-used if you try to re-install
2702 the printer. To really get rid of the Adobe driver files on the
2703 clients, open the "Printers" folder (possibly via <emphasis>Start, Settings, Control Panel, Printers</emphasis>),
2704 right-click onto the folder background and select <emphasis>Server
2705 Properties</emphasis>. When the new dialog opens, select the
2706 <emphasis>Drivers</emphasis> tab. On the list select the driver you
2707 want to delete and click on the <emphasis>Delete</emphasis>
2708 button. This will only work if there is not one single printer left
2709 which uses that particular driver. You need to "delete" all printers
2710 using this driver in the "Printers" folder first. You will need
2711 Administrator privileges to do this.
2712 </para></listitem>
2714 <listitem><para>
2715 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
2716 Once you have successfully downloaded the CUPS PostScript driver to a
2717 client, you can easily switch all printers to this one by proceeding
2718 as described in <link linkend="printing">the printing chapter</link>: either change
2719 a driver for an existing printer by running the "Printer Properties"
2720 dialog, or use <command>rpcclient</command> with the
2721 <command>setdriver</command> sub-command.
2722 </para></listitem>
2723 </orderedlist>
2724 </para></note>
2725 </sect2>
2727 <sect2>
2728 <title>Benefits of using "CUPS PostScript Driver for
2729 Windows NT/2k/XP" instead of Adobe Driver</title>
2731 <para>
2732 You are interested in a comparison between the CUPS and the Adobe
2733 PostScript drivers? For our purposes these are the most important
2734 items which weigh in favor of the CUPS ones:
2735 </para>
2737 <itemizedlist>
2738 <listitem><para>no hassle with the Adobe EULA</para></listitem>
2740 <listitem><para>no hassle with the question <quote>Where do I
2741 get the ADOBE*.* driver files from?</quote></para></listitem>
2743 <listitem><para>
2744 <indexterm><primary>PJL</primary></indexterm>
2745                 the Adobe drivers (on request of the printer PPD
2746 associated with them) often put a PJL header in front of the main
2747 PostScript part of the print file. Thus the printfile starts with
2748 <parameter>&lt;1B &gt;%-12345X</parameter> or
2749 <parameter>&lt;escape&gt;%-12345X</parameter> instead
2750 of <parameter>%!PS</parameter>). This leads to the
2751 CUPS daemon auto-typing the incoming file as a print-ready file,
2752 not initiating a pass through the "pstops" filter (to speak more
2753 technically, it is not regarded as the generic MIME type 
2754 <indexterm><primary>application/postscript</primary></indexterm>
2755 <emphasis>application/postscript</emphasis>, but as
2756 the more special MIME type
2757 <indexterm><primary>application/cups.vnd-postscript</primary></indexterm>
2758 <emphasis>application/cups.vnd-postscript</emphasis>),
2759 which therefore also leads to the page accounting in
2760 <emphasis>/var/log/cups/page_log</emphasis> not
2761 receiving the exact number of pages; instead the dummy page number
2762 of "1" is logged in a standard setup)</para></listitem>
2764 <listitem><para>the Adobe driver has more options to "mis-configure" the
2765 PostScript generated by it (like setting it inadvertently to
2766 <emphasis>Optimize for Speed</emphasis>, instead of
2767 <emphasis>Optimize for Portability</emphasis>, which
2768 could lead to CUPS being unable to process it)</para></listitem>
2770 <listitem><para>the CUPS PostScript driver output sent by Windows
2771 clients to the CUPS server will be guaranteed to be auto-typed always
2772 as generic MIME type <emphasis>application/postscript</emphasis>,
2773 thusly passing through the CUPS "pstops" filter and logging the
2774 correct number of pages in the <filename>page_log</filename> for
2775 accounting and quota purposes</para></listitem>
2777 <listitem><para>the CUPS PostScript driver supports the sending of
2778 additional standard (IPP) print options by Win NT/2k/XP clients.  Such
2779 additional print options are: naming the CUPS standard
2780 <emphasis>banner pages</emphasis> (or the custom ones, should they be
2781 installed at the time of driver download), using the CUPS
2782 <emphasis>page-label</emphasis> option, setting a
2783 <emphasis>job-priority</emphasis> and setting the <emphasis>scheduled
2784 time of printing</emphasis> (with the option to support additional
2785 useful IPP job attributes in the future).</para></listitem>
2787 <listitem><para>the CUPS PostScript driver supports the inclusion of
2788 the new <emphasis>*cupsJobTicket</emphasis> comments at the
2789 beginning of the PostScript file (which could be used in the future
2790 for all sort of beneficial extensions on the CUPS side, but which will
2791 not disturb any other applications as they will regard it as a comment
2792 and simply ignore it).</para></listitem>
2794 <listitem><para>the CUPS PostScript driver will be the heart of the
2795 fully fledged CUPS IPP client for Windows NT/2K/XP to be released soon
2796 (probably alongside the first Beta release for CUPS
2797 1.2).</para></listitem>
2798 </itemizedlist>
2800 </sect2>
2802 <sect2>
2803 <title>Run "cupsaddsmb" (quiet Mode)</title>
2805 <indexterm><primary>cupsaddsmb</primary></indexterm>
2806 <indexterm><primary>point and print</primary></indexterm>
2808 <para>
2809 The cupsaddsmb command copies the needed files into your
2810 <smbconfsection>[print$]</smbconfsection> share. Additionally, the PPD
2811 associated with this printer is copied from
2812 <filename>/etc/cups/ppd/</filename> to
2813 <smbconfsection>[print$]</smbconfsection>. There the files wait for convenient
2814 Windows client installations via Point'n'Print. Before we can run the
2815 command successfully, we need to be sure that we can authenticate
2816 towards Samba. If you have a small network you are probably using user
2817 level security (<smbconfoption><name>security</name><value>user</value></smbconfoption>). 
2818 </para>
2820 <para>
2821 Here is an example of a successfully run cupsaddsmb command. 
2822 </para>
2824 <para><screen>
2825 &rootprompt;<userinput>cupsaddsmb -U root infotec_IS2027</userinput>
2826 Password for root required to access localhost via Samba: <userinput>['secret']</userinput>
2827 </screen></para>
2829 <para>
2830 To share <emphasis>all</emphasis> printers and drivers, use the
2831 <option>-a</option> parameter instead of a printer name. Since
2832 cupsaddsmb "exports" the printer drivers to Samba, it should be
2833 obvious that it only works for queues with a CUPS driver associated.
2834 </para>
2835 </sect2>
2837 <sect2>
2838 <title>Run "cupsaddsmb" with verbose Output</title>
2840 <indexterm><primary>cupsaddsmb</primary></indexterm>
2842 <para>
2843 Probably you want to see what's going on. Use the
2844 <option>-v</option> parameter to get a more verbose output. The
2845 output below was edited for better readability: all "\" at the end of
2846 a line indicate that I inserted an artificial line break plus some
2847 indentation here:
2848 </para>
2850 <warning><para>
2851 You will see the root password for the Samba account printed on
2852 screen. 
2853 </para></warning>
2855 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
2856 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
2857 <para><screen>
2858 &rootprompt;<userinput>cupsaddsmb -U root -v infotec_2105</userinput>
2859 Password for root required to access localhost via &example.server.samba;:
2860 Running command: smbclient //localhost/print\$ -N -U'root%secret' \
2861     -c 'mkdir W32X86; \
2862     put /var/spool/cups/tmp/3e98bf2d333b5 W32X86/infotec_2105.ppd; \
2863         put /usr/share/cups/drivers/cupsdrvr.dll W32X86/cupsdrvr.dll; \
2864     put /usr/share/cups/drivers/cupsui.dll W32X86/cupsui.dll; \
2865     put /usr/share/cups/drivers/cups.hlp W32X86/cups.hlp'
2866 added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
2867 Domain=[CUPS-PRINT] OS=[UNIX] Server=[Samba 2.2.7a]
2868 NT_STATUS_OBJECT_NAME_COLLISION making remote directory \W32X86
2869 putting file /var/spool/cups/tmp/3e98bf2d333b5 as \W32X86/infotec_2105.ppd
2870 putting file /usr/share/cups/drivers/cupsdrvr.dll as \W32X86/cupsdrvr.dll
2871 putting file /usr/share/cups/drivers/cupsui.dll as \W32X86/cupsui.dll
2872 putting file /usr/share/cups/drivers/cups.hlp as \W32X86/cups.hlp
2873   
2874 Running command: rpcclient localhost -N -U'root%secret' 
2875    -c 'adddriver "Windows NT x86"   \
2876    "infotec_2105:cupsdrvr.dll:infotec_2105.ppd:cupsui.dll:cups.hlp:NULL:   \
2877     RAW:NULL"'
2878 cmd = adddriver "Windows NT x86" \
2879     "infotec_2105:cupsdrvr.dll:infotec_2105.ppd:cupsui.dll:cups.hlp:NULL:RAW:NULL"
2880 Printer Driver infotec_2105 successfully installed.
2881   
2882 Running command: smbclient //localhost/print\$ -N -U'root%secret' \
2883 -c 'mkdir WIN40; \
2884     put /var/spool/cups/tmp/3e98bf2d333b5 WIN40/infotec_2105.PPD; \
2885         put /usr/share/cups/drivers/ADFONTS.MFM WIN40/ADFONTS.MFM;   \
2886     put /usr/share/cups/drivers/ADOBEPS4.DRV WIN40/ADOBEPS4.DRV; \
2887     put /usr/share/cups/drivers/ADOBEPS4.HLP WIN40/ADOBEPS4.HLP; \
2888     put /usr/share/cups/drivers/DEFPRTR2.PPD WIN40/DEFPRTR2.PPD; \
2889         put /usr/share/cups/drivers/ICONLIB.DLL WIN40/ICONLIB.DLL; \
2890         put /usr/share/cups/drivers/PSMON.DLL WIN40/PSMON.DLL;'
2891   added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
2892   Domain=[CUPS-PRINT] OS=[UNIX] Server=[Samba 2.2.7a]
2893   NT_STATUS_OBJECT_NAME_COLLISION making remote directory \WIN40
2894   putting file /var/spool/cups/tmp/3e98bf2d333b5 as \WIN40/infotec_2105.PPD
2895   putting file /usr/share/cups/drivers/ADFONTS.MFM as \WIN40/ADFONTS.MFM
2896   putting file /usr/share/cups/drivers/ADOBEPS4.DRV as \WIN40/ADOBEPS4.DRV
2897   putting file /usr/share/cups/drivers/ADOBEPS4.HLP as \WIN40/ADOBEPS4.HLP
2898   putting file /usr/share/cups/drivers/DEFPRTR2.PPD as \WIN40/DEFPRTR2.PPD
2899   putting file /usr/share/cups/drivers/ICONLIB.DLL as \WIN40/ICONLIB.DLL
2900   putting file /usr/share/cups/drivers/PSMON.DLL as \WIN40/PSMON.DLL
2901   
2902   Running command: rpcclient localhost -N -U'root%secret' \
2903    -c 'adddriver "Windows 4.0"      \
2904    "infotec_2105:ADOBEPS4.DRV:infotec_2105.PPD:NULL:ADOBEPS4.HLP: \
2905    PSMON.DLL:RAW:ADOBEPS4.DRV,infotec_2105.PPD,ADOBEPS4.HLP,PSMON.DLL, \
2906     ADFONTS.MFM,DEFPRTR2.PPD,ICONLIB.DLL"'
2907   cmd = adddriver "Windows 4.0" "infotec_2105:ADOBEPS4.DRV:infotec_2105.PPD:NULL:          \
2908     ADOBEPS4.HLP:PSMON.DLL:RAW:ADOBEPS4.DRV,infotec_2105.PPD,ADOBEPS4.HLP,  \
2909                    PSMON.DLL,ADFONTS.MFM,DEFPRTR2.PPD,ICONLIB.DLL"
2910   Printer Driver infotec_2105 successfully installed.
2911   
2912   Running command: rpcclient localhost -N -U'root%secret'  \
2913    -c 'setdriver infotec_2105 infotec_2105'
2914   cmd = setdriver infotec_2105 infotec_2105
2915   Successfully set infotec_2105 to driver infotec_2105.
2917 </screen></para>
2919 <para>
2920 If you look closely, you'll discover your root password was transferred
2921 unencrypted over the wire, so beware! Also, if you look further her,
2922 you'll discover error messages like NT_STATUS_OBJECT_NAME_COLLISION in
2923 between. They occur, because the directories WIN40 and W32X86 already
2924 existed in the <smbconfsection>[print$]</smbconfsection> driver download share
2925 (from a previous driver installation). They are harmless here.
2926 </para>
2927 </sect2>
2929 <sect2>
2930 <title>Understanding cupsaddsmb</title>
2932 <indexterm><primary>cupsaddsmb</primary></indexterm>
2934 <para>
2935 What has happened? What did cupsaddsmb do? There are five stages of
2936 the procedure
2937 </para>
2939 <orderedlist>
2940         <listitem><para>
2941         <indexterm><primary>IPP</primary></indexterm>
2942                         call the CUPS server via IPP and request the
2943 driver files and the PPD file for the named printer;</para></listitem>
2945 <listitem><para>store the files temporarily in the local
2946 TEMPDIR (as defined in
2947 <filename>cupsd.conf</filename>);</para></listitem>
2949 <listitem><para>connect via smbclient to the Samba server's
2950  <smbconfsection>[print$]</smbconfsection> share and put the files into the
2951  share's WIN40 (for Win95/98/ME) and W32X86/ (for WinNT/2k/XP) sub
2952  directories;</para></listitem>
2954 <listitem><para>
2955 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
2956                 connect via rpcclient to the Samba server and
2957 execute the "adddriver" command with the correct
2958 parameters;</para></listitem>
2960 <listitem><para>
2961 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
2962                 connect via rpcclient to the Samba server a second
2963 time and execute the "setdriver" command.</para></listitem>
2964 </orderedlist>
2966 <para>
2967 Note, that you can run the cupsaddsmb utility with parameters to
2968 specify one remote host as Samba host and a second remote host as CUPS
2969 host. Especially if you want to get a deeper understanding, it is a
2970 good idea try it and see more clearly what is going on (though in real
2971 life most people will have their CUPS and Samba servers run on the
2972 same host):
2973 </para>
2975 <para><screen>
2976 &rootprompt;<userinput>cupsaddsmb -H sambaserver -h cupsserver -v printername</userinput>
2977 </screen></para>
2978 </sect2>
2980 <sect2>
2981 <title>How to recognize if cupsaddsmb completed successfully</title>
2983 <para>
2984 You <emphasis>must</emphasis> always check if the utility completed
2985 successfully in all fields. You need as a minimum these 3 messages
2986 amongst the output:
2987 </para>
2989 <orderedlist>
2991 <listitem><para><emphasis>Printer Driver infotec_2105 successfully
2992 installed.</emphasis> # (for the W32X86 == WinNT/2K/XP
2993 architecture...)</para></listitem>
2995 <listitem><para><emphasis>Printer Driver infotec_2105 successfully
2996 installed.</emphasis> # (for the WIN40 == Win9x/ME
2997 architecture...)</para></listitem>
2999 <listitem><para><emphasis>Successfully set [printerXPZ] to driver
3000 [printerXYZ].</emphasis></para></listitem>
3001 </orderedlist>
3003 <para>
3004 These messages probably not easily recognized in the general
3005 output. If you run cupsaddsmb with the <option>-a</option>
3006 parameter (which tries to prepare <emphasis>all</emphasis> active CUPS
3007 printer drivers for download), you might miss if individual printers
3008 drivers had problems to install properly. Here a redirection of the
3009 output will help you analyze the results in retrospective.
3010 </para>
3012 <note><para>
3013 It is impossible to see any diagnostic output if you don't run
3014 cupsaddsmb in verbose mode.  Therefore we strongly recommend to not
3015 use the default quiet mode.  It will hide any problems from you which
3016 might occur.
3017 </para></note>
3018 </sect2>
3020 <sect2>
3021 <title>cupsaddsmb with a Samba PDC</title>
3023 <indexterm><primary>cupsaddsmb</primary></indexterm>
3025 <para>
3026 You can't get the standard cupsaddsmb command to run on a Samba PDC?
3027 You are asked for the password credential all over again and again and
3028 the command just will not take off at all? Try one of these
3029 variations:
3030 </para>
3032 <para><screen>
3033 &rootprompt;<userinput>cupsaddsmb -U &example.workgroup;\\root -v printername</userinput>
3034 &rootprompt;<userinput>cupsaddsmb -H &example.pdc.samba; -U &example.workgroup;\\root -v printername</userinput>
3035 &rootprompt;<userinput>cupsaddsmb -H &example.pdc.samba; -U &example.workgroup;\\root -h cups-server -v printername</userinput>
3036 </screen></para>
3038 <para>
3039 (Note the two backslashes: the first one is required to
3040 "escape" the second one).
3041 </para>
3042 </sect2>
3044 <sect2>
3045 <title>cupsaddsmb Flowchart</title>
3047 <indexterm><primary>cupsaddsmb</primary></indexterm>
3048 <para>
3049 Here is a chart about the procedures, commandflows and
3050 dataflows of the "cupaddsmb" command. Note again: cupsaddsmb is
3051 not intended to, and does not work with, "raw" queues!
3052 </para>
3054 <para>
3055         <image id="small14"><imagedescription>cupsaddsmb flowchart</imagedescription>
3056                 <imagefile>14small</imagefile></image>
3057 </para>
3058 </sect2>
3060 <sect2>
3061 <title>Installing the PostScript Driver on a Client</title>
3063 <indexterm><primary>point and print</primary></indexterm>
3064 <para>
3065 After cupsaddsmb completed, your driver is prepared for the clients to
3066 use. Here are the steps you must perform to download and install it
3067 via "Point'n'Print". From a Windows client, browse to the CUPS/Samba
3068 server;
3069 </para>
3071 <itemizedlist>
3073 <indexterm><primary>"Printers" folder</primary></indexterm>
3075 <listitem><para>open the <emphasis>Printers</emphasis>
3076 share of Samba in Network Neighbourhood;</para></listitem>
3078 <listitem><para>right-click on the printer in
3079 question;</para></listitem>
3081 <listitem><para>from the opening context-menu select
3082 <emphasis>Install...</emphasis> or 
3083 <emphasis>Connect...</emphasis> (depending on the Windows version you
3084 use).</para></listitem>
3085 </itemizedlist>
3087 <para>
3088 After a few seconds, there should be a new printer in your
3089 client's <emphasis>local</emphasis> "Printers" folder: On Windows
3090 XP it will follow a naming convention of <emphasis>PrinterName on
3091 SambaServer</emphasis>. (In my current case it is "infotec_2105 on
3092 kde-bitshop"). If you want to test it and send your first job from
3093 an application like Winword, the new printer will appears in a
3094 <filename>\\SambaServer\PrinterName</filename> entry in the
3095 dropdown list of available printers.
3096 </para>
3098 <note><para>
3099 <indexterm><primary>PPD</primary></indexterm>
3100 cupsaddsmb will only reliably work with CUPS version 1.1.15 or higher
3101 and Samba from 2.2.4. If it doesn't work, or if the automatic printer
3102 driver download to the clients doesn't succeed, you can still manually
3103 install the CUPS printer PPD on top of the Adobe PostScript driver on
3104 clients. Then point the client's printer queue to the Samba printer
3105 share for a UNC type of connection:
3106 </para></note>
3108 <para><screen>
3109 &dosprompt;<userinput>net use lpt1: \\sambaserver\printershare /user:ntadmin</userinput>
3110 </screen></para>
3112 <para>
3113 should you desire to use the CUPS networked PostScript RIP
3114 functions. (Note that user "ntadmin" needs to be a valid Samba user
3115 with the required privileges to access the printershare) This would
3116 set up the printer connection in the traditional
3117 <emphasis>LanMan</emphasis> way (not using MS-RPC).
3118 </para>
3119 </sect2>
3121 <sect2>
3122 <title>Avoiding critical PostScript Driver Settings on the
3123 Client</title>
3125 <para>
3126 Soooo: printing works, but there are still problems. Most jobs print
3127 well, some don't print at all. Some jobs have problems with fonts,
3128 which don't look very good. Some jobs print fast, and some are
3129 dead-slow. Many of these problems can be greatly reduced or even
3130 completely eliminated if you follow a few guidelines. Remember, if
3131 your print device is not PostScript-enabled, you are treating your
3132 Ghostscript installation on your CUPS host with the output your client
3133 driver settings produce. Treat it well:
3134 </para>
3136 <itemizedlist>
3137 <listitem><para>Avoid the <emphasis>PostScript Output Option: Optimize
3138 for Speed</emphasis> setting. Rather use the <emphasis>Optimize for
3139 Portability</emphasis> instead (Adobe PostScript
3140 driver).</para></listitem>
3142 <listitem><para>Don't use the <emphasis>Page Independence:
3143 NO</emphasis> setting. Instead use <emphasis>Page Independence
3144 YES</emphasis> (CUPS PostScript Driver)</para></listitem>
3146 <listitem><para>Recommended is the <emphasis>True Type Font
3147 Downloading Option: Native True Type</emphasis> over
3148 <emphasis>Automatic</emphasis> and <emphasis>Outline</emphasis>; you
3149 should by all means avoid <emphasis>Bitmap</emphasis> (Adobe
3150 PostScript Driver)</para></listitem>
3152 <listitem><para>Choose <emphasis>True Type Font: Download as Softfont
3153 into Printer</emphasis> over the default <emphasis>Replace by Device
3154 Font</emphasis> (for exotic fonts you may need to change it back to
3155 get a printout at all) (Adobe)</para></listitem>
3157 <listitem><para>Sometimes you can choose <emphasis>PostScript Language
3158 Level</emphasis>: in case of problems try <emphasis>2</emphasis>
3159 instead of <emphasis>3</emphasis> (the latest ESP Ghostscript package
3160 handles Level 3 PostScript very well) (Adobe).</para></listitem>
3162 <listitem><para>Say <emphasis>Yes</emphasis> to <emphasis>PostScript
3163 Error Handler</emphasis> (Adobe)</para></listitem>
3164 </itemizedlist>
3165 </sect2>
3166 </sect1>
3168 <sect1>
3169 <title>Installing PostScript Driver Files manually (using
3170 rpcclient)</title>
3172 <para>
3173 Of course you can run all the commands which are embedded into the
3174 cupsaddsmb convenience utility yourself, one by one, and hereby upload
3175 and prepare the driver files for future client downloads.
3176 </para>
3178 <orderedlist>
3179 <listitem><para>prepare Samba (a CUPS printqueue with the name of the
3180 printer should be there. We are providing the driver
3181 now);</para></listitem>
3183 <listitem><para>copy all files to
3184                 <smbconfsection>[print$]</smbconfsection></para></listitem>
3186 <listitem><para>
3187 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3188                 run <command>rpcclient adddriver</command>
3189 (for each client architecture you want to support):</para></listitem>
3191 <listitem><para>
3192 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
3193                 run <command>rpcclient
3194 setdriver.</command></para></listitem>
3195 </orderedlist>
3197 <para>
3198 <indexterm><primary>rpcclient</primary><secondary>enumports</secondary></indexterm>
3199 <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3200 <indexterm><primary>rpcclient</primary><secondary>enumdrivers</secondary></indexterm>
3201 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
3202 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3203 We are going to do this now. First, read the man page on "rpcclient"
3204 to get a first idea. Look at all the printing related
3205 sub-commands. <command>enumprinters</command>,
3206 <command>enumdrivers</command>, <command>enumports</command>,
3207 <command>adddriver</command>, <command>setdriver</command> are amongst
3208 the most interesting ones. rpcclient implements an important part of
3209 the MS-RPC protocol. You can use it to query (and command) a Win NT
3210 (or 2K/XP) PC too. MS-RPC is used by Windows clients, amongst other
3211 things, to benefit from the "Point'n'Print" features. Samba can now
3212 mimic this too.
3213 </para>
3215 <sect2>
3216 <title>A Check of the rpcclient man Page</title>
3218 <para>
3219 First let's have a little check of the rpcclient man page. Here are
3220 two relevant passages:
3221 </para>
3223 <para>
3224 <command>adddriver &lt;arch&gt; &lt;config&gt;</command> Execute an
3225 AddPrinterDriver() RPC to install the printer driver information on
3226 the server.  Note that the driver files should already exist in the
3227 directory returned by <command>getdriverdir</command>.  Possible
3228 values for <parameter>arch</parameter> are the same as those for the
3229 <command>getdriverdir</command> command.  The
3230 <parameter>config</parameter> parameter is defined as follows:
3231 </para>
3232                 
3233 <para><screen>
3234 Long Printer Name:\
3235 Driver File Name:\
3236 Data File Name:\
3237 Config File Name:\
3238 Help File Name:\
3239 Language Monitor Name:\
3240 Default Data Type:\
3241 Comma Separated list of Files
3242 </screen></para>
3244 <para>Any empty fields should be enter as the string "NULL". </para>
3246 <para>Samba does not need to support the concept of Print Monitors
3247 since these only apply to local printers whose driver can make use of
3248 a bi-directional link for communication.  This field should be "NULL".
3249 On a remote NT print server, the Print Monitor for a driver must
3250 already be installed prior to adding the driver or else the RPC will
3251 fail
3252 </para>
3254 <para>
3255 <command>setdriver &lt;printername&gt; &lt;drivername&gt;</command>
3256 Execute a <command>SetPrinter()</command> command to update the
3257 printer driver associated with an installed printer. The printer
3258 driver must already be correctly installed on the print server.
3259 </para>
3261 <para> See also the enumprinters and enumdrivers commands for
3262 obtaining a list of installed printers and drivers.
3263 </para>
3265 </sect2>
3267 <sect2>
3268 <title>Understanding the rpcclient man page</title>
3270 <para>
3271 The <emphasis>exact</emphasis> format isn't made too clear by the man
3272 page, since you have to deal with some parameters containing
3273 spaces. Here is a better description for it. We have line-broken the
3274 command and indicated the breaks with "\". Usually you would type the
3275 command in one line without the linebreaks:
3276 </para>
3278 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3280 <para><screen>
3281  adddriver "Architecture" \
3282            "LongPrinterName:DriverFile:DataFile:ConfigFile:HelpFile:\
3283            LanguageMonitorFile:DataType:ListOfFiles,Comma-separated"
3284 </screen></para>
3286 <para>
3287 What the man pages denotes as a simple &lt;config&gt;
3288 keyword, does in reality consist of 8 colon-separated fields. The
3289 last field may take multiple (in some, very insane, cases, even
3290 20 different additional files. This might sound confusing at first.
3291 Note, that what the man pages names the "LongPrinterName" in
3292 reality should rather be called the "Driver Name". You can name it
3293 anything you want, as long as you use this name later in the
3294 <emphasis>rpcclient ... setdriver</emphasis> command. For
3295 practical reasons, many name the driver the same as the
3296 printer.
3297 </para>
3299 <para>
3300 True: it isn't simple at all. I hear you asking:
3301 <emphasis>How do I know which files are "Driver
3302 File", "Data File", "Config File", "Help File" and "Language
3303 Monitor File" in each case?</emphasis> -- For an answer you may
3304 want to have a look at how a Windows NT box with a shared printer
3305 presents the files to us. Remember, that this whole procedure has
3306 to be developed by the Samba Team by overhearing the traffic caused
3307 by Windows computers on the wire. We may as well turn to a Windows
3308 box now, and access it from a UNIX workstation. We will query it
3309 with <command>rpcclient</command> to see what it tells us and
3310 try to understand the man page more clearly which we've read just
3311 now.
3312 </para>
3313 </sect2>
3315 <sect2>
3316 <title>Producing an Example by querying a Windows Box</title>
3318 <para>
3319         <indexterm><primary>rpcclient</primary><secondary>getdriver</secondary></indexterm>
3320         <indexterm><primary>rpcclient</primary><secondary>getprinter</secondary></indexterm>
3321 We could run <command>rpcclient</command> with a
3322 <command>getdriver</command> or a <command>getprinter</command>
3323 subcommand (in level 3 verbosity) against it. Just sit down at UNIX or
3324 Linux workstation with the Samba utilities installed. Then type the
3325 following command:
3326 </para>
3328 <para><screen>
3329 &rootprompt;<userinput>rpcclient -U'USERNAME%PASSWORD' NT-SERVER-NAME -c 'getdriver printername 3'</userinput>
3330 </screen></para>
3332 <para>
3333 From the result it should become clear which is which. Here is an
3334 example from my installation:
3335 </para>
3337         <indexterm><primary>rpcclient</primary><secondary>getdriver</secondary></indexterm>
3338 <para><screen>
3339 &rootprompt;<userinput>rpcclient -U'Danka%xxxx' W2KSERVER \
3340         -c'getdriver "DANKA InfoStream Virtual Printer" 3'</userinput>
3341  cmd = getdriver "DANKA InfoStream Virtual Printer" 3
3343  [Windows NT x86]
3344  Printer Driver Info 3:
3345          Version: [2]
3346          Driver Name: [DANKA InfoStream]
3347          Architecture: [Windows NT x86]
3348          Driver Path: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\PSCRIPT.DLL]
3349          Datafile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\INFOSTRM.PPD]
3350          Configfile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\PSCRPTUI.DLL]
3351          Helpfile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\PSCRIPT.HLP]
3353          Dependentfiles: []
3354          Dependentfiles: []
3355          Dependentfiles: []
3356          Dependentfiles: []
3357          Dependentfiles: []
3358          Dependentfiles: []
3359          Dependentfiles: []
3361          Monitorname: []
3362          Defaultdatatype: []
3364 </screen></para>
3366 <para>
3367 Some printer drivers list additional files under the label
3368 "Dependentfiles": these would go into the last field
3369 <emphasis>ListOfFiles,Comma-separated</emphasis>. For the CUPS
3370 PostScript drivers we don't need any (nor would we for the Adobe
3371 PostScript driver): therefore the field will get a "NULL" entry.
3372 </para>
3373 </sect2>
3375 <sect2>
3376 <title>What is required for adddriver and setdriver to succeed</title>
3378 <para>
3379 From the manpage (and from the quoted output
3380 of <emphasis>cupsaddsmb</emphasis>, above) it becomes clear that you
3381 need to have certain conditions in order to make the manual uploading
3382 and initializing of the driver files succeed. The two rpcclient
3383 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3384 subcommands (<command>adddriver</command> and
3385 <command>setdriver</command>) need to encounter the following
3386 pre-conditions to complete successfully:
3387 </para>
3388 <itemizedlist>
3390 <listitem><para>you are connected as <smbconfoption><name>printer admin</name></smbconfoption>, or root (note,
3391 that this is <emphasis>not</emphasis> the "Printer Operators" group in
3392 NT, but the <emphasis>printer admin</emphasis> group, as defined in
3393 the <smbconfsection>[global]</smbconfsection> section of
3394 &smb.conf;);</para></listitem>
3396 <listitem><para>copy all required driver files to
3397 <filename>\\sambaserver\print$\w32x86</filename> and
3398 <filename>\\sambaserver\print$\win40</filename> as appropriate. They
3399 will end up in the "0" respective "2" subdirectories later -- for now
3400 <emphasis>don't</emphasis> put them there, they'll be automatically
3401 used by the <command>adddriver</command> subcommand.! (if you use
3402 "smbclient" to put the driver files into the share, note that you need
3403 to escape the "$": <command>smbclient //sambaserver/print\$ -U
3404 root</command>);</para></listitem>
3406 <listitem><para>the user you're connecting as must be able to write to
3407 the <smbconfsection>[print$]</smbconfsection> share and create
3408 subdirectories;</para></listitem>
3410 <listitem><para>the printer you are going to setup for the Windows
3411 clients, needs to be installed in CUPS already;</para></listitem>
3413 <listitem><para>
3414         <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
3415         <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3416                 the CUPS printer must be known to Samba, otherwise the
3417 <command>setdriver</command> subcommand fails with an
3418 NT_STATUS_UNSUCCESSFUL error. To check if the printer is known by
3419 Samba you may use the <command>enumprinters</command> subcommand to
3420 rpcclient. A long-standing bug prevented a proper update of the
3421 printer list until every smbd process had received a SIGHUP or was
3422 restarted. Remember this in case you've created the CUPS printer just
3423 shortly ago and encounter problems: try restarting
3424 Samba.</para></listitem>
3425 </itemizedlist>
3426 </sect2>
3428 <sect2>
3429 <title>Manual Driver Installation in 15 Steps</title>
3431 <para>
3432 We are going to install a printer driver now by manually executing all
3433 required commands. As this may seem a rather complicated process at
3434 first, we go through the procedure step by step, explaining every
3435 single action item as it comes up.
3436 </para>
3438 <procedure>
3439         <title>Manual Driver Installation installation</title>
3441 <step>
3442 <title>Install the Printer on CUPS</title>
3444 <para><screen>
3445 &rootprompt;<userinput>lpadmin -p mysmbtstprn -v socket://10.160.51.131:9100 -E -P canonIR85.ppd</userinput>
3446 </screen></para>
3448 <para>
3449 This installs printer with the name <emphasis>mysmbtstprn</emphasis>
3450 to the CUPS system. The printer is accessed via a socket
3451 (a.k.a. JetDirect or Direct TCP/IP) connection. You need to be root
3452 for this step
3453 </para>
3454 </step>
3456 <step>
3457 <title>(optional) Check if the Printer is recognized by
3458 Samba</title>
3460         <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3461 <para><screen>
3462 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'enumprinters' localhost | grep -C2 mysmbtstprn</userinput>
3463 flags:[0x800000]
3464 name:[\\kde-bitshop\mysmbtstprn]
3465 description:[\\kde-bitshop\mysmbtstprn,,mysmbtstprn]
3466 comment:[mysmbtstprn]
3467 </screen></para>
3469 <para>
3470 This should show the printer in the list. If not, stop and re-start
3471 the Samba daemon (smbd), or send a HUP signal: <command>kill -HUP
3472 `pidof smbd`</command>. Check again.  Troubleshoot and repeat until
3473 success. Note the "empty" field between the two commas in the
3474 "description" line. Here would the driver name appear if there was one
3475 already. You need to know root's Samba password (as set by the
3476 <command>smbpasswd</command> command) for this step and most of the
3477 following steps. Alternatively you can authenticate as one of the
3478 users from the "write list" as defined in &smb.conf; for
3479 <smbconfsection>[print$]</smbconfsection>.
3480 </para>
3481 </step>
3483 <step>
3484 <title>(optional) Check if Samba knows a Driver for the
3485 Printer</title>
3487         <indexterm><primary>rpcclient</primary><secondary>getprinter</secondary></indexterm>
3488         <indexterm><primary>rpcclient</primary><secondary>getdriver</secondary></indexterm>
3489 <para><screen>
3490 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' localhost \
3491                         | grep driver </userinput>
3492 drivername:[]
3494 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' localhost \
3495         | grep -C4 driv</userinput>
3496 servername:[\\kde-bitshop]
3497 printername:[\\kde-bitshop\mysmbtstprn]
3498 sharename:[mysmbtstprn]
3499 portname:[Samba Printer Port]
3500 drivername:[]
3501 comment:[mysmbtstprn]
3502 location:[]
3503 sepfile:[]
3504 printprocessor:[winprint]
3506 &rootprompt;<userinput>rpcclient -U root%xxxx -c 'getdriver mysmbtstprn' localhost</userinput>
3507  result was WERR_UNKNOWN_PRINTER_DRIVER
3509 </screen></para>
3511 <para>
3512 Neither method of the three commands shown above should show a driver.
3513 This step was done for the purpose of demonstrating this condition. An
3514 attempt to connect to the printer at this stage will prompt the
3515 message along the lines: "The server has not the required printer
3516 driver installed".
3517 </para>
3518 </step>
3520 <step>
3521 <title>Put all required Driver Files into Samba's
3522 [print$]</title>
3524 <para><screen>
3525 &rootprompt;<userinput>smbclient //localhost/print\$ -U 'root%xxxx' \
3526         -c 'cd W32X86; \
3527         put /etc/cups/ppd/mysmbtstprn.ppd mysmbtstprn.PPD; \ 
3528         put /usr/share/cups/drivers/cupsui.dll cupsui.dll; \
3529         put /usr/share/cups/drivers/cupsdrvr.dll cupsdrvr.dll; \
3530         put /usr/share/cups/drivers/cups.hlp cups.hlp'</userinput>
3531 </screen></para>
3533 <para>
3534 (Note that this command should be entered in one long single
3535 line. Line-breaks and the line-end indicating "\" has been inserted
3536 for readability reasons.) This step is <emphasis>required</emphasis>
3537 for the next one to succeed. It makes the driver files physically
3538 present in the <smbconfsection>[print$]</smbconfsection> share. However, clients
3539 would still not be able to install them, because Samba does not yet
3540 treat them as driver files. A client asking for the driver would still
3541 be presented with a "not installed here" message.
3542 </para>
3543 </step>
3545 <step>
3546 <title>Verify where the Driver Files are now</title>
3548 <para><screen>
3549 &rootprompt;<userinput>ls -l /etc/samba/drivers/W32X86/</userinput>
3550 total 669
3551 drwxr-sr-x    2 root     ntadmin       532 May 25 23:08 2
3552 drwxr-sr-x    2 root     ntadmin       670 May 16 03:15 3
3553 -rwxr--r--    1 root     ntadmin     14234 May 25 23:21 cups.hlp
3554 -rwxr--r--    1 root     ntadmin    278380 May 25 23:21 cupsdrvr.dll
3555 -rwxr--r--    1 root     ntadmin    215848 May 25 23:21 cupsui.dll
3556 -rwxr--r--    1 root     ntadmin    169458 May 25 23:21 mysmbtstprn.PPD
3557 </screen></para>
3559 <para>
3560 The driver files now are in the W32X86 architecture "root" of
3561 <smbconfsection>[print$]</smbconfsection>.
3562 </para>
3563 </step>
3565 <step>
3566 <title>Tell Samba that these are
3567 <emphasis>Driver</emphasis> Files
3568 (<command>adddriver</command>)</title>
3570         <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3571 <para><screen>
3572 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c `adddriver "Windows NT x86" "mydrivername: \
3573   cupsdrvr.dll:mysmbtstprn.PPD: \
3574   cupsui.dll:cups.hlp:NULL:RAW:NULL" \
3575   localhost</userinput>
3576 Printer Driver mydrivername successfully installed.
3577 </screen></para>
3579 <para>
3580 Note that your cannot repeat this step if it fails. It could fail even
3581 as a result of a simple typo. It will most likely have moved a part of
3582 the driver files into the "2" subdirectory. If this step fails, you
3583 need to go back to the fourth step and repeat it, before you can try
3584 this one again. In this step you need to choose a name for your
3585 driver. It is normally a good idea to use the same name as is used for
3586 the printername; however, in big installations you may use this driver
3587 for a number of printers which have obviously different names. So the
3588 name of the driver is not fixed.
3589 </para>
3590 </step>
3592 <step>
3593 <title>Verify where the Driver Files are now</title>
3595 <para><screen>
3596 &rootprompt;<userinput>ls -l /etc/samba/drivers/W32X86/</userinput>
3597 total 1
3598 drwxr-sr-x    2 root     ntadmin       532 May 25 23:22 2
3599 drwxr-sr-x    2 root     ntadmin       670 May 16 03:15 3
3601 &rootprompt;<userinput>ls -l /etc/samba/drivers/W32X86/2</userinput>
3602 total 5039
3603 [....]
3604 -rwxr--r--    1 root     ntadmin     14234 May 25 23:21 cups.hlp
3605 -rwxr--r--    1 root     ntadmin    278380 May 13 13:53 cupsdrvr.dll
3606 -rwxr--r--    1 root     ntadmin    215848 May 13 13:53 cupsui.dll
3607 -rwxr--r--    1 root     ntadmin    169458 May 25 23:21 mysmbtstprn.PPD
3608 </screen></para>
3610 <para>
3611 Notice how step 6 did also move the driver files to the appropriate
3612 subdirectory. Compare with the situation after step 5.
3613 </para>
3614 </step>
3616 <step>
3617 <title>(optional) Verify if Samba now recognizes the
3618 Driver</title>
3620         <indexterm><primary>rpcclient</primary><secondary>enumdrivers</secondary></indexterm>
3621 <para><screen>
3622 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'enumdrivers 3' localhost \
3623         | grep -B2 -A5 mydrivername</userinput>
3624 Printer Driver Info 3:
3625 Version: [2]
3626 Driver Name: [mydrivername]
3627 Architecture: [Windows NT x86]
3628 Driver Path: [\\kde-bitshop\print$\W32X86\2\cupsdrvr.dll]
3629 Datafile: [\\kde-bitshop\print$\W32X86\2\mysmbtstprn.PPD]
3630 Configfile: [\\kde-bitshop\print$\W32X86\2\cupsui.dll]
3631 Helpfile: [\\kde-bitshop\print$\W32X86\2\cups.hlp]
3632 </screen></para>
3634 <para>
3635 Remember, this command greps for the name you did choose for the
3636 driver in step Six. This command must succeed before you can proceed.
3637 </para>
3638 </step>
3640 <step>
3641 <title>Tell Samba which Printer should use these Driver
3642 Files (<command>setdriver</command>)</title>
3644 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
3646 <para><screen>
3647 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'setdriver mysmbtstprn mydrivername' localhost</userinput>
3648 Successfully set mysmbtstprn to driver mydrivername
3649 </screen></para>
3651 <para>
3652 Since you can bind any printername (=printqueue) to any driver, this
3653 is a very convenient way to setup many queues which use the same
3654 driver. You don't need to repeat all the previous steps for the
3655 setdriver command to succeed. The only pre-conditions are:
3656 <command>enumdrivers</command> must find the driver and
3657 <command>enumprinters</command> must find the printer.
3658 </para>
3659 </step>
3661 <step>
3662 <title>(optional) Verify if Samba has this Association
3663 recognized</title>
3665 <indexterm><primary>rpcclient</primary><secondary>getprinter</secondary></indexterm>
3666 <indexterm><primary>rpcclient</primary><secondary>getdriver</secondary></indexterm>
3667 <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3668 <para><screen>
3669 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' localhost \
3670   | grep driver</userinput>
3671 drivername:[mydrivername]
3673 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' localhost \
3674   | grep -C4 driv</userinput>
3675 servername:[\\kde-bitshop]
3676 printername:[\\kde-bitshop\mysmbtstprn]
3677 sharename:[mysmbtstprn]
3678 portname:[Done]
3679 drivername:[mydrivername]
3680 comment:[mysmbtstprn]
3681 location:[]
3682 sepfile:[]
3683 printprocessor:[winprint]
3685 &rootprompt;<userinput>rpcclient -U root%xxxx -c 'getdriver mysmbtstprn' localhost</userinput>
3686 [Windows NT x86]
3687 Printer Driver Info 3:
3688      Version: [2]
3689      Driver Name: [mydrivername]
3690      Architecture: [Windows NT x86]
3691      Driver Path: [\\kde-bitshop\print$\W32X86\2\cupsdrvr.dll]
3692      Datafile: [\\kde-bitshop\print$\W32X86\2\mysmbtstprn.PPD]
3693      Configfile: [\\kde-bitshop\print$\W32X86\2\cupsui.dll]
3694      Helpfile: [\\kde-bitshop\print$\W32X86\2\cups.hlp]
3695      Monitorname: []
3696      Defaultdatatype: [RAW]
3697      Monitorname: []
3698      Defaultdatatype: [RAW]
3700 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'enumprinters' localhost | grep mysmbtstprn</userinput>
3701      name:[\\kde-bitshop\mysmbtstprn]
3702      description:[\\kde-bitshop\mysmbtstprn,mydrivername,mysmbtstprn]
3703      comment:[mysmbtstprn]
3705 </screen></para>
3707 <para>
3708 <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3709 Compare these results with the ones from steps 2 and 3. Note that
3710 every single of these commands show the driver is installed.  Even
3711 the <command>enumprinters</command> command now lists the driver
3712 on the "description" line.
3713 </para>
3714 </step>
3716 <step>
3717 <title>(optional) Tickle the Driver into a correct
3718 Device Mode</title>
3720 <para>
3721 <indexterm><primary>"Printers" folder</primary></indexterm>
3722 You certainly know how to install the driver on the client.  In case
3723 you are not particularly familiar with Windows, here is a short
3724 recipe: browse the Network Neighbourhood, go to the Samba server, look
3725 for the shares. You should see all shared Samba printers.
3726 Double-click on the one in question. The driver should get
3727 installed, and the network connection set up. An alternative way is to
3728 open the "Printers (and Faxes)" folder, right-click on the printer in
3729 question and select "Connect" or "Install". As a result, a new printer
3730 should have appeared in your client's local "Printers (and Faxes)"
3731 folder, named something like "printersharename on Sambahostname".
3732 </para>
3734 <para>
3735 It is important that you execute this step as a Samba printer admin
3736 (as defined in &smb.conf;). Here is another method
3737 to do this on Windows XP. It uses a commandline, which you may type
3738 into the "DOS box" (type root's smbpassword when prompted):
3739 </para>
3741 <para><screen>
3742 &dosprompt;<userinput>runas /netonly /user:root "rundll32 printui.dll,PrintUIEntry /in /n\
3743                         \\sambacupsserver\mysmbtstprn"</userinput>
3744 </screen></para>
3746 <para>
3747 Change any printer setting once (like changing <emphasis>"portrait" to
3748         "landscape"</emphasis>), click <guibutton>Apply</guibutton>; change the setting
3749 back.
3750 </para>
3751 </step>
3753 <step>
3754 <title>Install the Printer on a Client
3755 ("Point'n'Print")</title>
3757 <indexterm significance="preferred"><primary>point and print</primary></indexterm>
3759 <para><screen>
3760 &dosprompt;<userinput>rundll32 printui.dll,PrintUIEntry /in /n "\\sambacupsserver\mysmbtstprn"</userinput>
3761 </screen></para>
3763 <para>
3764 If it doesn't work it could be a permission problem with the
3765 <smbconfsection>[print$]</smbconfsection> share.
3766 </para>
3767 </step>
3769 <step>
3770 <title>Thirteenth Step (optional): Print a Test Page</title>
3772 <para><screen>
3773 &dosprompt;<userinput>rundll32 printui.dll,PrintUIEntry /p /n "\\sambacupsserver\mysmbtstprn"</userinput>
3774 </screen></para>
3776 <para>
3777 Then hit [TAB] 5 times, [ENTER] twice, [TAB] once and [ENTER] again
3778 and march to the printer.
3779 </para>
3780 </step>
3782 <step>
3783 <title>Fourteenth Step (recommended): Study the Test Page</title>
3785 <para>
3786 Hmmm.... just kidding! By now you know everything about printer
3787 installations and you don't need to read a word. Just put it in a
3788 frame and bolt it to the wall with the heading "MY FIRST
3789 RPCCLIENT-INSTALLED PRINTER" - why not just throw it away!
3790 </para>
3791 </step>
3793 <step>
3794 <title>Fifteenth Step (obligatory): Enjoy. Jump. Celebrate your
3795 Success</title>
3797 <para><screen>
3798 &rootprompt;<userinput>echo "Cheeeeerioooooo! Success..." &gt;&gt; /var/log/samba/log.smbd</userinput>
3799 </screen></para>
3800 </step>
3801 </procedure>
3802 </sect2>
3804 <sect2>
3805 <title>Troubleshooting revisited</title>
3807 <para>
3808 The setdriver command will fail, if in Samba's mind the queue is not
3809 already there. You had promising messages about the:
3810 </para>
3812 <para><screen>
3814  Printer Driver ABC successfully installed.
3816 </screen></para>
3818 <para>
3819 after the "adddriver" parts of the procedure?  But you are also seeing
3820 a disappointing message like this one beneath?
3821 </para>
3823 <para><screen>
3825  result was NT_STATUS_UNSUCCESSFUL
3827 </screen></para>
3829 <para>
3830 <indexterm><primary>lpstat</primary></indexterm>
3831 It is not good enough that you
3832 can see the queue <emphasis>in CUPS</emphasis>, using
3833 the <command>lpstat -p ir85wm</command> command. A
3834 bug in most recent versions of Samba prevents the proper update of
3835 the queuelist. The recognition of newly installed CUPS printers
3836 fails unless you re-start Samba or send a HUP to all smbd
3837 processes. To verify if this is the reason why Samba doesn't
3838 execute the setdriver command successfully, check if Samba "sees"
3839 the printer: 
3840 </para>
3842 <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3843 <para><screen>
3844 &rootprompt;<userinput>rpcclient transmeta -N -U'root%secret' -c 'enumprinters 0'| grep  ir85wm</userinput>
3845         printername:[ir85wm]
3846 </screen></para>
3848 <para>
3849 An alternative command could be this: 
3850 </para>
3852 <indexterm><primary>rpcclient</primary><secondary>getprinter</secondary></indexterm>
3853 <para><screen>
3854 &rootprompt;<userinput>rpcclient transmeta -N -U'root%secret' -c 'getprinter ir85wm' </userinput>
3855         cmd = getprinter ir85wm
3856         flags:[0x800000]
3857         name:[\\transmeta\ir85wm]
3858         description:[\\transmeta\ir85wm,ir85wm,DPD]
3859         comment:[CUPS PostScript-Treiber for WinNT/2K/XP]
3860 </screen></para>
3862 <para>
3863 BTW, you can use these commands, plus a few more, of course,
3864 to install drivers on remote Windows NT print servers too!
3865 </para>
3866 </sect2>
3867 </sect1>
3869 <sect1>
3870 <title>The printing <filename>*.tdb</filename> Files</title>
3872 <para>
3873 <indexterm><primary>TDB</primary></indexterm>
3874 <indexterm><primary>connections.tdb</primary><seealso>TDB</seealso></indexterm>
3875 <indexterm><primary>printing.tdb</primary><seealso>TDB</seealso></indexterm>
3876 <indexterm><primary>share_info.tdb</primary><seealso>TDB</seealso></indexterm>
3877 <indexterm><primary>ntdrivers.tdb</primary><seealso>TDB</seealso></indexterm>
3878 <indexterm><primary>unexpected.tdb</primary><seealso>TDB</seealso></indexterm>
3879 <indexterm><primary>brlock.tdb</primary><seealso>TDB</seealso></indexterm>
3880 <indexterm><primary>locking.tdb</primary><seealso>TDB</seealso></indexterm>
3881 <indexterm><primary>ntforms.tdb</primary><seealso>TDB</seealso></indexterm>
3882 <indexterm><primary>messages.tdb</primary><seealso>TDB</seealso></indexterm>
3883 <indexterm><primary>ntprinters.tdb</primary><seealso>TDB</seealso></indexterm>
3884 <indexterm><primary>sessionid.tdb</primary><seealso>TDB</seealso></indexterm>
3885 <indexterm><primary>secrets.tdb</primary><seealso>TDB</seealso></indexterm>
3886 Some mystery is associated with the series of files with a
3887 tdb-suffix appearing in every Samba installation. They are
3888 <filename>connections.tdb</filename>,
3889 <filename>printing.tdb</filename>,
3890 <filename>share_info.tdb</filename> ,
3891 <filename>ntdrivers.tdb</filename>,
3892 <filename>unexpected.tdb</filename>,
3893 <filename>brlock.tdb</filename> ,
3894 <filename>locking.tdb</filename>,
3895 <filename>ntforms.tdb</filename>,
3896 <filename>messages.tdb</filename> ,
3897 <filename>ntprinters.tdb</filename>,
3898 <filename>sessionid.tdb</filename> and
3899 <filename>secrets.tdb</filename>. What is their purpose?
3900 </para>
3902 <sect2>
3903 <title>Trivial DataBase Files</title>
3905 <indexterm><primary>TDB</primary></indexterm>
3906 <para>
3907 A Windows NT (Print) Server keeps track of all information needed to serve
3908 its duty toward its clients by storing entries in the Windows
3909 "Registry". Client queries are answered by reading from the registry,
3910 Administrator or user configuration settings are saved by writing into
3911 the Registry. Samba and UNIX obviously don't have such a kind of
3912 Registry. Samba instead keeps track of all client related information in a
3913 series of <filename>*.tdb</filename> files. (TDB = Trivial Data
3914 Base). These are often located in <filename>/var/lib/samba/</filename>
3915 or <filename>/var/lock/samba/</filename> . The printing related files
3916 are <filename>ntprinters.tdb</filename>,
3917 <filename>printing.tdb</filename>,<filename>ntforms.tdb</filename> and
3918 <filename>ntdrivers.tdb</filename>.
3919 </para>
3920 </sect2>
3922 <sect2>
3923 <title>Binary Format</title>
3925 <para>
3926 <filename>*.tdb</filename> files are not human readable. They are
3927 written in a binary format. "Why not ASCII?", you may ask. "After all,
3928 ASCII configuration files are a good and proofed tradition on UNIX."
3929 -- The reason for this design decision by the Samba Team is mainly
3930 performance. Samba needs to be fast; it runs a separate
3931 <command>smbd</command> process for each client connection, in some
3932 environments many thousand of them. Some of these smbds might need to
3933 write-access the same <filename>*.tdb</filename> file <emphasis>at the
3934 same time</emphasis>. The file format of Samba's
3935 <filename>*.tdb</filename> files allows for this provision. Many smbd
3936 processes may write to the same <filename>*.tdb</filename> file at the
3937 same time. This wouldn't be possible with pure ASCII files.
3938 </para>
3939 </sect2>
3941 <sect2>
3942 <title>Losing <filename>*.tdb</filename> Files</title>
3944 <para>
3945 It is very important that all <filename>*.tdb</filename> files remain
3946 consistent over all write and read accesses. However, it may happen
3947 that these files <emphasis>do</emphasis> get corrupted. (A
3948 <command>kill -9 `pidof smbd`</command> while a write access is in
3949 progress could do the damage as well as a power interruption,
3950 etc.). In cases of trouble, a deletion of the old printing-related
3951 <filename>*.tdb</filename> files may be the only option. You need to
3952 re-create all print related setup after that.  Or you have made a
3953 backup of the <filename>*.tdb</filename> files in time.
3954 </para>
3955 </sect2>
3957 <sect2>
3958 <title>Using <emphasis>tdbbackup</emphasis></title>
3960 <indexterm><primary>TDB</primary><secondary>backing up</secondary><see>tdbbackup</see></indexterm>
3961 <indexterm><primary>tdbbackup</primary></indexterm>
3963 <para>
3964 Samba ships with a little utility which helps the root user of your
3965 system to back up your <filename>*.tdb</filename> files. If you run it
3966 with no argument, it prints a little usage message:
3967 </para>
3969 <para><screen>
3970 &rootprompt;<userinput>tdbbackup</userinput>
3971  Usage: tdbbackup [options] &lt;fname...&gt;
3973  Version:3.0a
3974    -h            this help message
3975    -s suffix     set the backup suffix
3976    -v            verify mode (restore if corrupt)
3978 </screen></para>
3980 <para>
3981 Here is how I backed up my printing.tdb file:
3982 </para>
3984 <para><screen>
3985 &rootprompt;<userinput>ls</userinput>
3986 .              browse.dat       locking.tdb     ntdrivers.tdb   printing.tdb
3987 ..             share_info.tdb   connections.tdb messages.tdb    ntforms.tdb
3988 printing.tdbkp unexpected.tdb   brlock.tdb      gmon.out        namelist.debug  
3989 ntprinters.tdb sessionid.tdb
3991 &rootprompt;<userinput>tdbbackup -s .bak printing.tdb</userinput>
3992  printing.tdb : 135 records
3994 &rootprompt;<userinput>ls -l printing.tdb*</userinput>
3995  -rw-------    1 root     root        40960 May  2 03:44 printing.tdb
3996  -rw-------    1 root     root        40960 May  2 03:44 printing.tdb.bak
3998 </screen></para>
3999 </sect2>
4000 </sect1>
4002 <sect1>
4003 <title>CUPS Print Drivers from Linuxprinting.org</title>
4005 <indexterm><primary>Linuxprinting.org</primary></indexterm>
4007 <para>
4008 CUPS ships with good support for HP LaserJet type printers.  You can
4009 install the generic driver as follows:
4010 </para>
4012 <indexterm><primary>lpadmin</primary></indexterm>
4014 <para><screen>
4015 &rootprompt;<userinput>lpadmin -p laserjet4plus -v parallel:/dev/lp0 -E -m laserjet.ppd</userinput>
4016 </screen></para>
4018 <para>
4019 The <option>-m</option> switch will retrieve the
4020 <filename>laserjet.ppd</filename> from the standard repository for
4021 not-yet-installed-PPDs, which CUPS typically stores in
4022 <filename>/usr/share/cups/model</filename>. Alternatively, you may use
4023 <option>-P /path/to/your.ppd</option>.
4024 </para>
4026 <para>
4027 The generic laserjet.ppd however does not support every special option
4028 for every LaserJet-compatible model. It constitutes a sort of "least
4029 denominator" of all the models. If for some reason it is ruled out to
4030 you to pay for the commercially available ESP Print Pro drivers, your
4031 first move should be to consult the database on <ulink
4032 noescape="1" url="http://www.linuxprinting.org/printer_list.cgi">http://www.linuxprinting.org/printer_list.cgi</ulink>.
4033 Linuxprinting.org has excellent recommendations about which driver is
4034 best used for each printer. Its database is kept current by the
4035 tireless work of Till Kamppeter from MandrakeSoft, who is also the
4036 principal author of the foomatic-rip utility.
4037 </para>
4039 <note><para>
4040 <indexterm><primary>foomatic-rip</primary></indexterm>
4041 The former "cupsomatic" concept is now be replaced by the new, much
4042 more powerful "foomatic-rip". foomatic-rip is the successor of
4043 cupsomatic. cupsomatic is no longer maintained. Here is the new URL
4044 to the Foomatic-3.0 database:<ulink
4045 noescape="1" url="http://www.linuxprinting.org/driver_list.cgi">http://www.linuxprinting.org/driver_list.cgi</ulink>.
4046 If you upgrade to foomatic-rip, don't forget to also upgrade to the
4047 new-style PPDs for your foomatic-driven printers. foomatic-rip will
4048 not work with PPDs generated for the old cupsomatic. The new-style
4049 PPDs are 100% compliant to the Adobe PPD specification. They are
4050 intended to be used by Samba and the cupsaddsmb utility also, to
4051 provide the driver files for the Windows clients also!
4052 </para></note>
4054 <sect2>
4055 <title>foomatic-rip and Foomatic explained</title>
4057 <indexterm significance="preferred"><primary>foomatic</primary></indexterm>
4058 <indexterm significance="preferred"><primary>foomatic-rip</primary></indexterm>
4060 <para>
4061 Nowadays most Linux distros rely on the utilities of Linuxprinting.org
4062 to create their printing related software (which, BTW, works on all
4063 UNIXes and on Mac OS X or Darwin too). It is not known as well as it
4064 should be, that it also has a very end-user friendly interface which
4065 allows for an easy update of drivers and PPDs, for all supported
4066 models, all spoolers, all operating systems and all package formats
4067 (because there is none). Its history goes back a few years.
4068 </para>
4070 <para>
4071 Recently Foomatic has achieved the astonishing milestone of <ulink
4072 url="http://www.linuxprinting.org/printer_list.cgi?make=Anyone">1000
4073 listed</ulink> printer models. Linuxprinting.org keeps all the
4074 important facts about printer drivers, supported models and which
4075 options are available for the various driver/printer combinations in
4076 its <ulink
4077 url="http://www.linuxprinting.org/foomatic.html">Foomatic</ulink>
4078 database. Currently there are <ulink
4079 url="http://www.linuxprinting.org/driver_list.cgi">245 drivers</ulink>
4080 in the database: many drivers support various models, and many models
4081 may be driven by different drivers; it's your choice!
4082 </para>
4084 <sect3>
4085 <title>690 "perfect" Printers</title>
4087 <para>
4088 At present there are 690 devices dubbed as working "perfectly", 181
4089 "mostly", 96 "partially" and 46 are "Paperweights". Keeping in mind
4090 that most of these are non-PostScript models (PostScript printers are
4091 automatically supported supported by CUPS to perfection, by using
4092 their own manufacturer-provided Windows-PPD...), and that a
4093 multifunctional device never qualifies as working "perfectly" if it
4094 doesn't also scan and copy and fax under GNU/Linux: then this is a
4095 truly astonishing achievement. Three years ago the number was not
4096 more than 500, and Linux or UNIX "printing" at the time wasn't
4097 anywhere near the quality it is today!
4098 </para>
4099 </sect3>
4101 <sect3>
4102 <title>How the "Printing HOWTO" started it all</title>
4104 <para>
4105 A few years ago <ulink
4106 url="http://www2.picante.com:81/~gtaylor/">Grant Taylor</ulink>
4107 started it all. The roots of today's Linuxprinting.org are in the
4108 first <ulink
4109 url="http://www.linuxprinting.org/foomatic2.9/howto/">Linux Printing
4110 HOWTO</ulink> which he authored. As a side-project to this document,
4111 which served many Linux users and admins to guide their first steps in
4112 this complicated and delicate setup (to a scientist, printing is
4113 "applying a structured deposition of distinct patterns of ink or toner
4114 particles on paper substrates" <emphasis>;-)</emphasis>, he started to
4115 build in a little Postgres database with information about the
4116 hardware and driver zoo that made up Linux printing of the time. This
4117 database became the core component of today's Foomatic collection of
4118 tools and data. In the meantime it has moved to an XML representation
4119 of the data.
4120 </para>
4121 </sect3>
4123 <sect3>
4124 <title>Foomatic's strange Name</title>
4126 <indexterm><primary>foomatic</primary></indexterm>
4128 <para>
4129 "Why the funny name?", you ask. When it really took off, around spring
4130 2000, CUPS was far less popular than today, and most systems used LPD,
4131 LPRng or even PDQ to print. CUPS shipped with a few generic "drivers"
4132 (good for a few hundred different printer models). These didn't
4133 support many device-specific options. CUPS also shipped with its own
4134 built-in rasterization filter ("pstoraster", derived from
4135 Ghostscript). On the other hand, CUPS provided brilliant support for
4136 <emphasis>controlling</emphasis> all printer options through
4137 standardized and well-defined "PPD files" (PostScript Printers
4138 Description files). Plus, CUPS was designed to be easily extensible.
4139 </para>
4141 <para>
4142 Grant already had in his database a respectable compilation
4143 of facts about a many more printers, and the Ghostscript "drivers"
4144 they run with. His idea, to generate PPDs from the database info
4145 and use them to make standard Ghostscript filters work within CUPS,
4146 proved to work very well. It also "killed several birds with one
4147 stone":
4148 </para>
4150 <itemizedlist>
4151 <listitem><para>It made all current and future Ghostscript filter
4152 developments available for CUPS;</para></listitem>
4154 <listitem><para>It made available a lot of additional printer models
4155 to CUPS users (because often the "traditional" Ghostscript way of
4156 printing was the only one available);</para></listitem>
4158 <listitem><para>It gave all the advanced CUPS options (web interface,
4159 GUI driver configurations) to users wanting (or needing) to use
4160 Ghostscript filters.</para></listitem>
4161 </itemizedlist>
4162 </sect3>
4164 <sect3>
4165 <title>cupsomatic, pdqomatic, lpdomatic, directomatic</title>
4167 <indexterm><primary>cupsomatic</primary></indexterm>
4168 <indexterm><primary>CUPS-PPD</primary></indexterm>
4169 <indexterm><primary>PPD</primary><secondary>CUPS</secondary><see>CUPS-PPD</see></indexterm>
4171 <para>
4172 CUPS worked through a quickly-hacked up filter script named <ulink
4173 url="http://www.linuxprinting.org/download.cgi?filename=cupsomatic&amp;show=0">cupsomatic</ulink>.
4174 cupsomatic ran the printfile through Ghostscript, constructing
4175 automatically the rather complicated command line needed. It just
4176 required to be copied into the CUPS system to make it work. To
4177 "configure" the way cupsomatic controls the Ghostscript rendering
4178 process, it needs a CUPS-PPD. This PPD is generated directly from the
4179 contents of the database. For CUPS and the respective printer/filter
4180 combo another Perl script named "CUPS-O-Matic" did the PPD
4181 generation. After that was working, Grant implemented within a few
4182 days a similar thing for two other spoolers. Names chosen for the
4183 config-generator scripts were <ulink
4184 url="http://www.linuxprinting.org/download.cgi?filename=lpdomatic&amp;show=0">PDQ-O-Matic</ulink>
4185 (for PDQ) and <ulink
4186 url="http://www.linuxprinting.org/download.cgi?filename=lpdomatic&amp;show=0">LPD-O-Matic</ulink>
4187 (for - you guessed it - LPD); the configuration here didn't use PPDs
4188 but other spooler-specific files.
4189 </para>
4191 <para>
4192 From late summer of that year, <ulink
4193 url="http://www.linuxprinting.org/till/">Till Kamppeter</ulink>
4194 started to put work into the database. Till had been newly employed by
4195 <ulink url="http://www.mandrakesoft.com/">MandrakeSoft</ulink> to
4196 convert their printing system over to CUPS, after they had seen his
4197 <ulink url="http://www.fltk.org/">FLTK</ulink>-based <ulink
4198 url="http://cups.sourceforge.net/xpp/">XPP</ulink> (a GUI frontend to
4199 the CUPS lp-command). He added a huge amount of new information and new
4200 printers. He also developed the support for other spoolers, like
4201 <ulink url="http://ppr.sourceforge.net/">PPR</ulink> (via ppromatic),
4202 <ulink url="http://sourceforge.net/projects/lpr/">GNUlpr</ulink> and
4203 <ulink url="http://www.lprng.org/">LPRng</ulink> (both via an extended
4204 lpdomatic) and "spoolerless" printing (<ulink
4205 url="http://www.linuxprinting.org/download.cgi?filename=directomatic&amp;show=0">directomatic</ulink>)....
4206 </para>
4208 <para>
4209 So, to answer your question: "Foomatic" is the general name for all
4210 the overlapping code and data behind the "*omatic" scripts.... --
4211 Foomatic up to versions 2.0.x required (ugly) Perl data structures
4212 attached the Linuxprinting.org PPDs for CUPS. It had a different
4213 "*omatic" script for every spooler, as well as different printer
4214 configuration files..
4215 </para>
4216 </sect3>
4218 <sect3>
4219 <title>The <emphasis>Grand Unification</emphasis>
4220 achieved...</title>
4222 <indexterm><primary>foomatic-rip</primary></indexterm>
4224 <para>
4225 This all has changed in Foomatic versions 2.9 (Beta) and released as
4226 "stable" 3.0. This has now achieved the convergence of all *omatic
4227 scripts: it is called the <ulink
4228 url="http://www.linuxprinting.org/foomatic2.9/download.cgi?filename=foomatic-rip&amp;show=0">foomatic-rip</ulink>.
4229 This single script is the unification of the previously different
4230 spooler-specific *omatic scripts. foomatic-rip is used by all the
4231 different spoolers alike. Because foomatic-rip can read PPDs (both the
4232 original PostScript printer PPDs and the Linuxprinting.org-generated
4233 ones), all of a sudden all supported spoolers can have the power of
4234 PPDs at their disposal; users only need to plug "foomatic-rip" into
4235 their system.... For users there is improved media type and source
4236 support; paper sizes and trays are easier to configure.
4237 </para>
4239 <para>
4240 Also, the New Generation of Linuxprinting.org PPDs doesn't contain
4241 Perl data structures any more. If you are a distro maintainer and have
4242 used the previous version of Foomatic, you may want to give the new
4243 one a spin: but don't forget to generate a new-version set of PPDs,
4244 via the new <ulink
4245 url="http://www.linuxprinting.org/download/foomatic/foomatic-db-engine-3.0.0beta1.tar.gz">foomatic-db-engine</ulink>!
4246 Individual users just need to generate a single new PPD specific to
4247 their model by <ulink
4248 url="http://www.linuxprinting.org/kpfeifle/LinuxKongress2002/Tutorial/II.Foomatic-User/II.tutorial-handout-foomatic-user.html">following
4249 the steps</ulink> outlined in the Foomatic tutorial or further
4250 below. This new development is truly amazing.
4251 </para>
4253 <para>
4254 foomatic-rip is a very clever wrapper around the need to run
4255 Ghostscript with a different syntax, different options, different
4256 device selections and/or different filters for each different printer
4257 or different spooler. At the same time it can read the PPD associated
4258 with a print queue and modify the print job according to the user
4259 selections. Together with this comes the 100% compliance of the new
4260 Foomatic PPDs with the Adobe spec. Some really innovative features of
4261 the Foomatic concept will surprise users: it will support custom paper
4262 sizes for many printers; and it will support printing on media drawn
4263 from different paper trays within the same job (in both cases: even
4264 where there is no support for this from Windows-based vendor printer
4265 drivers).
4266 </para>
4267 </sect3>
4269 <sect3>
4270 <title>Driver Development outside</title>
4272 <para>
4273 Most driver development itself does not happen within
4274 Linuxprinting.org. Drivers are written by independent maintainers.
4275 Linuxprinting.org just pools all the information, and stores it in its
4276 database. In addition, it also provides the Foomatic glue to integrate
4277 the many drivers into any modern (or legacy) printing system known to
4278 the world.
4279 </para>
4281 <para>
4282 Speaking of the different driver development groups: most of
4283 the work is currently done in three projects. These are:
4284 </para>
4286 <itemizedlist>
4287 <listitem><para><ulink
4288 url="http://www-124.ibm.com/developerworks/oss/linux/projects/omni/">Omni</ulink>
4289 -- a Free Software project by IBM which tries to convert their printer
4290 driver knowledge from good-ol' OS/2 times into a modern, modular,
4291 universal driver architecture for Linux/UNIX (still Beta).  This
4292 currently supports 437 models.</para></listitem>
4294 <listitem><para><ulink url="http://hpinkjet.sf.net/">HPIJS</ulink> --
4295 a Free Software project by HP to provide the support for their own
4296 range of models (very mature, printing in most cases is perfect and
4297 provides true photo quality). This currently supports 369
4298 models.</para></listitem>
4300 <listitem><para><ulink
4301 url="http://gimp-print.sf.net/">Gimp-Print</ulink> -- a Free software
4302 effort, started by Michael Sweet (also lead developer for CUPS), now
4303 directed by Robert Krawitz, which has achieved an amazing level of
4304 photo print quality (many Epson users swear that its quality is
4305 better than the vendor drivers provided by Epson for the Microsoft
4306 platforms). This currently supports 522 models.</para></listitem>
4307 </itemizedlist>
4308 </sect3>
4310 <sect3>
4311 <title>Forums, Downloads, Tutorials, Howtos -- also for Mac OS X and
4312 commercial UNIX</title>
4314 <para>
4315 Linuxprinting.org today is the one-stop "shop" to download printer
4316 drivers. Look for printer information and <ulink
4317 url="http://www.linuxprinting.org//kpfeifle/LinuxKongress2002/Tutorial/">tutorials</ulink>
4318 or solve printing problems in its popular <ulink
4319 url="http://www.linuxprinting.org/newsportal/">forums</ulink>.  But
4320 it's not just for GNU/Linux: users and admins of <ulink
4321 url="http://www.linuxprinting.org/macosx/">commercial UNIX
4322 systems</ulink> are also going there, and the relatively new <ulink
4323 url="http://www.linuxprinting.org/newsportal/thread.php3?name=linuxprinting.macosx.general">Mac
4324 OS X forum</ulink> has turned out to be one of the most frequented
4325 fora after only a few weeks.
4326 </para>
4328 <para>
4329 Linuxprinting.org and the Foomatic driver wrappers around Ghostscript
4330 are now a standard toolchain for printing on all the important
4331 distros. Most of them also have CUPS underneath. While in recent years
4332 most printer data had been added by Till (who works at Mandrake), many
4333 additional contributions came from engineers with SuSE, RedHat,
4334 Connectiva, Debian and others. Vendor-neutrality is an important goal
4335 of the Foomatic project.
4336 </para>
4338 <note><para>
4339 Till Kamppeter from MandrakeSoft is doing an excellent job in his
4340 spare time to maintain Linuxprinting.org and Foomatic. So if you use
4341 it often, please send him a note showing your appreciation.
4342 </para></note>
4343 </sect3>
4345 <sect3>
4346 <title>Foomatic Database generated PPDs</title>
4348 <para>
4349 The Foomatic database is an amazing piece of ingenuity in itself. Not
4350 only does it keep the printer and driver information, but it is
4351 organized in a way that it can generate "PPD" files "on the fly" from
4352 its internal XML-based datasets. While these PPDs are modelled to the
4353 Adobe specification of "PostScript Printer Descriptions" (PPDs), the
4354 Linuxprinting.org/Foomatic-PPDs don't normally drive PostScript
4355 printers: they are used to describe all the bells and whistles you
4356 could ring or blow on an Epson Stylus inkjet, or a HP Photosmart or
4357 what-have-you. The main "trick" is one little additional line, not
4358 envisaged by the PPD specification, starting with the "*cupsFilter"
4359 keyword: it tells the CUPS daemon how to proceed with the PostScript
4360 print file (old-style Foomatic-PPDs named the
4361 <emphasis>cupsomatic</emphasis> filter script, while the new-style
4362 PPDs now call <emphasis>foomatic-rip</emphasis>). This filter
4363 script calls Ghostscript on the host system (the recommended variant
4364 is ESP Ghostscript) to do the rendering work. foomatic-rip knows which
4365 filter or internal device setting it should ask from Ghostscript to
4366 convert the PostScript printjob into a raster format ready for the
4367 target device. This usage of PPDs to describe the options of non-PS
4368 printers was the invention of the CUPS developers. The rest is easy:
4369 GUI tools (like KDE's marvellous <ulink
4370 url="http://printing.kde.org/overview/kprinter.phtml">"kprinter"</ulink>,
4371 or the GNOME <ulink
4372 url="http://gtklp.sourceforge.net/">"gtklp"</ulink>, "xpp" and the CUPS
4373 web interface) read the PPD too and use this information to present
4374 the available settings to the user as an intuitive menu selection.
4375 </para>
4376 </sect3>
4377 </sect2>
4379 <sect2>
4380 <title>foomatic-rip and Foomatic-PPD Download and Installation</title>
4382 <para>
4383 Here are the steps to install a foomatic-rip driven "LaserJet 4 Plus"
4384 compatible printer in CUPS (note that recent distributions of SuSE,
4385 UnitedLinux and Mandrake may ship with a complete package of
4386 Foomatic-PPDs plus the foomatic-rip utility.  going directly to
4387 Linuxprinting.org ensures you to get the latest driver/PPD files):
4388 </para>
4389 <itemizedlist>
4390 <listitem><para>Surf to <ulink
4391 noescape="1" url="http://www.linuxprinting.org/printer_list.cgi">http://www.linuxprinting.org/printer_list.cgi</ulink>
4392 </para></listitem>
4394 <listitem><para>Check the complete list of printers in the database:
4395 <ulink noescape="1" 
4396 url="http://www.linuxprinting.org/printer_list.cgi?make=Anyone">http://www.linuxprinting.org/printer_list.cgi?make=Anyone</ulink>
4397 </para></listitem>
4399 <listitem><para>There select your model and click on the
4400 link.</para></listitem>
4402 <listitem><para>You'll arrive at a page listing all drivers working
4403 with this model (for all printers, there will always be
4404 <emphasis>one</emphasis> recommended driver. Try this one
4405 first).</para></listitem>
4407 <listitem><para>In our case ("HP LaserJet 4 Plus"), we'll arrive here:
4408                 <ulink noescape="1"
4409 url="http://www.linuxprinting.org/show_printer.cgi?recnum=HP-LaserJet_4_Plus">http://www.linuxprinting.org/show_printer.cgi?recnum=HP-LaserJet_4_Plus</ulink>
4410 </para></listitem>
4412 <listitem><para>The recommended driver is "ljet4".</para></listitem>
4414 <listitem><para>There are several links provided here. You should
4415 visit them all, if you are not familiar with the Linuxprinting.org
4416 database.</para></listitem>
4418 <listitem><para>There is a link to the database page for the "ljet4":
4419                 <ulink noescape="1"
4420 url="http://www.linuxprinting.org/show_driver.cgi?driver=ljet4">http://www.linuxprinting.org/show_driver.cgi?driver=ljet4</ulink>
4421 On the driver's page, you'll find important and detailed information
4422 about how to use that driver within the various available
4423 spoolers.</para></listitem>
4425 <listitem><para>Another link may lead you to the homepage of the
4426 driver author or the driver.</para></listitem>
4428 <listitem><para>Important links are the ones which provide hints with
4429 setup instructions for CUPS (<ulink noescape="1"
4430 url="http://www.linuxprinting.org/cups-doc.html">http://www.linuxprinting.org/cups-doc.html</ulink>),
4431 PDQ (<ulink noescape="1"
4432 url="http://www.linuxprinting.org/pdq-doc.html">http://www.linuxprinting.org/pdq-doc.html</ulink>),
4433 LPD, LPRng and GNUlpr (<ulink noescape="1"
4434 url="http://www.linuxprinting.org/lpd-doc.html">http://www.linuxprinting.org/lpd-doc.html</ulink>)
4435 as well as PPR (<ulink noescape="1"
4436 url="http://www.linuxprinting.org/ppr-doc.html">http://www.linuxprinting.org/ppr-doc.html)</ulink>
4437 or "spooler-less" printing (<ulink noescape="1"
4438 url="http://www.linuxprinting.org/direct-doc.html">http://www.linuxprinting.org/direct-doc.html</ulink>
4439 ).</para></listitem>
4441 <listitem><para>You can view the PPD in your browser through this
4442 link: <ulink noescape="1"
4443 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>
4444 </para></listitem> <listitem><para>You can also (most importantly)
4445 generate and download the PPD: <ulink noescape="1"
4446 url="http://www.linuxprinting.org/ppd-o-matic.cgi?driver=ljet4&amp;printer=HP-LaserJet_4_Plus&amp;show=0">http://www.linuxprinting.org/ppd-o-matic.cgi?driver=ljet4&amp;printer=HP-LaserJet_4_Plus&amp;show=0</ulink>
4447 </para></listitem>
4449 <listitem><para>The PPD contains all the information needed to use our
4450 model and the driver; this is, once installed, working transparently
4451 for the user. Later you'll only need to choose resolution, paper size
4452 etc. from the web-based menu, or from the print dialog GUI, or from
4453 the commandline.</para></listitem>
4455 <listitem><para>Should you have ended up on the driver's page (<ulink noescape="1"
4456 url="http://www.linuxprinting.org/show_driver.cgi?driver=ljet4">http://www.linuxprinting.org/show_driver.cgi?driver=ljet4</ulink>),
4457 you can choose to use the "PPD-O-Matic" online PPD generator
4458 program.</para></listitem>
4460 <listitem><para>Select the exact model and check either "download" or
4461 "display PPD file" and click on "Generate PPD file".</para></listitem>
4463 <listitem><para>If you save the PPD file from the browser view, please
4464 don't use "cut'n'past" (since it could possibly damage line endings
4465 and tabs, which makes the PPD likely to fail its duty), but use "Save
4466 as..." in your browser's menu. (Best is to use the "download" option
4467 from the web page directly).</para></listitem>
4469 <listitem><para>Another very interesting part on each driver page is
4470 the <emphasis>Show execution details</emphasis> button. If you
4471 select your printer model and click that button, you will get
4472 displayed a complete Ghostscript command line, enumerating all options
4473 available for that driver/printermodel combo. This is a great way to
4474 "Learn Ghostscript By Doing". It is also an excellent "cheat sheet"
4475 for all experienced users who need to re-construct a good command line
4476 for that damn printing script, but can't remember the exact
4477 syntax. ;-)</para></listitem>
4479 <listitem><para>Some time during your visit to Linuxprinting.org, save
4480 the PPD to a suitable place on your harddisk, say
4481 <filename>/path/to/my-printer.ppd</filename> (if you prefer to install
4482 your printers with the help of the CUPS web interface, save the PPD to
4483 the <filename>/usr/share/cups/model/</filename> path and re-start
4484 cupsd).</para></listitem>
4486 <listitem><para>Then install the printer with a suitable commandline,
4487 e.g.: 
4488 </para>
4490 <para><screen>
4491 &rootprompt;<userinput>lpadmin -p laserjet4plus -v parallel:/dev/lp0 -E -P path/to/my-printer.ppd</userinput>
4492 </screen></para></listitem>
4494 <listitem><para>Note again this: for all the new-style "Foomatic-PPDs"
4495 from Linuxprinting.org, you also need a special "CUPS filter" named
4496 "foomatic-rip".Get the latest version of "foomatic-rip" from: <ulink noescape="1"
4497 url="http://www.linuxprinting.org/foomatic2.9/download.cgi?filename=foomatic-rip&amp;show=0">http://www.linuxprinting.org/foomatic2.9/download.cgi?filename=foomatic-rip&amp;show=0</ulink>
4498 </para></listitem>
4500 <listitem><para>The foomatic-rip Perlscript itself also makes some
4501 interesting reading (<ulink noescape="1"
4502 url="http://www.linuxprinting.org/foomatic2.9/download.cgi?filename=foomatic-rip&amp;show=1">http://www.linuxprinting.org/foomatic2.9/download.cgi?filename=foomatic-rip&amp;show=1</ulink>),
4503 because it is very well documented by Till's inline comments (even
4504 non-Perl hackers will learn quite a bit about printing by reading
4505 it... ;-)</para></listitem>
4507 <listitem><para>Save foomatic-rip either directly in
4508 <filename>/usr/lib/cups/filter/foomatic-rip</filename> or somewhere in
4509 your $PATH (and don't forget to make it world-executable). Again,
4510 don't save by "copy'n'paste" but use the appropriate link, or the
4511 "Save as..."  menu item in your browser.</para></listitem>
4513 <listitem><para>If you save foomatic-rip in your $PATH, create a symlink:
4514 <command>cd /usr/lib/cups/filter/ ; ln -s `which
4515 foomatic-rip`</command>. For CUPS to discover this new
4516 available filter at startup, you need to re-start
4517 cupsd.</para></listitem>
4518 </itemizedlist>
4520 <para>
4521 Once you print to a printqueue set up with the Foomatic-PPD, CUPS will
4522 insert the appropriate commands and comments into the resulting
4523 PostScript jobfile. foomatic-rip is able to read and act upon
4524 these. foomatic-rip uses some specially encoded Foomatic comments,
4525 embedded in the jobfile. These in turn are used to construct
4526 (transparently for you, the user) the complicated ghostscript command
4527 line telling for the printer driver how exactly the resulting raster
4528 data should look like and which printer commands to embed into the
4529 data stream.
4530 </para>
4532 <para>
4533 You need:
4534 </para>
4536 <itemizedlist>
4538 <listitem><para>A "foomatic+something" PPD -- but it this not enough
4539 to print with CUPS (it is only <emphasis>one</emphasis> important
4540 component)</para></listitem>
4542 <listitem><para>The "foomatic-rip" filter script (Perl) in
4543 /usr/lib/cups/filters/</para></listitem>
4545 <listitem><para>Perl to make foomatic-rip run</para></listitem>
4547 <listitem><para>Ghostscript (because it is doing the main work,
4548 controlled by the PPD/foomatic-rip combo) to produce the raster data
4549 fit for your printermodel's consumption</para></listitem>
4551 <listitem><para>Ghostscript <emphasis>must</emphasis> (depending on
4552 the driver/model) contain support for a certain "device", representing
4553 the selected "driver" for your model (as shown by "gs
4554 -h")</para></listitem>
4556 <listitem><para>foomatic-rip needs a new version of PPDs (PPD versions
4557 produced for cupsomatic don't work with
4558 foomatic-rip).</para></listitem>
4559 </itemizedlist>
4560 </sect2>
4561 </sect1>
4563 <sect1>
4564 <title>Page Accounting with CUPS</title>
4567 <indexterm><primary>CUPS</primary><secondary>Page Accounting</secondary></indexterm>
4568 <para>
4569 Often there are questions regarding "print quotas" wherein Samba users
4570 (that is, Windows clients) should not be able to print beyond a
4571 certain amount of pages or data volume per day, week or month. This
4572 feature is dependent on the real print subsystem you're using.
4573 Samba's part is always to receive the job files from the clients
4574 (filtered <emphasis>or</emphasis> unfiltered) and hand it over to this
4575 printing subsystem.
4576 </para>
4578 <para>
4579 Of course one could "hack" things with one's own scripts. But then
4580 there is CUPS. CUPS supports "quotas" which can be based on sizes of
4581 jobs or on the number of pages or both, and are spanning any time
4582 period you want.
4583 </para>
4585 <sect2>
4586 <title>Setting up Quotas</title>
4588 <indexterm><primary>CUPS</primary><secondary>quotas</secondary></indexterm>
4589 <para>
4590 This is an example command how root would set a print quota in CUPS,
4591 assuming an existing printer named "quotaprinter":
4592 </para>
4594 <indexterm><primary>lpadmin</primary></indexterm>
4596 <para><screen>
4597 &rootprompt;<userinput>lpadmin -p quotaprinter -o job-quota-period=604800 \
4598         -o job-k-limit=1024 -o job-page-limit=100</userinput>
4599 </screen></para>
4601 <para>
4602 This would limit every single user to print 100 pages or 1024 KB of
4603 data (whichever comes first) within the last 604,800 seconds ( = 1
4604 week).
4605 </para>
4606 </sect2>
4608 <sect2>
4609 <title>Correct and incorrect Accounting</title>
4611 <para>
4612 For CUPS to count correctly, the printfile needs to pass the CUPS
4613 "pstops" filter, otherwise it uses a "dummy" count of "1".  Some
4614 printfiles don't pass it (eg: image files) but then those are mostly 1
4615 page jobs anyway. This also means that proprietary drivers for the
4616 target printer running on the client computers and CUPS/Samba, which
4617 then spool these files as "raw" (i.e. leaving them untouched, not
4618 filtering them), will be counted as "1-pagers" too!
4619 </para>
4621 <para>
4622 You need to send PostScript from the clients (i.e. run a PostScript
4623 driver there) to have the chance to get accounting done. If the
4624 printer is a non-PostScript model, you need to let CUPS do the job to
4625 convert the file to a print-ready format for the target printer. This
4626 will be working for currently about 1,000 different printer models,
4627 see <ulink
4628         url="http://www.linuxprinting.org/printer_list.cgi">the driver list at linuxprinting.org/</ulink>.
4629 </para>
4630 </sect2>
4632 <sect2>
4633 <title>Adobe and CUPS PostScript Drivers for Windows Clients</title>
4635 <para>
4636 Before CUPS-1.1.16 your only option was to use the Adobe PostScript
4637 Driver on the Windows clients. The output of this driver was not
4638 always passed through the "pstops" filter on the CUPS/Samba side, and
4639 therefore was not counted correctly (the reason is that it often,
4640 depending on the "PPD" being used, wrote a "PJL"-header in front of
4641 the real PostScript which caused CUPS to skip pstops and go directly
4642 to the "pstoraster" stage).
4643 </para>
4645 <para>
4646 From CUPS-1.1.16 onward you can use the "CUPS PostScript Driver for
4647 Windows NT/2K/XP clients" (which is tagged in the download area of
4648 http://www.cups.org/ as the "cups-samba-1.1.16.tar.gz" package). It does
4649 <emphasis>not</emphasis> work for Win9x/ME clients. But it guarantees:
4650 </para>
4652 <itemizedlist>
4653 <indexterm><primary>PJL</primary></indexterm>
4655 <listitem><para>to not write an PJL-header</para></listitem>
4657 <listitem><para>to still read and support all PJL-options named in the
4658 driver PPD with its own means</para></listitem>
4660 <listitem><para> that the file will pass through the "pstops" filter
4661 on the CUPS/Samba server</para></listitem>
4663 <listitem><para>to page-count correctly the
4664 printfile</para></listitem>
4665 </itemizedlist>
4667 <para>
4668 You can read more about the setup of this combination in the manpage
4669 for "cupsaddsmb" (which is only present with CUPS installed, and only
4670 current from CUPS 1.1.16).
4671 </para>
4672 </sect2>
4674 <sect2>
4675 <title>The page_log File Syntax</title>
4677 <indexterm><primary>page_log</primary></indexterm>
4678 <para>
4679 These are the items CUPS logs in the "page_log" for every
4680 single <emphasis>page</emphasis> of a job:
4681 </para>
4683 <itemizedlist>
4684 <listitem><para>Printer name</para></listitem>
4686 <listitem><para>User name</para></listitem>
4688 <listitem><para>Job ID</para></listitem>
4690 <listitem><para>Time of printing</para></listitem>
4692 <listitem><para>the page number</para></listitem>
4694 <listitem><para>the number of copies</para></listitem>
4696 <listitem><para>a billing information string
4697 (optional)</para></listitem>
4699 <listitem><para>the host which sent the job (included since version
4700 1.1.19)</para></listitem>
4701 </itemizedlist>
4703 <para>
4704 Here is an extract of my CUPS server's page_log file to illustrate the
4705 format and included items:
4706 </para>
4708 <para><screen>
4709 infotec_IS2027 kurt 401 [22/Apr/2003:10:28:43 +0100] 1 3 #marketing 10.160.50.13
4710 infotec_IS2027 kurt 401 [22/Apr/2003:10:28:43 +0100] 2 3 #marketing 10.160.50.13
4711 infotec_IS2027 kurt 401 [22/Apr/2003:10:28:43 +0100] 3 3 #marketing 10.160.50.13
4712 infotec_IS2027 kurt 401 [22/Apr/2003:10:28:43 +0100] 4 3 #marketing 10.160.50.13
4713 DigiMaster9110 boss 402 [22/Apr/2003:10:33:22 +0100] 1 440 finance-dep 10.160.51.33
4714 </screen></para>
4716 <para>
4717 This was job ID "401", printed on "infotec_IS2027" by user "kurt", a
4718 64-page job printed in 3 copies and billed to "#marketing", sent
4719 from IP address 10.160.50.13. The next job had ID "402", was sent by
4720 user "boss" from IP address 10.160.51.33,printed from one page 440
4721 copies and is set to be billed to "finance-dep".
4722 </para>
4723 </sect2>
4725 <sect2>
4726 <title>Possible Shortcomings</title>
4728 <para>
4729 What flaws or shortcomings are there with this quota system?
4730 </para>
4732 <itemizedlist>
4733 <listitem><para>the ones named above (wrongly logged job in case of
4734 printer hardware failure, etc.)</para></listitem>
4736 <listitem><para>in reality, CUPS counts the job pages that are being
4737 processed in <emphasis>software</emphasis> (that is, going through the
4738 "RIP") rather than the physical sheets successfully leaving the
4739 printing device. Thus if there is a jam while printing the 5th sheet out
4740 of 1000 and the job is aborted by the printer, the "page count" will
4741 still show the figure of 1000 for that job</para></listitem>
4743 <listitem><para>all quotas are the same for all users (no flexibility
4744 to give the boss a higher quota than the clerk), no support for
4745 groups</para></listitem>
4747 <listitem><para>no means to read out the current balance or the
4748 "used-up" number of current quota</para></listitem>
4750 <listitem><para>a user having used up 99 sheets of 100 quota will
4751 still be able to send and print a 1,000 sheet job</para></listitem>
4753 <listitem><para>a user being denied a job because of a filled-up quota
4754 doesn't get a meaningful error message from CUPS other than
4755 "client-error-not-possible".</para></listitem>
4756 </itemizedlist>
4757 </sect2>
4759 <sect2>
4760 <title>Future Developments</title>
4762 <para>
4763 This is the best system currently available, and there are huge
4764 improvements under development for CUPS 1.2:
4765 </para>
4767 <itemizedlist>
4768 <listitem><para>page counting will go into the "backends" (these talk
4769 directly to the printer and will increase the count in sync with the
4770 actual printing process: thus a jam at the 5th sheet will lead to a
4771 stop in the counting)</para></listitem>
4773 <listitem><para>quotas will be handled more flexibly</para></listitem>
4775 <listitem><para>probably there will be support for users to inquire
4776 their "accounts" in advance</para></listitem>
4778 <listitem><para>probably there will be support for some other tools
4779 around this topic</para></listitem>
4780 </itemizedlist>
4781 </sect2>
4783 <sect2>
4784 <title>Other Accounting Tools</title>
4786 <para>
4787 PrintAnalyzer, pyKota, printbill, LogReport.
4788 </para>
4789 </sect2>
4790 </sect1>
4792 <sect1>
4793 <title>Additional Material</title>
4795 <para>
4796 A printer queue with <emphasis>no</emphasis> PPD associated to it is a
4797 "raw" printer and all files will go directly there as received by the
4798 spooler. The exceptions are file types "application/octet-stream"
4799 which need "passthrough feature" enabled. "Raw" queues don't do any
4800 filtering at all, they hand the file directly to the CUPS backend.
4801 This backend is responsible for the sending of the data to the device
4802 (as in the "device URI" notation: <filename>lpd://, socket://,
4803 smb://, ipp://, http://, parallel:/, serial:/, usb:/</filename> etc.)
4804 </para>
4806 <para>
4807 "cupsomatic"/Foomatic are <emphasis>not</emphasis> native CUPS drivers
4808 and they don't ship with CUPS. They are a Third Party add-on,
4809 developed at Linuxprinting.org. As such, they are a brilliant hack to
4810 make all models (driven by Ghostscript drivers/filters in traditional
4811 spoolers) also work via CUPS, with the same (good or bad!) quality as
4812 in these other spoolers. "cupsomatic" is only a vehicle to execute a
4813 ghostscript commandline at that stage in the CUPS filtering chain,
4814 where "normally" the native CUPS "pstoraster" filter would kick
4815 in. cupsomatic by-passes pstoraster, "kidnaps" the printfile from CUPS
4816 away and re-directs it to go through Ghostscript. CUPS accepts this,
4817 because the associated CUPS-O-Matic-/Foomatic-PPD specifies:
4818 </para>
4820 <para><programlisting>
4821   *cupsFilter:  "application/vnd.cups-postscript 0 cupsomatic"
4822 </programlisting></para>
4824 <para>
4825 This line persuades CUPS to hand the file to cupsomatic, once it has
4826 successfully converted it to the MIME type
4827 "application/vnd.cups-postscript". This conversion will not happen for
4828 Jobs arriving from Windows which are auto-typed
4829 "application/octet-stream", with the according changes in
4830 <filename>/etc/cups/mime.types</filename> in place.
4831 </para>
4833 <para>
4834 CUPS is widely configurable and flexible, even regarding its filtering
4835 mechanism. Another workaround in some situations would be to have in
4836 <filename>/etc/cups/mime.types</filename> entries as follows:
4837 </para>
4839 <para><programlisting>
4840  application/postscript           application/vnd.cups-raw  0  -
4841  application/vnd.cups-postscript  application/vnd.cups-raw  0  -
4842 </programlisting></para>
4844 <para>
4845 This would prevent all Postscript files from being filtered (rather,
4846 they will through the virtual <emphasis>nullfilter</emphasis>
4847 denoted with "-").  This could only be useful for PS printers. If you
4848 want to print PS code on non-PS printers (provided they support ASCII
4849 text printing) an entry as follows could be useful:
4850 </para>
4852 <para><programlisting>
4853  */*           application/vnd.cups-raw  0  -
4854 </programlisting></para>
4856 <para>
4857 and would effectively send <emphasis>all</emphasis> files to the
4858 backend without further processing.
4859 </para>
4861 <para>
4862 Lastly, you could have the following entry:
4863 </para>
4865 <para><programlisting>
4866 application/vnd.cups-postscript application/vnd.cups-raw 0 my_PJL_stripping_filter
4867 </programlisting></para>
4869 <para>
4870 You will need to write a <emphasis>my_PJL_stripping_filter</emphasis>
4871 (could be a shellscript) that parses the PostScript and removes the
4872 unwanted PJL. This would need to conform to CUPS filter design
4873 (mainly, receive and pass the parameters printername, job-id,
4874 username, jobtitle, copies, print options and possibly the
4875 filename). It would be installed as world executable into
4876 <filename>/usr/lib/cups/filters/</filename> and will be called by CUPS
4877 if it encounters a MIME type "application/vnd.cups-postscript".
4878 </para>
4880 <para>
4881 CUPS can handle <emphasis>-o job-hold-until=indefinite</emphasis>.
4882 This keeps the job in the queue "on hold". It will only be printed
4883 upon manual release by the printer operator. This is a requirement in
4884 many "central reproduction departments", where a few operators manage
4885 the jobs of hundreds of users on some big machine, where no user is
4886 allowed to have direct access (such as when the operators often need
4887 to load the proper paper type before running the 10,000 page job
4888 requested by marketing for the mailing, etc.).
4889 </para>
4890 </sect1>
4892 <sect1>
4893 <title>Auto-Deletion or Preservation of CUPS Spool Files</title>
4895 <para>
4896 Samba print files pass through two "spool" directories. One is the
4897 incoming directory managed by Samba, (set in the <smbconfoption><name>path</name><value>/var/spool/samba</value></smbconfoption> directive in the
4898 <smbconfsection>[printers]</smbconfsection> section of
4899 &smb.conf;). The other is the spool directory of
4900 your UNIX print subsystem. For CUPS it is normally
4901 <filename>/var/spool/cups/</filename>, as set by the cupsd.conf
4902 directive <filename>RequestRoot /var/spool/cups</filename>.
4903 </para>
4905 <sect2>
4906 <title>CUPS Configuration Settings explained</title>
4908 <para>
4909 Some important parameter settings in the CUPS configuration file
4910 <filename>cupsd.conf</filename> are:
4911 </para>
4913 <variablelist>
4915 <varlistentry><term>PreserveJobHistory Yes</term>
4916 <listitem><para>
4917 This keeps some details of jobs in cupsd's mind (well it keeps the
4918 "c12345", "c12346" etc. files in the CUPS spool directory, which do a
4919 similar job as the old-fashioned BSD-LPD control files). This is set
4920 to "Yes" as a default.
4921 </para></listitem></varlistentry>
4923 <varlistentry><term>PreserveJobFiles Yes</term>
4924 <listitem><para>
4925 This keeps the job files themselves in cupsd's mind
4926 (well it keeps the "d12345", "d12346" etc. files in the CUPS spool
4927 directory...). This is set to "No" as the CUPS
4928 default.
4929 </para></listitem></varlistentry>
4931 <varlistentry><term><emphasis>"MaxJobs 500"</emphasis></term>
4932 <listitem><para>
4933 This directive controls the maximum number of jobs
4934 that are kept in memory. Once the number of jobs reaches the limit,
4935 the oldest completed job is automatically purged from the system to
4936 make room for the new one. If all of the known jobs are still
4937 pending or active then the new job will be rejected. Setting the
4938 maximum to 0 disables this functionality. The default setting is
4940 </para></listitem></varlistentry>
4941 </variablelist>
4943 <para>
4944 (There are also additional settings for "MaxJobsPerUser" and
4945 "MaxJobsPerPrinter"...)
4946 </para>
4947 </sect2>
4949 <sect2>
4950 <title>Pre-conditions</title>
4952 <para>
4953 For everything to work as announced, you need to have three
4954 things:
4955 </para>
4957 <itemizedlist>
4958 <listitem><para>a Samba-smbd which is compiled against "libcups" (Check
4959 on Linux by running "ldd `which smbd`")</para></listitem>
4961 <listitem><para>a Samba-&smb.conf; setting of
4962                 <smbconfoption><name>printing</name><value>cups</value></smbconfoption></para></listitem>
4964 <listitem><para>another Samba-&smb.conf; setting of
4965                 <smbconfoption><name>printcap</name><value>cups</value></smbconfoption></para></listitem>
4966 </itemizedlist>
4968 <note><para>
4969 In this case all other manually set printing-related commands (like
4970 <smbconfoption><name>print command</name></smbconfoption>, 
4971 <smbconfoption><name>lpq command</name></smbconfoption>, 
4972 <smbconfoption><name>lprm command</name></smbconfoption>, 
4973 <smbconfoption><name>lppause command</name></smbconfoption> or
4974 <smbconfoption><name>lpresume command</name></smbconfoption>) are ignored and they should normally have no
4975 influence what-so-ever on your printing.
4976 </para></note>
4977 </sect2>
4979 <sect2>
4980 <title>Manual Configuration</title>
4982 <para>
4983 If you want to do things manually, replace the <smbconfoption><name>printing</name><value>cups</value></smbconfoption>
4984 by <smbconfoption><name>printing</name><value>bsd</value></smbconfoption>. Then your manually set commands may work
4985 (haven't tested this), and a <smbconfoption><name>print command</name><value>lp -d %P %s; rm %s"</value></smbconfoption>
4986 may do what you need.
4987 </para>
4988 </sect2>
4989 </sect1>
4991 <sect1>
4992 <title>In Case of Trouble.....</title>
4994 <para>
4995 If you have more problems, post the output of these commands
4996 to the CUPS or Samba mailing lists (choose the one which seems more
4997 relevant to your problem):
4998 </para>
5000 <para><screen>
5001 &prompt;<userinput>grep -v ^# /etc/cups/cupsd.conf | grep -v ^$</userinput>
5002 &prompt;<userinput>grep -v ^# /etc/samba/smb.conf | grep -v ^$ | grep -v "^;"</userinput>
5003 </screen></para>
5005 <para>
5006 (adapt paths as needed). These commands leave out the empty
5007 lines and lines with comments, providing the "naked settings" in a
5008 compact way. Don't forget to name the CUPS and Samba versions you
5009 are using! This saves bandwidth and makes for easier readability
5010 for experts (and you are expecting experts to read them, right?
5012 </para>
5014 </sect1>
5016 <sect1>
5017 <title>Printing <emphasis>from</emphasis> CUPS to Windows attached
5018 Printers</title>
5020 <para>
5021 From time to time the question arises, how you can print
5022 <emphasis>to</emphasis> a Windows attached printer
5023 <emphasis>from</emphasis> Samba. Normally the local connection
5024 from Windows host to printer would be done by USB or parallel
5025 cable, but this doesn't matter to Samba. From here only an SMB
5026 connection needs to be opened to the Windows host. Of course, this
5027 printer must be "shared" first. As you have learned by now, CUPS uses
5028 <emphasis>backends</emphasis> to talk to printers and other
5029 servers. To talk to Windows shared printers you need to use the
5030 <emphasis>smb</emphasis> (surprise, surprise!) backend. Check if this
5031 is in the CUPS backend directory. This resides usually in
5032 <filename>/usr/lib/cups/backend/</filename>. You need to find a "smb"
5033 file there. It should be a symlink to <filename>smbspool</filename>
5034 which file must exist and be executable:
5035 </para>
5037 <para><screen>
5038 &rootprompt;<userinput>ls -l /usr/lib/cups/backend/</userinput>
5039 total 253
5040 drwxr-xr-x    3 root     root          720 Apr 30 19:04 .
5041 drwxr-xr-x    6 root     root          125 Dec 19 17:13 ..
5042 -rwxr-xr-x    1 root     root        10692 Feb 16 21:29 canon
5043 -rwxr-xr-x    1 root     root        10692 Feb 16 21:29 epson
5044 lrwxrwxrwx    1 root     root            3 Apr 17 22:50 http -&gt; ipp
5045 -rwxr-xr-x    1 root     root        17316 Apr 17 22:50 ipp
5046 -rwxr-xr-x    1 root     root        15420 Apr 20 17:01 lpd
5047 -rwxr-xr-x    1 root     root         8656 Apr 20 17:01 parallel
5048 -rwxr-xr-x    1 root     root         2162 Mar 31 23:15 pdfdistiller
5049 lrwxrwxrwx    1 root     root           25 Apr 30 19:04 ptal -&gt; /usr/sbin/ptal-cups
5050 -rwxr-xr-x    1 root     root         6284 Apr 20 17:01 scsi
5051 lrwxrwxrwx    1 root     root           17 Apr  2 03:11 smb -&gt; /usr/bin/smbspool
5052 -rwxr-xr-x    1 root     root         7912 Apr 20 17:01 socket
5053 -rwxr-xr-x    1 root     root         9012 Apr 20 17:01 usb
5055 &rootprompt;<userinput>ls -l `which smbspool`</userinput>
5056 -rwxr-xr-x    1 root     root       563245 Dec 28 14:49 /usr/bin/smbspool
5057 </screen></para>
5059 <para>
5060 If this symlink doesn't exist, create it:
5061 </para>
5063 <para><screen>
5064 &rootprompt;<userinput>ln -s `which smbspool` /usr/lib/cups/backend/smb</userinput>
5065 </screen></para>
5067 <para>
5068 smbspool has been written by Mike Sweet from the CUPS folks.  It is
5069 included and ships with Samba. It may also be used with print
5070 subsystems other than CUPS, to spool jobs to Windows printer shares. To
5071 set up printer "winprinter" on CUPS, you need to have a "driver" for
5072 it. Essentially this means to convert the print data on the CUPS/Samba
5073 host to a format that the printer can digest (the Windows host is
5074 unable to convert any files you may send).  This also means you should
5075 be able to print to the printer if it were hooked directly at your
5076 Samba/CUPS host. For troubleshooting purposes, this is what you
5077 should do, to determine if that part of the process chain is in
5078 order. Then proceed to fix the network connection/authentication to
5079 the Windows host, etc.
5080 </para>
5082 <para>
5083 To install a printer with the smb backend on CUPS, use this command:
5084 </para>
5086 <para><screen>
5087 &rootprompt;<userinput>lpadmin -p winprinter -v smb://WINDOWSNETBIOSNAME/printersharename \
5088   -P /path/to/PPD</userinput>
5089 </screen></para>
5091 <para>
5092 The <emphasis>PPD</emphasis> must be able to direct CUPS to generate
5093 the print data for the target model. For PostScript printers just use
5094 the PPD that would be used with the Windows NT PostScript driver. But
5095 what can you do if the printer is only accessible with a password? Or
5096 if the printer's host is part of another workgroup? This is provided
5097 for: you can include the required parameters as part of the
5098 <filename>smb://</filename> device-URI. Like this:
5099 </para>
5101 <itemizedlist>
5102         <listitem><para>smb://WORKGROUP/WINDOWSNETBIOSNAME/printersharename </para></listitem>
5103         <listitem><para>smb://username:password@WORKGROUP/WINDOWSNETBIOSNAME/printersharename</para></listitem>
5104         <listitem><para>smb://username:password@WINDOWSNETBIOSNAME/printersharename</para></listitem>
5105 </itemizedlist>
5107 <para>
5108 Note that the device-URI will be visible in the process list of the
5109 Samba server (e.g. when someone uses the <command>ps -aux</command>
5110 command on Linux), even if the username and passwords are sanitized
5111 before they get written into the log files.  So this is an inherently
5112 insecure option. However it is the only one. Don't use it if you want
5113 to protect your passwords. Better share the printer in a way that
5114 doesn't require a password! Printing will only work if you have a
5115 working netbios name resolution up and running. Note that this is a
5116 feature of CUPS and you don't necessarily need to have smbd running
5117 (but who wants that? :-).
5118 </para>
5119 </sect1>
5121 <sect1>
5122 <title>More CUPS filtering Chains</title>
5124 <para>
5125 The following diagrams reveal how CUPS handles print jobs.
5126 </para>
5128 <image><imagefile>cups1</imagefile><imagedescription>Filtering chain 1</imagedescription></image>
5130 <image><imagefile>cups2</imagefile><imagedescription>Filtering chain with cupsomatic</imagedescription></image>
5132 <note><para>
5133 Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
5134 CUPS and ESP PrintPro plug-in where rastertosomething is noted.
5135 </para></note>
5137 <!--FIXME: Put this into diagrams... ?
5139 #########################################################################
5141 # And this is how it works for ESP PrintPro from 4.3:
5142 # ===================================================
5144 # SOMETHNG-FILEFORMAT
5145 #      |
5146 #      V
5147 #     somethingtops
5148 #      |
5149 #      V
5150 # APPLICATION/POSTSCRIPT
5151 #      |
5152 #      V
5153 #     pstops
5154 #      |
5155 #      V
5156 # APPLICATION/VND.CUPS-POSTSCRIPT
5157 #      |
5158 #      V
5159 #     gsrip
5160 #      |  (= "postscipt interpreter")
5161 #      V
5162 # APPLICATION/VND.CUPS-RASTER
5163 #      |
5164 #      V
5165 #     rastertosomething  (e.g. Gimp-Print filters may be plugged in here)
5166 #      |   (= "raster driver")
5167 #      V
5168 # SOMETHING-DEVICE-SPECIFIC
5169 #      |
5170 #      V
5171 #     backend
5173 # NOTE: Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
5174 #       CUPS and ESP PrintPro plug-in where rastertosomething is noted.
5176 #########################################################################
5177 </screen>
5179 <screen>
5180 #########################################################################
5182 # This is how "cupsomatic" would come into play with ESP PrintPro:
5183 # ================================================================
5186 # SOMETHNG-FILEFORMAT
5187 #      |
5188 #      V
5189 #    somethingtops
5190 #      |
5191 #      V
5192 # APPLICATION/POSTSCRIPT
5193 #      |
5194 #      V
5195 #    pstops
5196 #      |
5197 #      V
5198 # APPLICATION/VND.CUPS-POSTSCRIPT ================+
5199 #      |                                          V
5200 #      V                                         cupsomatic
5201 #    gsrip                                       (constructs complicated
5202 #      |  (= "postscipt interpreter")            Ghostscript commandline
5203 #      |                                         to let the file be
5204 #      V                                         processed by a
5205 # APPLICATION/VND.CUPS-RASTER                    "-sDEVICE=s.th."
5206 #      |                                         call...)
5207 #      V                                          |
5208 #    rastertosomething                            V
5209 #      |   (= "raster driver")      +=========================+
5210 #      |                            | Ghostscript at work.... |
5211 #      V                            |                         |
5212 # SOMETHING-DEVICE-SPECIFIC         *=========================+
5213 #      |                                          |
5214 #      V                                          |
5215 #    backend &lt;=================================+
5216 #      |
5217 #      V
5218 #    THE PRINTER
5220 # NOTE: Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
5221 #       CUPS and ESP PrintPro plug-in where rastertosomething is noted.
5223 #########################################################################
5224 </screen>
5226 <screen>
5227 #########################################################################
5229 # And this is how it works for CUPS from 1.1.15:
5230 # ==============================================
5232 # SOMETHNG-FILEFORMAT
5233 #      |
5234 #      V
5235 #     somethingtops
5236 #      |
5237 #      V
5238 # APPLICATION/POSTSCRIPT
5239 #      |
5240 #      V
5241 #     pstops
5242 #      |
5243 #      V
5244 # APPLICATION/VND.CUPS-POSTSCRIPT=====+
5245 #                  +==================v==============================+
5246 #                  | Ghostscript                                     |
5247 #                  | at work...                                      |
5248 #                  | (with                                           |
5249 #                  | "-sDEVICE=cups")                                |
5250 #                  |                                                 |
5251 #                  |         (= "postscipt interpreter")             |
5252 #                  |                                                 |
5253 #                  +==================v==============================+
5254 #                                     |
5255 # APPLICATION/VND.CUPS-RASTER &gt;====+
5256 #      |
5257 #      V
5258 #     rastertosomething
5259 #      |   (= "raster driver")
5260 #      V
5261 # SOMETHING-DEVICE-SPECIFIC
5262 #      |
5263 #      V
5264 #     backend
5267 # NOTE: since version 1.1.15 CUPS "outsourced" the pstoraster process to
5268 #       Ghostscript. GNU Ghostscript needs to be patched to handle the
5269 #       CUPS requirement; ESP Ghostscript has this builtin. In any case,
5270 #       "gs -h" needs to show up a "cups" device. pstoraster is now a
5271 #       calling an appropriate "gs -sDEVICE=cups..." commandline to do
5272 #       the job. It will output "application/vnd.cup-raster", which will
5273 #       be finally processed by a CUPS raster driver "rastertosomething"
5274 #       Note the difference to "cupsomatic", which will <emphasis>not</emphasis> output
5275 #       CUPS-raster, but a final version of the printfile, ready to be
5276 #       sent to the printer. cupsomatic also doesn't use the "cups"
5277 #       devicemode in Ghostscript, but one of the classical devicemodes....
5279 # NOTE: Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
5280 #       CUPS and ESP PrintPro plug-in where rastertosomething is noted.
5282 #########################################################################
5283 </screen>
5285 <screen>
5286 #########################################################################
5288 # And this is how it works for CUPS from 1.1.15, with cupsomatic included:
5289 # ========================================================================
5291 # SOMETHNG-FILEFORMAT
5292 #      |
5293 #      V
5294 #     somethingtops
5295 #      |
5296 #      V
5297 # APPLICATION/POSTSCRIPT
5298 #      |
5299 #      V
5300 #     pstops
5301 #      |
5302 #      V
5303 # APPLICATION/VND.CUPS-POSTSCRIPT=====+
5304 #                  +==================v==============================+
5305 #                  | Ghostscript        . Ghostscript at work....    |
5306 #                  | at work...         . (with "-sDEVICE=           |
5307 #                  | (with              .            s.th."          |
5308 #                  | "-sDEVICE=cups")   .                            |
5309 #                  |                    .                            |
5310 #                  | (CUPS standard)    .      (cupsomatic)          |
5311 #                  |                    .                            |
5312 #                  |          (= "postscript interpreter")           |
5313 #                  |                    .                            |
5314 #                  +==================v==============v===============+
5315 #                                     |              |
5316 # APPLICATION/VND.CUPS-RASTER &gt;=======+              |
5317 #      |                                             |
5318 #      V                                             |
5319 #     rastertosomething                              |
5320 #      |   (= "raster driver")                       |
5321 #      V                                             |
5322 # SOMETHING-DEVICE-SPECIFIC &gt;========================+
5323 #      |
5324 #      V
5325 #     backend
5328 # NOTE: Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
5329 #       CUPS and ESP PrintPro plug-in where rastertosomething is noted.
5331 ##########################################################################
5332 </screen>-->
5333 </sect1>
5335 <sect1>
5336         <title>Common Errors</title>
5338         <sect2>
5339                 <title>Win9x client can't install driver</title>
5341                 <para>For Win9x clients require the printer names to be 8
5342 chars (or "8 plus 3 chars suffix") max; otherwise the driver files
5343 won't get transferred when you want to download them from
5344 Samba.</para>
5346         </sect2>
5348         <sect2>
5349                 <title>"cupsaddsmb" keeps asking for root password in
5350                         neverending loop</title>
5352                 <para>Have you <smbconfoption><name>security</name><value>user</value></smbconfoption>? Have
5353 you used <command>smbpasswd</command> to give root a Samba account?
5354 You can do 2 things: open another terminal and execute
5355 <command>smbpasswd -a root</command> to create the account, and
5356 continue with entering the password into the first terminal. Or break
5357 out of the loop by hitting ENTER twice (without trying to type a
5358 password).</para>
5360         </sect2>
5362         <sect2>
5363                 <title>"cupsaddsmb" gives "No PPD file for printer..."
5364                         message while PPD file is present</title>
5366                 <para>Have you enabled printer sharing on CUPS? This means:
5367 do you have a <parameter>&lt;Location
5368 /printers&gt;....&lt;/Location&gt;</parameter> section in CUPS
5369 server's <filename>cupsd.conf</filename> which doesn't deny access to
5370 the host you run "cupsaddsmb" from?  It <emphasis>could</emphasis> be
5371 an issue if you use cupsaddsmb remotely, or if you use it with a
5372 <option>-h</option> parameter: <userinput>cupsaddsmb -H
5373         sambaserver -h cupsserver -v printername</userinput>.
5374 </para>
5375 <para>Is your
5376 "TempDir" directive in
5377 <emphasis>cupsd.conf</emphasis>
5378 set to a valid value and is it writeable?
5379 </para>
5381         </sect2>
5383         <sect2>
5384                 <title>Client can't connect to Samba printer</title>
5385         <para>Use <command>smbstatus</command> to check which user
5386 you are from Samba's point of view. Do you have the privileges to
5387 write into the <smbconfsection>[print$]</smbconfsection>
5388 share?</para>
5390         </sect2>
5392         <sect2>
5393                 <title>Can't reconnect to Samba under new account
5394                         from Win2K/XP</title>
5395         <para>Once you are connected as the "wrong" user (for
5396 example as "nobody", which often occurs if you have 
5397 <smbconfoption><name>map to guest</name><value>bad user</value></smbconfoption>), Windows Explorer will not accept an
5398 attempt to connect again as a different user. There won't be any byte
5399 transfered on the wire to Samba, but still you'll see a stupid error
5400 message which makes you think that Samba has denied access. Use
5401 <command>smbstatus</command> to check for active connections. Kill the
5402 PIDs. You still can't re-connect and get the dreaded
5403 <computeroutput>You can't connect with a second account from the same
5404 machine</computeroutput> message, as soon as you are trying? And you
5405 don't see any single byte arriving at Samba (see logs; use "ethereal")
5406 indicating a renewed connection attempt? Shut all Explorer Windows.
5407 This makes Windows forget what it has cached in its memory as
5408 established connections. Then re-connect as the right user. Best
5409 method is to use a DOS terminal window and <emphasis>first</emphasis>
5410 do <userinput>net use z: \\&example.server.samba;\print$ /user:root</userinput>. Check
5411 with <command>smbstatus</command> that you are connected under a
5412 different account. Now open the "Printers" folder (on the Samba server
5413 in the <emphasis>Network Neighbourhood</emphasis>), right-click the
5414 printer in question and select
5415 <emphasis>Connect...</emphasis></para></sect2>
5417 <sect2>
5418         <title>Avoid being connected to the Samba server as the
5419                 "wrong" user</title>
5420         
5421         <para>You see per <command>smbstatus</command> that you are
5422 connected as user "nobody"; while you wanted to be "root" or
5423 "printeradmin"? This is probably due to 
5424 <smbconfoption><name>map to guest</name><value>bad user</value></smbconfoption>, which silently connects you under the guest account,
5425 when you gave (maybe by accident) an incorrect username. Remove
5426 <smbconfoption><name>map to guest</name></smbconfoption>, if you want to prevent
5427 this.</para></sect2>
5429 <sect2><title>Upgrading to CUPS drivers from Adobe drivers on
5430                 NT/2K/XP clients gives problems</title>
5432         <para>First delete all "old" Adobe-using printers. Then
5433 delete all "old" Adobe drivers. (On Win2K/XP, right-click in
5434 background of "Printers" folder, select "Server Properties...", select
5435 tab "Drivers" and delete here).</para></sect2>
5437 <sect2><title>Can't use "cupsaddsmb" on Samba server which is
5438                 a PDC</title>
5439 <para>Do you use the "naked" root user name? Try to do it
5440 this way: <userinput>cupsaddsmb -U <replaceable>DOMAINNAME</replaceable>\\root -v
5441 <replaceable>printername</replaceable></userinput>> (note the two backslashes: the first one is
5442 required to "escape" the second one).</para></sect2>
5444 <sect2><title>Deleted Win2K printer driver is still shown</title>
5445 <para>Deleting a printer on the client won't delete the
5446 driver too (to verify, right-click on the white background of the
5447 "Printers" folder, select "Server Properties" and click on the
5448 "Drivers" tab). These same old drivers will be re-used when you try to
5449 install a printer with the same name. If you want to update to a new
5450 driver, delete the old ones first. Deletion is only possible if no
5451 other printer uses the same driver.</para></sect2>
5453 <sect2><title>Win2K/XP "Local Security
5454                 Policies"</title>
5455 <para><emphasis>Local Security Policies</emphasis> may not
5456 allow the installation of unsigned drivers. "Local Security Policies"
5457 may not allow the installation of printer drivers at
5458 all.</para></sect2>
5460 <sect2><title>WinXP clients: "Administrator can not install
5461                 printers for all local users"</title>
5462 <para>Windows XP handles SMB printers on a "per-user" basis.
5463 This means every user needs to install the printer himself. To have a
5464 printer available for everybody, you might want to use the built-in
5465 IPP client capabilities of WinXP. Add a printer with the print path of
5466 <emphasis>http://cupsserver:631/printers/printername</emphasis>.
5467 Still looking into this one: maybe a "logon script" could
5468 automatically install printers for all
5469 users.</para></sect2>
5471 <sect2><title>"Print Change Notify" functions on
5472                 NT-clients</title>
5473 <para>For "print change notify" functions on NT++ clients,
5474 these need to run the "Server" service first (re-named to
5475 <emphasis>File &amp; Print Sharing for MS Networks</emphasis> in
5476 XP).</para></sect2>
5478 <sect2><title>WinXP-SP1</title>
5479 <para>WinXP-SP1 introduced a <emphasis>Point and Print
5480 Restriction Policy</emphasis> (this restriction doesn't apply to
5481 "Administrator" or "Power User" groups of users).  In Group Policy
5482 Object Editor: go to <emphasis>User Configuration,
5483         Administrative Templates, Control Panel,
5484 Printers</emphasis>. The policy is automatically set to
5485 <emphasis>Enabled</emphasis> and the <emphasis>Users can only Point
5486 and Print to machines in their Forest</emphasis> . You probably need
5487 to change it to <emphasis>Disabled</emphasis> or <emphasis>Users can
5488 only Point and Print to these servers</emphasis> in order to make
5489 driver downloads from Samba possible.</para></sect2>
5491 <sect2><title>Print options for all     users can't be set on Win2K/XP</title>
5493 <para>How are you doing it? I bet the wrong way (it is not
5494 very easy to find out, though). There are 3 different ways to bring
5495 you to a dialog that <emphasis>seems</emphasis> to set everything. All
5496 three dialogs <emphasis>look</emphasis> the same. Only one of them
5497 <emphasis>does</emphasis> what you intend. You need to be
5498 Administrator or Print Administrator to do this for all users.  Here
5499 is how I do in on XP:
5500 </para>
5502 <orderedlist numeration="upperalpha">
5504 <listitem><para>The first "wrong" way:
5506 <orderedlist numeration="arabic">
5507 <listitem><para>Open the <emphasis>Printers</emphasis>
5508 folder.</para></listitem>
5510 <listitem><para>Right-click on the printer
5511 (<emphasis>remoteprinter on cupshost</emphasis>) and
5512 select in context menu <emphasis>Printing
5513 Preferences...</emphasis></para></listitem>
5515 <listitem><para>Look at this dialog closely and remember what it looks
5516 like.</para></listitem>
5517 </orderedlist>
5518 </para>
5519 </listitem>
5521 <listitem><para>The second "wrong" way:
5523 <orderedlist numeration="arabic">
5524 <listitem><para>Open the <emphasis>Printers</emphasis>
5525 folder.</para></listitem>
5527 <listitem><para>Right-click on the printer (<emphasis>remoteprinter on
5528 cupshost</emphasis>) and select in the context menu
5529 <emphasis>Properties</emphasis></para></listitem>
5531 <listitem><para>Click on the <emphasis>General</emphasis>
5532 tab</para></listitem>
5534 <listitem><para>Click on the button <emphasis>Printing
5535 Preferences...</emphasis></para></listitem>
5537 <listitem><para>A new dialog opens. Keep this dialog open and go back
5538 to the parent dialog.</para></listitem>
5539 </orderedlist>
5540 </para>
5541 </listitem>
5543 <listitem><para>The third, the "correct" way: (should you do
5544 this from the beginning, just carry out steps 1. and 2. from second
5545 "way" above)
5547 <orderedlist numeration="arabic">
5548 <listitem><para>Click on the <emphasis>Advanced</emphasis>
5549 tab. (Hmmm... if everything is "Grayed Out", then you are not logged
5550 in as a user with enough privileges).</para></listitem>
5552 <listitem><para>Click on the <emphasis>Printing
5553 Defaults...</emphasis> button.</para></listitem>
5555 <listitem><para>On any of the two new tabs, click on the
5556 <emphasis>Advanced...</emphasis>
5557 button.</para></listitem>
5559 <listitem><para>A new dialog opens. Compare this one to the other,
5560 identical looking one from "B.5" or A.3".</para></listitem>
5561 </orderedlist>
5562 </para>
5563 </listitem>
5564 </orderedlist>
5566 <para>
5567 Do you see any difference? I don't either... However, only the last
5568 one, which you arrived at with steps "C.1.-6." will save any settings
5569 permanently and be the defaults for new users. If you want all clients
5570 to get the same defaults, you need to conduct these steps <emphasis>as
5571 Administrator</emphasis> (<smbconfoption><name>printer admin</name></smbconfoption> in
5572 &smb.conf;) <emphasis>before</emphasis> a client
5573 downloads the driver (the clients can later set their own
5574 <emphasis>per-user defaults</emphasis> by following the
5575 procedures <emphasis>A.</emphasis> or <emphasis>B.</emphasis>
5576 above).</para></sect2>
5578 <sect2><title>Most common blunders in driver
5579                 settings on Windows clients</title>
5580         <para>Don't use <emphasis>Optimize for
5581 Speed</emphasis>: use <emphasis>Optimize for
5582 Portability</emphasis> instead (Adobe PS Driver) Don't use
5583 <emphasis>Page Independence: No</emphasis>: always
5584 settle with  <emphasis>Page Independence:
5585 Yes</emphasis> (Microsoft PS Driver and CUPS PS Driver for
5586 WinNT/2K/XP) If there are problems with fonts: use
5587 <emphasis>Download as Softfont into
5588 printer</emphasis> (Adobe PS Driver). For
5589 <emphasis>TrueType Download Options</emphasis>
5590 choose <emphasis>Outline</emphasis>. Use PostScript
5591 Level 2, if you are having trouble with a non-PS printer, and if
5592 there is a choice.</para></sect2>
5594 <sect2><title><command>cupsaddsmb</command> does not work
5595                 with newly installed printer</title>
5596 <para>Symptom: the last command of
5597 <command>cupsaddsmb</command> doesn't complete successfully:
5598 <command>cmd = setdriver printername printername</command> result was
5599 NT_STATUS_UNSUCCESSFUL then possibly the printer was not yet
5600 "recognized" by Samba. Did it show up in <emphasis>Network
5601 Neighbourhood</emphasis>? Did it show up in <command>rpcclient
5602 hostname -c 'enumprinters'</command>? Restart smbd (or send a
5603 <command>kill -HUP</command> to all processes listed by
5604 <command>smbstatus</command> and try
5605 again.</para></sect2>
5607 <sect2><title>Permissions on
5608 <filename>/var/spool/samba/</filename> get reset after each
5609 reboot</title>
5610 <para>Have you by accident set the CUPS spool directory to
5611 the same location? (<parameter>RequestRoot
5612 /var/spool/samba/</parameter> in <filename>cupsd.conf</filename> or
5613 the other way round: <filename>/var/spool/cups/</filename> is set as
5614 <smbconfoption><name>path</name></smbconfoption>> in the <smbconfsection>[printers]</smbconfsection>
5615 section). These <emphasis>must</emphasis> be different. Set
5616 <parameter>RequestRoot /var/spool/cups/</parameter> in
5617 <filename>cupsd.conf</filename> and <smbconfoption><name>path</name><value>
5618 /var/spool/samba</value></smbconfoption> in the <smbconfsection>[printers]</smbconfsection>
5619 section of &smb.conf;. Otherwise cupsd will
5620 sanitize permissions to its spool directory with each restart, and
5621 printing will not work reliably.</para></sect2>
5623 <sect2><title>Printer named "lp"
5624 intermittently swallows jobs and spits out completely different
5625 ones</title>
5626 <para>It is a very bad idea to name any printer "lp". This
5627 is the traditional UNIX name for the default printer. CUPS may be set
5628 up to do an automatic creation of "Implicit Classes". This means, to
5629 group all printers with the same name to a pool of devices, and
5630 loadbalancing the jobs across them in a round-robin fashion.  Chances
5631 are high that someone else has an "lp" named printer too.  You may
5632 receive his jobs and send your own to his device unwittingly. To have
5633 tight control over the printer names, set <parameter>BrowseShortNames
5634 No</parameter>. It will present any printer as "printername@cupshost"
5635 then, giving you a better control over what may happen in a large
5636 networked environment.</para></sect2>
5638 <sect2><title>Location of Adobe PostScript driver files necessary for "cupsaddsmb"</title>
5639 <para>Use <command>smbclient</command> to connect to any
5640 Windows box with a shared PostScript printer: <command>smbclient
5641 //windowsbox/print\$ -U guest</command>. You can navigate to the
5642 <filename>W32X86/2</filename> subdir to <command>mget ADOBE*</command>
5643 and other files or to <filename>WIN40/0</filename> to do the same. --
5644 Another option is to download the <filename>*.exe</filename> packaged
5645 files from the Adobe website.</para></sect2>
5647 </sect1>
5649 <sect1>
5650 <title>An Overview of the CUPS Printing Processes</title>
5652 <image><imagedescription>CUPS Printing Overview</imagedescription>
5653         <imagefile>a_small</imagefile>
5654 </image>
5655 </sect1>
5657 </chapter>