Better compatibility with official syntax
[Samba.git] / docs / docbook / projdoc / CUPS-printing.xml
blobe4169aeda352c63ff53ca48d70bca7ac1913342f
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>
327 <indexterm><primary>point and print</primary></indexterm>
329 <listitem><para>deposit and prepare the drivers (for later download) on
330 the print server (Samba); this enables the clients to use
331 "Point and Print" to get drivers semi-automatically installed the
332 first time they access the printer; with this method NT/2K/XP
333 clients use the <emphasis>SPOOLSS/MS-RPC</emphasis>
334 type printing calls.</para></listitem>
335 </itemizedlist>
337 <para>
338 The second method is recommended for use over the first.
339 </para>
340 </sect2>
342 <sect2>
343 <title>Explicitly enable "raw" printing for
344 <emphasis>application/octet-stream</emphasis>!</title>
346 <indexterm><primary>application/octet-stream</primary></indexterm>
348 <para>
349 If you use the first option (drivers are installed on the client
350 side), there is one setting to take care of: CUPS needs to be told
351 that it should allow "raw" printing of deliberate (binary) file
352 formats. The CUPS files that need to be correctly set for RAW mode
353 printers to work are:
354 </para>
356 <itemizedlist>
357 <listitem><para>/etc/cups/mime.types
358 </para></listitem>
360 <listitem><para>/etc/cups/mime.convs</para></listitem>
361 </itemizedlist>
363 <para>
364 Both contain entries (at the end of the respective files) which must
365 be uncommented to allow RAW mode operation.
366 In<filename>/etc/cups/mime.types</filename> make sure this line is
367 present:
368 </para>
370 <para><screen>
371  application/octet-stream
372 </screen></para>
374 <para>
375 In <filename>/etc/cups/mime.convs</filename>,
376 have this line:
377 </para>
379 <indexterm><primary>application/vnd.cups-raw</primary></indexterm>
381 <para><screen>
382  application/octet-stream   application/vnd.cups-raw   0   - 
383 </screen></para>
385 <para>
386 If these two files are not set up correctly for raw Windows client
387 printing, you may encounter the dreaded <computeroutput>Unable to
388 convert file 0</computeroutput> in your CUPS error_log file. 
389 </para>
391 <note><para>editing the <filename>mime.convs</filename> and the
392 <filename>mime.types</filename> file does not
393 <emphasis>enforce</emphasis> "raw" printing, it only
394 <emphasis>allows</emphasis> it.
395 </para></note>
397 <formalpara><title>Background</title>
399 <indexterm><primary>application/octet-stream</primary></indexterm>
401 <para>
402 CUPS being a more security-aware printing system than traditional ones
403 does not by default allow a user to send deliberate (possibly binary)
404 data to printing devices. This could be easily abused to launch a
405 "Denial of Service" attack on your printer(s), causing at the least
406 the loss of a lot of paper and ink. "Unknown" data are tagged by CUPS
407 as <emphasis>MIME type: application/octet-stream</emphasis> and not
408 allowed to go to the printer. By default, you can only send other
409 (known) MIME types "raw". Sending data "raw" means that CUPS does not
410 try to convert them and passes them to the printer untouched (see next
411 chapter for even more background explanations).
412 </para>
413 </formalpara>
415 <para>
416 This is all you need to know to get the CUPS/Samba combo printing
417 "raw" files prepared by Windows clients, which have vendor drivers
418 locally installed. If you are not interested in background information about
419 more advanced CUPS/Samba printing, simply skip the remaining sections
420 of this chapter.
421 </para>
422 </sect2>
424 <sect2>
425 <title>Three familiar Methods for driver upload plus a new one</title>
427 <indexterm><primary>point and print</primary></indexterm>
429 <para>
430 If you want to use the MS-RPC type printing, you must upload the
431 drivers onto the Samba server first (<smbconfsection>[print$]</smbconfsection>
432 share). For a discussion on how to deposit printer drivers on the
433 Samba host (so that the Windows clients can download and use them via
434 "Point'n'Print") please also refer to the previous chapter of this
435 HOWTO Collection. There you will find a description or reference to
436 three methods of preparing the client drivers on the Samba server:
437 </para>
439 <indexterm><primary>add printer wizard</primary></indexterm>
441 <itemizedlist>
442 <listitem><para>the GUI, "Add Printer Wizard"
443 <emphasis>upload-from-a-Windows-client</emphasis>
444 method;</para></listitem>
446 <listitem><para>the commandline, "smbclient/rpcclient"
447 <emphasis>upload-from-a-UNIX-workstation</emphasis>
448 method;</para></listitem>
450 <indexterm><primary>imprints</primary></indexterm>
452 <listitem><para>the <emphasis>Imprints</emphasis> Toolset
453 method.</para></listitem>
454 </itemizedlist>
456 <para>
457 These 3 methods apply to CUPS all the same. A new and more
458 convenient way to load the Windows drivers into Samba is provided
459 if you use CUPS:
460 </para>
462 <indexterm><primary>cupsaddsmb</primary></indexterm>
464 <itemizedlist>
465 <listitem><para>the <emphasis>cupsaddsmb</emphasis>
466 utility.</para></listitem>
467 </itemizedlist>
469 <para>
470 cupsaddsmb is discussed in much detail further below. But we will
471 first explore the CUPS filtering system and compare the Windows and
472 UNIX printing architectures.
473 </para>
474 </sect2>
475 </sect1>
477 <sect1>
478 <title>Using CUPS/Samba in an advanced Way -- intelligent printing
479 with PostScript Driver Download</title>
481 <indexterm><primary>PostScript</primary><seealso>Ghostscript</seealso></indexterm>
483 <para>
484 Are you still following this? Good. Let's go into more detail then. We now know
485 how to set up a "dump" printserver, that is, a server which is spooling
486 printjobs "raw", leaving the print data untouched.
487 </para>
489 <para>
490 Possibly you need to setup CUPS in a more smart way. The reasons could
491 be manifold:
492 </para>
494 <itemizedlist>
495 <listitem><para>Maybe your boss wants to get monthly statistics: Which
496 printer did how many pages? What was the average data size of a job?
497 What was the average print run per day? What are the typical hourly
498 peaks in printing? Which departments prints how
499 much?</para></listitem>
501 <listitem><para>Maybe you are asked to setup a print quota system:
502 users should not be able to print more jobs, once they have surpassed
503 a given limit per period?</para></listitem>
505 <listitem><para>Maybe your previous network printing setup is a mess
506 and shall be re-organized from a clean beginning?</para></listitem>
508 <listitem><para>Maybe you have experiencing too many "Blue Screens",
509 originating from poorly debugged printer drivers running in NT "kernel
510 mode"?</para></listitem>
511 </itemizedlist>
513 <para>
514 These goals cannot be achieved by a raw print server. To build a
515 server meeting these requirements, you'll first need to learn about
516 how CUPS works and how you can enable its features.
517 </para>
519 <para>
520 What follows is the comparison of some fundamental concepts for
521 Windows and UNIX printing; then is the time for a description of the
522 CUPS filtering system, how it works and how you can tweak it.
523 </para>
525 <sect2 id="gdipost">
526 <title>GDI on Windows -- PostScript on UNIX</title>
528 <indexterm><primary>GDI</primary></indexterm>
529 <indexterm><primary>PostScript</primary></indexterm>
531 <para>
532 Network printing is one of the most complicated and error-prone
533 day-to-day tasks any user or an administrator may encounter. This is
534 true for all OS platforms. And there are reasons for this.
535 </para>
537 <indexterm><primary>PCL</primary></indexterm>
538 <indexterm><primary>PDL</primary></indexterm>
540 <para>
541 You can't expect for most file formats to just throw them towards
542 printers and they get printed. There needs to be a file format
543 conversion in between. The problem is: there is no common standard for
544 print file formats across all manufacturers and printer types.  While
545 <emphasis>PostScript</emphasis> (trademark held by Adobe), and, to an
546 extent, <emphasis>PCL</emphasis> (trademark held by HP), have developed
547 into semi-official "standards", by being the most widely used PDLs
548 (<emphasis>Page Description Languages</emphasis>), there are still
549 many manufacturers who "roll their own" (their reasons may be
550 unacceptable license fees for using printer-embedded PostScript
551 interpreters, etc.).
552 </para>
553 </sect2>
555 <sect2>
556 <title>Windows Drivers, GDI and EMF</title>
558 <indexterm><primary>GDI</primary></indexterm>
559 <indexterm><primary>EMF</primary></indexterm>
560 <indexterm><primary>WYSIWYG</primary></indexterm>
562 <para>
563 In Windows OS, the format conversion job is done by the printer
564 drivers. On MS Windows OS platforms all application programmers have
565 at their disposal a built-in API, the GDI (<emphasis>Graphical Device
566 Interface</emphasis>), as part and parcel of the OS itself, to base
567 themselves on. This GDI core is used as one common unified ground, for
568 all Windows programs, to draw pictures, fonts and documents
569 <emphasis>on screen</emphasis> as well as <emphasis>on
570 paper</emphasis> (=print). Therefore printer driver developers can
571 standardize on a well-defined GDI output for their own driver
572 input. Achieving WYSIWYG ("What You See Is What You Get") is
573 relatively easy, because the on-screen graphic primitives, as well as
574 the on-paper drawn objects, come from one common source. This source,
575 the GDI, produces often a file format called EMF (<emphasis>Enhanced
576 MetaFile</emphasis>). The EMF is processed by the printer driver and
577 converted to the printer-specific file format.
578 </para>
580 <note><para>
581 <indexterm><primary>PDF</primary></indexterm>
582 To the GDI foundation in MS Windows, Apple has chosen to
583 put paper and screen output on a common foundation for their
584 (BSD-UNIX-based, did you know??) Mac OS X and Darwin Operating
585 Systems. Their <emphasis>Core Graphic Engine</emphasis> uses a
586 <emphasis>PDF</emphasis> derivative for all display work.
587 </para></note>
589 <para>
591 <image><imagedescription>Windows Printing to a local Printer</imagedescription><imagefile>1small</imagefile></image>
592 </para>
593 </sect2>
595 <sect2>
596 <title>UNIX Printfile Conversion and GUI Basics</title>
598 <indexterm><primary>X Window System</primary></indexterm>
599 <indexterm><primary>PostScript</primary></indexterm>
600 <indexterm><primary>PCL</primary></indexterm>
601 <indexterm><primary>Xprint</primary></indexterm>
603 <para>
604 In UNIX and Linux, there is no comparable layer built into the OS
605 kernel(s) or the X (screen display) server. Every application is
606 responsible for itself to create its print output.  Fortunately, most
607 use PostScript. That gives at least some common ground. Unfortunately,
608 there are many different levels of quality for this PostScript. And
609 worse: there is a huge difference (and no common root) in the way how
610 the same document is displayed on screen and how it is presented on
611 paper. WYSIWYG is more difficult to achieve. This goes back to the
612 time decades ago, when the predecessors of <emphasis>X.org</emphasis>,
613 designing the UNIX foundations and protocols for Graphical User
614 Interfaces refused to take over responsibility for "paper output"
615 also, as some had demanded at the time, and restricted itself to
616 "on-screen only".  (For some years now, the "Xprint" project has been
617 under development, attempting to build printing support into the X
618 framework, including a PostScript and a PCL driver, but it is not yet
619 ready for prime time.) You can see this unfavorable inheritance up to
620 the present day by looking into the various "font" directories on your
621 system; there are separate ones for fonts used for X display and fonts
622 to be used on paper.
623 </para>
625 <formalpara>
626 <title>Background</title>
628 <indexterm><primary>PostScript</primary></indexterm>
630 <para>
631 The PostScript programming language is an "invention" by Adobe Inc.,
632 but its specifications have been published to the full. Its strength
633 lies in its powerful abilities to describe graphical objects (fonts,
634 shapes, patterns, lines, curves, dots...), their attributes (color,
635 linewidth...) and the way to manipulate (scale, distort, rotate,
636 shift...) them.  Because of its open specification, anybody with the
637 skill can start writing his own implementation of a PostScript
638 interpreter and use it to display PostScript files on screen or on
639 paper. Most graphical output devices are based on the concept of
640 "raster images" or "pixels" (one notable exception are pen
641 plotters). Of course, you can look at a PostScript file in its textual
642 form and you will be reading its PostScript code, the language
643 instructions which need to be interpreted by a rasterizer. Rasterizers
644 produce pixel images, which may be displayed on screen by a viewer
645 program or on paper by a printer.
646 </para>
647 </formalpara>
648 </sect2>
650 <sect2 id="post-and-ghost">
651 <title>PostScript and Ghostscript</title>
653 <indexterm><primary>PostScript</primary></indexterm>
654 <indexterm><primary>GhostScript</primary><seealso>PostScript</seealso></indexterm>
655 <indexterm><primary>PostScript</primary><secondary>RIP</secondary></indexterm>
657 <para>
658 So, UNIX is lacking a common ground for printing on paper and
659 displaying on screen. Despite this unfavorable legacy for UNIX, basic
660 printing is fairly easy: if you have PostScript printers at your
661 disposal! The reason is: these devices have a built-in PostScript
662 language "interpreter", also called a <emphasis>Raster Image
663 Processor</emphasis> (RIP), (which makes them more expensive than
664 other types of printers); throw PostScript towards them, and they will
665 spit out your printed pages. Their RIP is doing all the hard work of
666 converting the PostScript drawing commands into a bitmap picture as
667 you see it on paper, in a resolution as done by your printer. This is
668 no different to PostScript printing of a file from a Windows origin.
669 </para>
671 <note><para>
672 <indexterm><primary>PPD</primary></indexterm>
673 Traditional UNIX programs and printing systems -- while
674 using PostScript -- are largely not PPD-aware. PPDs are "PostScript
675 Printer Description" files. They enable you to specify and control all
676 options a printer supports: duplexing, stapling, punching... Therefore
677 UNIX users for a long time couldn't choose many of the supported
678 device and job options, unlike Windows or Apple users. But now there
679 is CUPS....
680 </para>
681 </note>
683 <para>
684         <image><imagedescription>Printing to a Postscript Printer</imagedescription>
685                 <imagefile>2small</imagefile></image>
686 </para>
688 <indexterm><primary>PDL</primary></indexterm>
690 <para>
691 However, there are other types of printers out there. These don't know
692 how to print PostScript. They use their own <emphasis>Page Description
693 Language</emphasis> (PDL, often proprietary). To print to them is much
694 more demanding. Since your UNIX applications mostly produce
695 PostScript, and since these devices don't understand PostScript, you
696 need to convert the printfiles to a format suitable for your printer
697 on the host, before you can send it away.
698 </para>
699 </sect2>
701 <sect2>
702 <title>Ghostscript -- the Software RIP for non-PostScript Printers</title>
704 <indexterm><primary>GhostScript</primary></indexterm>
706 <para>
707 Here is where <emphasis>Ghostscript</emphasis> kicks in. Ghostscript is
708 the traditional (and quite powerful) PostScript interpreter used on
709 UNIX platforms. It is a RIP in software, capable to do a
710 <emphasis>lot</emphasis> of file format conversions, for a very broad
711 spectrum of hardware devices as well as software file formats.
712 Ghostscript technology and drivers is what enables PostScript printing
713 to non-PostScript hardware.
714 </para>
716 <para>
717 <image><imagedescription>Ghostscript as a RIP for non-postscript printers</imagedescription>
718         <imagefile>3small</imagefile>
719 </image>
720 </para>
722 <tip><para>
723 Use the "gs -h" command to check for all built-in "devices" of your
724 Ghostscript version. If you specify e.g. a parameter of
725 <parameter>-sDEVICE=png256</parameter> on your Ghostscript command
726 line, you are asking Ghostscript to convert the input into a PNG
727 file. Naming a "device" on the commandline is the most important
728 single parameter to tell Ghostscript how exactly it should render the
729 input. New Ghostscript versions are released at fairly regular
730 intervals, now by artofcode LLC. They are initially put under the
731 "AFPL" license, but re-released under the GNU GPL as soon as the next
732 AFPL version appears. GNU Ghostscript is probably the version
733 installed on most Samba systems. But it has got some
734 deficiencies. <indexterm><primary>Ghostscript</primary><secondary>ESP</secondary><see>ESP GhostScript</see></indexterm>Therefore ESP Ghostscript was developed as an
735 enhancement over GNU Ghostscript, with lots of bug-fixes, additional
736 devices and improvements. It is jointly maintained by developers from
737 CUPS, Gimp-Print, MandrakeSoft, SuSE, RedHat and Debian. It includes
738 the "cups" device (essential to print to non-PS printers from CUPS).
739 </para></tip>
740 </sect2>
742 <sect2>
743 <title>PostScript Printer Description (PPD) Specification</title>
745 <indexterm><primary>PPD</primary></indexterm>
747 <para>
748 While PostScript in essence is a <emphasis>Page Description
749 Language</emphasis> (PDL) to represent the page layout in a
750 <emphasis>device independent</emphasis> way, real world print jobs are
751 always ending up to be output on a hardware with device-specific
752 features. To take care of all the differences in hardware, and to
753 allow for innovations, Adobe has specified a syntax and file format
754 for <emphasis>PostScript Printer Description</emphasis> (PPD)
755 files. Every PostScript printer ships with one of these files.
756 </para>
758 <para>
759 PPDs contain all information about general and special features of the
760 given printer model: Which different resolutions can it handle? Does
761 it have a Duplexing Unit? How many paper trays are there? What media
762 types and sizes does it take? For each item it also names the special
763 command string to be sent to the printer (mostly inside the PostScript
764 file) in order to enable it.
765 </para>
767 <para>
768 Information from these PPDs is meant to be taken into account by the
769 printer drivers. Therefore, installed as part of the Windows
770 PostScript driver for a given printer is the printer's PPD. Where it
771 makes sense, the PPD features are presented in the drivers' UI dialogs
772 to display to the user as choice of print options. In the end, the
773 user selections are somehow written (in the form of special
774 PostScript, PJL, JCL or vendor-dependent commands) into the PostScript
775 file created by the driver.
776 </para>
778 <warning><para>
779 <indexterm><primary>PDF</primary></indexterm>
780 A PostScript file that was created to contain device-specific commands
781 for achieving a certain print job output (e.g. duplexed, stapled and
782 punched) on a specific target machine, may not print as expected, or
783 may not be printable at all on other models; it also may not be fit
784 for further processing by software (e.g. by a PDF distilling program).
785 </para></warning>
786 </sect2>
788 <sect2>
789 <title>CUPS can use all Windows-formatted Vendor PPDs</title>
791 <para>
792 CUPS can handle all spec-compliant PPDs as supplied by the
793 manufacturers for their PostScript models. Even if a
794 UNIX/Linux-illiterate vendor might not have mentioned our favorite
795 OS in his manuals and brochures -- you can safely trust this:
796 <emphasis>if you get hold of the Windows NT version of the PPD, you
797 can use it unchanged in CUPS</emphasis> and thus access the full
798 power of your printer just like a Windows NT user could!
799 </para>
801 <tip><para>
802 To check the spec compliance of any PPD online, go to <ulink
803 noescape="1" url="http://www.cups.org/testppd.php">http://www.cups.org/testppd.php</ulink>
804 and upload your PPD. You will see the results displayed
805 immediately. CUPS in all versions after 1.1.19 has a much more strict
806 internal PPD parsing and checking code enabled; in case of printing
807 trouble this online resource should be one of your first pitstops.
808 </para></tip>
810 <warning><para>
811 <indexterm><primary>foomatic</primary></indexterm>
812 <indexterm><primary>cupsomatic</primary></indexterm>
813 For real PostScript printers <emphasis>don't</emphasis> use the
814 <emphasis>Foomatic</emphasis> or <emphasis>cupsomatic</emphasis>
815 PPDs from Linuxprinting.org. With these devices the original
816 vendor-provided PPDs are always the first choice!
817 </para></warning>
819 <tip><para>
820 If you are looking for an original vendor-provided PPD of a specific
821 device, and you know that an NT4 box (or any other Windows box) on
822 your LAN has the PostScript driver installed, just use
823 <command>smbclient //NT4-box/print\$ -U username</command> to
824 access the Windows directory where all printer driver files are
825 stored. First look in the <filename>W32X86/2</filename> subdir for
826 the PPD you are seeking.
827 </para></tip>
828 </sect2>
830 <sect2>
831 <title>CUPS also uses PPDs for non-PostScript Printers</title>
833 <para>
834 CUPS also uses specially crafted PPDs to handle non-PostScript
835 printers. These PPDs are usually not available from the vendors (and
836 no, you can't just take the PPD of a Postscript printer with the same
837 model name and hope it works for the non-PostScript version too). To
838 understand how these PPDs work for non-PS printers we first need to
839 dive deeply into the CUPS filtering and file format conversion
840 architecture. Stay tuned.
841 </para>
842 </sect2>
843 </sect1>
845 <sect1>
846 <title>The CUPS Filtering Architecture</title>
848 <para>
849 The core of the CUPS filtering system is based on
850 <emphasis>Ghostscript</emphasis>. In addition to Ghostscript, CUPS
851 uses some other filters of its own. You (or your OS vendor) may have
852 plugged in even more filters. CUPS handles all data file formats under
853 the label of various <emphasis>MIME types</emphasis>. Every incoming
854 printfile is subjected to an initial
855 <emphasis>auto-typing</emphasis>. The auto-typing determines its given
856 MIME type. A given MIME type implies zero or more possible filtering
857 chains relevant to the selected target printer. This section discusses
858 how MIME types recognition and conversion rules interact. They are
859 used by CUPS to automatically setup a working filtering chain for any
860 given input data format.
861 </para>
863 <para>
864 If CUPS rasterizes a PostScript file <emphasis>natively</emphasis> to
865 a bitmap, this is done in 2 stages:
866 </para>
868 <itemizedlist>
869 <listitem><para>the first stage uses a Ghostscript device named "cups"
870 (this is since version 1.1.15) and produces a generic raster format
871 called "CUPS raster".
872 </para></listitem>
874 <listitem><para>the second stage uses a "raster driver" which converts
875 the generic CUPS raster to a device specific raster.</para></listitem>
876 </itemizedlist>
878 <para>
879 Make sure your Ghostscript version has the "cups" device compiled in
880 (check with <command>gs -h | grep cups</command>).  Otherwise you
881 may encounter the dreaded <computeroutput>Unable to convert file
882 0</computeroutput> in your CUPS error_log file. To have "cups" as a
883 device in your Ghostscript, you either need to <emphasis>patch GNU
884 Ghostscript</emphasis> and re-compile or use <indexterm><primary>ESP</primary><secondary>Ghostscript</secondary></indexterm><ulink
885 url="http://www.cups.org/ghostscript.php">ESP Ghostscript</ulink>. The
886 superior alternative is ESP Ghostscript: it supports not just CUPS,
887 but 300 other devices too (while GNU Ghostscript supports only about
888 180). Because of this broad output device support, ESP Ghostscript is
889 the first choice for non-CUPS spoolers too. It is now recommended by
890 Linuxprinting.org for all spoolers.
891 </para>
893 <para>
894 <indexterm><primary>cupsomatic</primary></indexterm>
895 <indexterm><primary>foomatic</primary></indexterm>
896 CUPS printers may be setup to use <emphasis>external</emphasis>
897 rendering paths. One of the most common ones is provided by the
898 <emphasis>Foomatic/cupsomatic</emphasis> concept, from <ulink
899 url="http://www.linuxprinting.org/">Linuxprinting.org</ulink>.  This
900 uses the classical Ghostscript approach, doing everything in one
901 step. It doesn't use the "cups" device, but one of the many
902 others. However, even for Foomatic/cupsomatic usage, best results and
903 <indexterm><primary>ESP</primary><secondary>Ghostscript</secondary></indexterm>
904 broadest printer model support is provided by ESP Ghostscript (more
905 about cupsomatic/Foomatic, particularly the new version called now
906 <emphasis>foomatic-rip</emphasis>, follows below).
907 </para>
909 <sect2>
910 <title>MIME types and CUPS Filters</title>
912 <para>
913         <indexterm><primary>MIME</primary></indexterm>
914 CUPS reads the file <filename>/etc/cups/mime.types</filename>
915 (and all other files carrying a <filename>*.types</filename> suffix
916 in the same directory) upon startup. These files contain the MIME
917 type recognition rules which are applied when CUPS runs its
918 auto-typing routines. The rule syntax is explained in the man page
919 for <filename>mime.types</filename> and in the comments section of the
920 <filename>mime.types</filename> file itself. A simple rule reads
921 like this:
922 </para>
924 <para>
925 <indexterm><primary>application/pdf</primary></indexterm>
926 <screen>
927  application/pdf         pdf string(0,%PDF)
928 </screen></para>
930 <para>
931 This means: if a filename has either a
932 <filename>.pdf</filename> suffix, or if the magic
933 string <emphasis>%PDF</emphasis> is right at the
934 beginning of the file itself (offset 0 from the start), then it is
935 a PDF file (<emphasis>application/pdf</emphasis>).
936 Another rule is this: 
937 </para>
939 <para><screen>
940  application/postscript  ai eps ps string(0,%!) string(0,&lt;04&gt;%!)
941 </screen></para>
943 <para>
944 Its meaning: if the filename has one of the suffixes
945 <filename>.ai</filename>, <filename>.eps</filename>,
946 <filename>.ps</filename> or if the file itself starts with one of the
947 strings <emphasis>%!</emphasis> or <emphasis><![CDATA[<04>%!]]></emphasis>, it
948 is a generic PostScript file
949 (<emphasis>application/postscript</emphasis>).
950 </para>
952 <note><para>
953 There is a very important difference between two similar MIME type in
954 CUPS: one is <emphasis>application/postscript</emphasis>, the other is
955 <emphasis>application/vnd.cups-postscript</emphasis>. While
956 <emphasis>application/postscript</emphasis> is meant to be device
957 independent (job options for the file are still outside the PS file
958 content, embedded in commandline or environment variables by CUPS),
959 <emphasis>application/vnd.cups-postscript</emphasis> may have the job
960 options inserted into the PostScript data itself (were
961 applicable). The transformation of the generic PostScript
962 (application/postscript) to the device-specific version
963 (application/vnd.cups-postscript) is the responsibility of the
964 CUPS <emphasis>pstops</emphasis> filter. pstops uses information
965 contained in the PPD to do the transformation.
966 </para></note>
968 <warning><para>
969 Don't confuse the other mime.types file your system might be using
970 with the one in the <filename>/etc/cups/</filename> directory.
971 </para></warning>
973 <para>
974 CUPS can handle ASCII text, HP-GL, PDF, PostScript, DVI and a
975 lot of image formats (GIF. PNG, TIFF, JPEG, Photo-CD, SUN-Raster,
976 PNM, PBM, SGI-RGB and some more) and their associated MIME types
977 with its filters.
978 </para>
979 </sect2>
981 <sect2>
982 <title>MIME type Conversion Rules</title>
984 <indexterm><primary>MIME</primary></indexterm>
986 <para>
987 CUPS reads the file <filename>/etc/cups/mime.convs</filename>
988 (and all other files named with a <filename>*.convs</filename>
989 suffix in the same directory) upon startup. These files contain
990 lines naming an input MIME type, an output MIME type, a format
991 conversion filter which can produce the output from the input type
992 and virtual costs associated with this conversion. One example line
993 reads like this:
994 </para>
996 <para><screen>
997  application/pdf         application/postscript   33   pdftops
998 </screen></para>
1000 <para>
1001 This means that the <emphasis>pdftops</emphasis> filter will take
1002 <emphasis>application/pdf</emphasis> as input and produce
1003 <emphasis>application/postscript</emphasis> as output, the virtual
1004 cost of this operation is 33 CUPS-$. The next filter is more
1005 expensive, costing 66 CUPS-$:
1006 </para>
1008 <indexterm><primary>pdf</primary></indexterm>
1010 <para><screen>
1011  application/vnd.hp-HPGL application/postscript   66   hpgltops
1012 </screen></para>
1014 <para>
1015 This is the <emphasis>hpgltops</emphasis>, which processes HP-GL
1016 plotter files to PostScript.
1017 </para>
1019 <indexterm><primary>application/octet-stream</primary></indexterm>
1021 <para><screen>
1022  application/octet-stream
1023 </screen></para>
1025 <para>
1026 Here are two more examples: 
1027 </para>
1029 <indexterm><primary>text/plain</primary></indexterm>
1031 <para><screen>
1032  application/x-shell     application/postscript   33    texttops
1033  text/plain              application/postscript   33    texttops
1034 </screen></para>
1036 <para>
1037 The last two examples name the <emphasis>texttops</emphasis> filter
1038 to work on "text/plain" as well as on "application/x-shell". (Hint:
1039 this differentiation is needed for the syntax highlighting feature of
1040 "texttops").
1041 </para>
1042 </sect2>
1044 <sect2>
1045 <title>Filter Requirements</title>
1047 <indexterm><primary>MIME</primary></indexterm>
1049 <para>
1050 There are many more combinations named in mime.convs.  However, you
1051 are not limited to use the ones pre-defined there. You can plug in any
1052 filter you like into the CUPS framework. It must meet, or must be made
1053 to meet some minimal requirements. If you find (or write) a cool
1054 conversion filter of some kind, make sure it complies to what CUPS
1055 needs, and put in the right lines in <filename>mime.types</filename>
1056 and <filename>mime.convs</filename>, then it will work seamlessly
1057 inside CUPS!
1058 </para>
1060 <tip><para>
1061 The mentioned "CUPS requirements" for filters are simple. Take
1062 filenames or <filename>stdin</filename> as input and write to
1063 <filename>stdout</filename>. They should take these 5 or 6 arguments:
1064 <emphasis>printer job user title copies options [filename]</emphasis>
1065 </para>
1067 <variablelist>
1068 <varlistentry><term>Printer</term>
1069 <listitem><para>The name of the printer queue (normally this is the
1070 name of the filter being run)</para></listitem>
1071 </varlistentry>
1073 <varlistentry><term>job</term>
1074 <listitem><para>The numeric job ID for the job being
1075 printed</para></listitem>
1076 </varlistentry>
1078 <varlistentry><term>user</term>
1079 <listitem><para>The string from the originating-user-name
1080 attribute</para></listitem>
1081 </varlistentry>
1083 <varlistentry><term>title</term>
1084 <listitem><para>The string from the job-name attribute</para></listitem>
1085 </varlistentry>
1087 <varlistentry><term>copies</term>
1088 <listitem><para>The numeric value from the number-copies
1089 attribute</para></listitem>
1090 </varlistentry>
1092 <varlistentry><term>options</term>
1093 <listitem><para>The job options</para></listitem>
1094 </varlistentry>
1096 <varlistentry><term>filename</term>
1097 <listitem><para>(Optionally) The print request file (if missing,
1098 filters expected data fed through <filename>stdin</filename>). In most
1099 cases it is very easy to write a simple wrapper script around existing
1100 filters to make them work with CUPS.</para></listitem>
1101 </varlistentry>
1102 </variablelist>
1103 </tip>
1104 </sect2>
1106 <sect2>
1107 <title>Prefilters</title>
1109 <indexterm><primary>PostScript</primary></indexterm>
1111 <para>
1112 As was said, PostScript is the central file format to any UNIX based
1113 printing system. From PostScript, CUPS generates raster data to feed
1114 non-PostScript printers.
1115 </para>
1117 <para>
1118 But what is happening if you send one of the supported non-PS formats
1119 to print? Then CUPS runs "pre-filters" on these input formats to
1120 generate PostScript first. There are pre-filters to create PS from
1121 ASCII text, PDF, DVI or HP-GL. The outcome of these filters is always
1122 of MIME type <emphasis>application/postscript</emphasis> (meaning that
1123 any device-specific print options are not yet embedded into the
1124 PostScript by CUPS, and that the next filter to be called is
1125 pstops). Another pre-filter is running on all supported image formats,
1126 the <emphasis>imagetops</emphasis> filter. Its outcome is always of
1127 MIME type <emphasis>application/vnd.cups-postscript</emphasis>
1128 (<emphasis>not</emphasis> application/postscript), meaning it has the
1129 print options already embedded into the file.
1130 </para>
1132 <para>
1133         <image scale="25"><imagedescription>Prefiltering in CUPS to form Postscript</imagedescription>
1134         <imagefile>4small</imagefile>
1135 </image>
1136 </para>
1137 </sect2>
1139 <sect2>
1140 <title>pstops</title>
1142 <para>
1143 <emphasis>pstops</emphasis>is the filter to convert
1144 <emphasis>application/postscript</emphasis> to
1145 <emphasis>application/vnd.cups-postscript</emphasis>. It was said
1146 above that this filter inserts all device-specific print options
1147 (commands to the printer to ask for the duplexing of output, or
1148 stapling an punching it, etc.) into the PostScript file.
1149 </para>
1151 <para>
1152         <image scale="25"><imagedescription>Adding Device-specific Print Options</imagedescription>
1153                 <imagefile>5small</imagefile>
1154         </image>
1155 </para>
1157 <para>
1158 This is not all: other tasks performed by it are:
1159 </para>
1161 <itemizedlist>
1162 <listitem><para>
1163 selecting the range of pages to be printed (if you choose to
1164 print only pages "3, 6, 8-11, 16, 19-21", or only the odd numbered
1165 ones)
1166 </para></listitem>
1168 <listitem><para>
1169 putting 2 or more logical pages on one sheet of paper (the
1170 so-called "number-up" function)
1171 </para></listitem>
1173 <listitem><para>counting the pages of the job to insert the accounting
1174 information into the <filename>/var/log/cups/page_log</filename>
1175 </para></listitem>
1176 </itemizedlist>
1177 </sect2>
1179 <sect2>
1180 <title>pstoraster</title>
1182 <para>
1183 <emphasis>pstoraster</emphasis> is at the core of the CUPS filtering
1184 system. It is responsible for the first stage of the rasterization
1185 process. Its input is of MIME type application/vnd.cups-postscript;
1186 its output is application/vnd.cups-raster. This output format is not
1187 yet meant to be printable. Its aim is to serve as a general purpose
1188 input format for more specialized <emphasis>raster drivers</emphasis>,
1189 that are able to generate device-specific printer data.
1190 </para>
1192 <para>
1193         <image scale="25"><imagedescription>Postscript to intermediate Raster format</imagedescription><imagefile>6small</imagefile></image>
1194 </para>
1196 <para>
1197 CUPS raster is a generic raster format with powerful features. It is
1198 able to include per-page information, color profiles and more to be
1199 used by the following downstream raster drivers. Its MIME type is
1200 registered with IANA and its specification is of course completely
1201 open. It is designed to make it very easy and inexpensive for
1202 manufacturers to develop Linux and UNIX raster drivers for their
1203 printer models, should they choose to do so. CUPS always takes care
1204 for the first stage of rasterization so these vendors don't need to care
1205 about Ghostscript complications (in fact, there is currently more
1206 than one vendor financing the development of CUPS raster drivers).
1207 </para>
1209 <para>
1210         <image><imagedescription>CUPS-raster production using Ghostscript</imagedescription>
1211                 <imagefile>7small</imagefile>
1212         </image>
1213 </para>
1215 <para>
1216 CUPS versions before version 1.1.15 were shipping a binary (or source
1217 code) standalone filter, named "pstoraster". pstoraster was derived
1218 from GNU Ghostscript 5.50, and could be installed besides and in
1219 addition to any GNU or AFPL Ghostscript package without conflicting.
1220 </para>
1222 <para>
1223 From version 1.1.15, this has changed. The functions for this has been
1224 integrated back into Ghostscript (now based on GNU Ghostscript version
1225 7.05). The "pstoraster" filter is now a simple shell script calling
1226 <command>gs</command> with the <command>-sDEVICE=cups</command>
1227 parameter. If your Ghostscript doesn't show a success on asking for
1228 <command>gs -h |grep cups</command>, you might not be able to
1229 print. Update your Ghostscript then!
1230 </para>
1231 </sect2>
1233 <sect2>
1234 <title>imagetops and imagetoraster</title>
1236 <para>
1237 Above in the section about prefilters, we mentioned the prefilter
1238 that generates PostScript from image formats. The imagetoraster
1239 filter is used to convert directly from image to raster, without the
1240 intermediate PostScript stage. It is used more often than the above
1241 mentioned prefilters. Here is a summarizing flowchart of image file
1242 filtering:
1243 </para>
1245 <para>
1246         <image><imagedescription>Image format to CUPS-raster format conversion</imagedescription>
1247                 <imagefile>8small</imagefile>
1248         </image>
1249 </para>
1251 </sect2>
1253 <sect2>
1254 <title>rasterto [printers specific]</title>
1256 <para>
1257 CUPS ships with quite some different raster drivers processing CUPS
1258 raster. On my system I find in /usr/lib/cups/filter/ these:
1259 <parameter>rastertoalps</parameter>, <parameter>rastertobj</parameter>, <parameter>rastertoepson</parameter>, <parameter>rastertoescp</parameter>,
1260 <parameter>rastertopcl</parameter>, <parameter>rastertoturboprint</parameter>, <parameter>rastertoapdk</parameter>, <parameter>rastertodymo</parameter>,
1261 <parameter>rastertoescp</parameter>, <parameter>rastertohp</parameter> and
1262 <parameter>rastertoprinter</parameter>. Don't worry if you have less
1263 than this; some of these are installed by commercial add-ons to CUPS
1264 (like <parameter>rastertoturboprint</parameter>), others (like
1265 <parameter>rastertoprinter</parameter>) by 3rd party driver
1266 development projects (such as Gimp-Print) wanting to cooperate as
1267 closely as possible with CUPS.
1268 </para>
1270 <para>
1271         <image><imagedescription>Raster to Printer Specific formats</imagedescription>
1272                 <imagefile>9small</imagefile>
1273         </image>
1274 </para>
1275 </sect2>
1277 <sect2>
1278 <title>CUPS Backends</title>
1280 <para>
1281 The last part of any CUPS filtering chain is a "backend".  Backends
1282 are special programs that send the print-ready file to the final
1283 device. There is a separate backend program for any transfer
1284 "protocol" of sending printjobs over the network, or for every local
1285 interface. Every CUPS printqueue needs to have a CUPS "device-URI"
1286 associated with it. The device URI is the way to encode the backend
1287 used to send the job to its destination. Network device-URIs are using
1288 two slashes in their syntax, local device URIs only one, as you can
1289 see from the following list. Keep in mind that local interface names
1290 may vary much from my examples, if your OS is not Linux:
1291 </para>
1293 <variablelist>
1294 <varlistentry><term>usb</term>
1295 <listitem><para>
1296 This backend sends printfiles to USB-connected printers. An
1297 example for the CUPS device-URI to use is:
1298 <filename>usb:/dev/usb/lp0</filename>
1299 </para></listitem></varlistentry>
1301 <varlistentry><term>serial</term>
1302 <listitem><para>
1303 This backend sends printfiles to serially connected printers.
1304 An example for the CUPS device-URI to use is:
1305 <filename>serial:/dev/ttyS0?baud=11500</filename>
1306 </para></listitem></varlistentry>
1308 <varlistentry><term>parallel</term>
1309 <listitem><para>
1310 This backend sends printfiles to printers connected to the
1311 parallel port. An example for the CUPS device-URI to use is:
1312 <filename>parallel:/dev/lp0</filename>
1313 </para></listitem></varlistentry>
1315 <varlistentry><term>scsi</term>
1316 <listitem><para>
1317 This backend sends printfiles to printers attached to the
1318 SCSI interface. An example for the CUPS device-URI to use is:
1319 <filename>scsi:/dev/sr1</filename>
1320 </para></listitem></varlistentry>
1322 <varlistentry><term>lpd</term>
1323 <listitem><para>
1324 This backend sends printfiles to LPR/LPD connected network
1325 printers. An example for the CUPS device-URI to use is:
1326 <filename>lpd://remote_host_name/remote_queue_name</filename>
1327 </para></listitem></varlistentry>
1329 <varlistentry><term>AppSocket/HP JetDirect</term>
1330 <listitem><para>
1331 This backend sends printfiles to AppSocket (a.k.a. "HP
1332 JetDirect") connected network printers. An example for the CUPS
1333 device-URI to use is:
1334 <filename>socket://10.11.12.13:9100</filename>
1335 </para></listitem></varlistentry>
1337 <varlistentry><term>ipp</term>
1338 <listitem><para>
1339 This backend sends printfiles to IPP connected network
1340 printers (or to other CUPS servers). Examples for CUPS device-URIs
1341 to use are:
1342 <filename>ipp:://192.193.194.195/ipp</filename>
1343 (for many HP printers) or
1344 <filename>ipp://remote_cups_server/printers/remote_printer_name</filename>
1345 </para></listitem></varlistentry>
1347 <varlistentry><term>http</term>
1348 <listitem><para>
1349 This backend sends printfiles to HTTP connected printers.
1350 (The http:// CUPS backend is only a symlink to the ipp:// backend.)
1351 Examples for the CUPS device-URIs to use are:
1352 <filename>http:://192.193.194.195:631/ipp</filename>
1353 (for many HP printers) or
1354 <filename>http://remote_cups_server:631/printers/remote_printer_name</filename>
1355 </para></listitem></varlistentry>
1357 <varlistentry><term>smb</term>
1358 <listitem><para>
1359 This backend sends printfiles to printers shared by a Windows
1360 host. An example for CUPS device-URIs to use are:
1361 <filename>smb://workgroup/server/printersharename</filename>
1363 <filename>smb://server/printersharename</filename>
1365 <filename>smb://username:password@workgroup/server/printersharename</filename>
1367 <filename>smb://username:password@server/printersharename</filename>.
1368 The smb:// backend is a symlink to the Samba utility
1369 <emphasis>smbspool</emphasis> (doesn't ship with CUPS). If the
1370 symlink is not present in your CUPS backend directory, have your
1371 root user create it: <command>ln -s `which smbspool`
1372 /usr/lib/cups/backend/smb</command>.
1373 </para></listitem></varlistentry>
1374 </variablelist>
1376 <para>
1377 It is easy to write your own backends as Shell or Perl scripts, if you
1378 need any modification or extension to the CUPS print system. One
1379 reason could be that you want to create "special" printers which send
1380 the printjobs as email (through a "mailto:/" backend), convert them to
1381 PDF (through a "pdfgen:/" backend) or dump them to "/dev/null" (In
1382 fact I have the system-wide default printer set up to be connected to
1383 a "devnull:/" backend: there are just too many people sending jobs
1384 without specifying a printer, or scripts and programs which don't name
1385 a printer. The system-wide default deletes the job and sends a polite
1386 mail back to the $USER asking him to always specify a correct
1387 printername).
1388 </para>
1390 <para>
1391 Not all of the mentioned backends may be present on your system or
1392 usable (depending on your hardware configuration). One test for all
1393 available CUPS backends is provided by the <emphasis>lpinfo</emphasis>
1394 utility. Used with the <option>-v</option> parameter, it lists
1395 all available backends:
1396 </para>
1398 <para><screen>
1399 &prompt;<userinput>lpinfo -v</userinput>
1400 </screen></para>
1401 </sect2>
1403 <sect2>
1404 <title>cupsomatic/Foomatic -- how do they fit into the Picture?</title>
1406 <indexterm><primary>cupsomatic</primary></indexterm>
1407 <indexterm><primary>foomatic</primary></indexterm>
1409 <para>
1410 "cupsomatic" filters may be the most widely used on CUPS
1411 installations. You must be clear about the fact that these were not
1412 developed by the CUPS people. They are a "Third Party" add-on to
1413 CUPS. They utilize the traditional Ghostscript devices to render jobs
1414 for CUPS. When troubleshooting, you should know about the
1415 difference. Here the whole rendering process is done in one stage,
1416 inside Ghostscript, using an appropriate "device" for the target
1417 printer. cupsomatic uses PPDs which are generated from the "Foomatic"
1418 Printer &amp; Driver Database at Linuxprinting.org.
1419 </para>
1421 <para>
1422 You can recognize these PPDs from the line calling the
1423 <emphasis>cupsomatic</emphasis> filter:
1424 </para>
1426 <para><screen>
1427  *cupsFilter: "application/vnd.cups-postscript  0  cupsomatic"
1428 </screen></para>
1430 <para>
1431 This line you may find amongst the first 40 or so lines of the PPD
1432 file. If you have such a PPD installed, the printer shows up in the
1433 CUPS web interface with a <emphasis>foomatic</emphasis> namepart for
1434 the driver description. cupsomatic is a Perl script that runs
1435 Ghostscript, with all the complicated commandline options
1436 auto-constructed from the selected PPD and commandline options give to
1437 the printjob.
1438 </para>
1440 <indexterm><primary>point and print</primary></indexterm>
1442 <para>
1443 However, cupsomatic is now deprecated. Its PPDs (especially the first
1444 generation of them, still in heavy use out there) are not meeting the
1445 Adobe specifications. You might also suffer difficulties when you try
1446 to download them with "Point'n'Print" to Windows clients. A better,
1447 and more powerful successor is now in a very stable Beta-version
1448 available: it is called <emphasis>foomatic-rip</emphasis>. To use
1449 foomatic-rip as a filter with CUPS, you need the new-type PPDs.  These
1450 have a similar, but different line:
1451 </para>
1453 <para><screen>
1455  *cupsFilter: "application/vnd.cups-postscript  0  foomatic-rip"
1457 </screen></para>
1459 <para>
1460 The PPD generating engine at Linuxprinting.org has been revamped.
1461 The new PPDs comply to the Adobe spec. On top, they also provide a
1462 new way to specify different quality levels (hi-res photo, normal
1463 color, grayscale, draft...) with a single click (whereas before you
1464 could have required 5 or more different selections (media type,
1465 resolution, inktype, dithering algorithm...). There is support for
1466 custom-size media built in. There is support to switch
1467 print-options from page to page, in the middle of a job. And the
1468 best thing is: the new foomatic-rip now works seamlessly with all
1469 legacy spoolers too (like LPRng, BSD-LPD, PDQ, PPR etc.), providing
1470 for them access to use PPDs for their printing!
1471 </para>
1472 </sect2>
1474 <sect2>
1475 <title>The Complete Picture</title>
1477 <para>
1478 If you want to see an overview over all the filters and how they
1479 relate to each other, the complete picture of the puzzle is at the end
1480 of this document.
1481 </para>
1482 </sect2>
1484 <sect2>
1485 <title><filename>mime.convs</filename></title>
1487 <para>
1488 CUPS auto-constructs all possible filtering chain paths for any given
1489 MIME type, and every printer installed. But how does it decide in
1490 favor or against a specific alternative?  (There may often be cases,
1491 where there is a choice of two or more possible filtering chains for
1492 the same target printer). Simple: you may have noticed the figures in
1493 the 3rd column of the mime.convs file. They represent virtual costs
1494 assigned to this filter. Every possible filtering chain will sum up to
1495 a total "filter cost". CUPS decides for the most "inexpensive" route.
1496 </para>
1498 <tip><para>
1499 The setting of <parameter>FilterLimit 1000</parameter> in
1500 <filename>cupsd.conf</filename> will not allow more filters to
1501 run concurrently than will consume a total of 1000 virtual filter
1502 cost. This is a very efficient way to limit the load of any CUPS
1503 server by setting an appropriate "FilterLimit" value. A FilterLimit of
1504 200 allows roughly 1 job at a time, while a FilterLimit of 1000 allows
1505 approximately 5 jobs maximum at a time.
1506 </para></tip>
1507 </sect2>
1509 <sect2>
1510 <title>"Raw" printing</title>
1512 <para>
1513 You can tell CUPS to print (nearly) any file "raw". "Raw" means it
1514 will not be filtered. CUPS will send the file to the printer "as is"
1515 without bothering if the printer is able to digest it. Users need to
1516 take care themselves that they send sensible data formats only. Raw
1517 printing can happen on any queue if the "-o raw" option is specified
1518 on the command line. You can also set up raw-only queues by simply not
1519 associating any PPD with it. This command:
1520 </para>
1522 <para><screen>
1523 &prompt;<userinput>lpadmin -P rawprinter -v socket://11.12.13.14:9100 -E</userinput>
1524 </screen></para>
1526 <para>
1527 sets up a queue named "rawprinter", connected via the "socket"
1528 protocol (a.k.a. "HP JetDirect") to the device at IP address
1529 11.12.1.3.14, using port 9100. (If you had added a PPD with
1530 <command>-P /path/to/PPD</command> to this command line, you would
1531 have installed a "normal" printqueue.
1532 </para>
1534 <para>
1535 CUPS will automatically treat each job sent to a queue as a "raw" one,
1536 if it can't find a PPD associated with the queue.  However, CUPS will
1537 only send known MIME types (as defined in its own mime.types file) and
1538 refuse others.
1539 </para>
1540 </sect2>
1542 <sect2>
1543 <title>"application/octet-stream" printing</title>
1545 <para>
1546 Any MIME type with no rule in the
1547 <filename>/etc/cups/mime.types</filename> file is regarded as unknown
1548 or <emphasis>application/octet-stream</emphasis> and will not be
1549 sent. Because CUPS refuses to print unknown MIME types per default,
1550 you will probably have experienced the fact that printjobs originating
1551 from Windows clients were not printed. You may have found an error
1552 message in your CUPS logs like:
1553 </para>
1555 <para><screen>
1556  Unable to convert file 0 to printable format for job
1557 </screen></para>
1559 <para>
1560 To enable the printing of "application/octet-stream" files, edit
1561 these two files:
1562 </para>
1564 <itemizedlist>
1565 <listitem><para><filename>/etc/cups/mime.convs</filename></para></listitem>
1567 <listitem><para><filename>/etc/cups/mime.types</filename></para></listitem>
1568 </itemizedlist>
1570 <para>
1571 Both contain entries (at the end of the respective files) which must
1572 be uncommented to allow RAW mode operation for
1573 application/octet-stream. In <filename>/etc/cups/mime.types</filename>
1574 make sure this line is present:
1575 </para>
1577 <indexterm><primary>application/octet-stream</primary></indexterm>
1579 <para><screen>
1580  application/octet-stream
1581 </screen></para>
1583 <para>
1584 This line (with no specific auto-typing rule set) makes all files
1585 not otherwise auto-typed a member of application/octet-stream. In
1586 <filename>/etc/cups/mime.convs</filename>, have this
1587 line: 
1588 </para>
1590 <para><screen>
1591  application/octet-stream   application/vnd.cups-raw   0   -
1592 </screen></para>
1594 <indexterm><primary>MIME</primary></indexterm>
1596 <para>
1597 This line tells CUPS to use the <emphasis>Null Filter</emphasis>
1598 (denoted as "-", doing... nothing at all) on
1599 <emphasis>application/octet-stream</emphasis>, and tag the result as
1600 <emphasis>application/vnd.cups-raw</emphasis>. This last one is
1601 always a green light to the CUPS scheduler to now hand the file over
1602 to the "backend" connecting to the printer and sending it over.
1603 </para>
1605 <note><para> Editing the <filename>mime.convs</filename> and the
1606 <filename>mime.types</filename> file does not
1607 <emphasis>enforce</emphasis> "raw" printing, it only
1608 <emphasis>allows</emphasis> it.
1609 </para></note>
1611 <formalpara>
1612 <title>Background</title>
1614 <para>
1615 CUPS being a more security-aware printing system than traditional ones
1616 does not by default allow one to send deliberate (possibly binary)
1617 data to printing devices.  (This could be easily abused to launch a
1618 Denial of Service attack on your printer(s), causing at least the loss
1619 of a lot of paper and ink...) "Unknown" data are regarded by CUPS
1620 as <emphasis>MIME type</emphasis>
1621 <emphasis>application/octet-stream</emphasis>. While you
1622 <emphasis>can</emphasis> send data "raw", the MIME type for these must
1623 be one that is known to CUPS and an allowed one. The file
1624 <filename>/etc/cups/mime.types</filename> defines the "rules" how CUPS
1625 recognizes MIME types. The file
1626 <filename>/etc/cups/mime.convs</filename> decides which file
1627 conversion filter(s) may be applied to which MIME types.
1628 </para>
1629 </formalpara>
1630 </sect2>
1632 <sect2>
1633 <title>PostScript Printer Descriptions (PPDs) for non-PS Printers</title>
1635 <indexterm><primary>PPD</primary></indexterm>
1637 <para>
1638 Originally PPDs were meant to be used for PostScript printers
1639 only. Here, they help to send device-specific commands and settings
1640 to the RIP which processes the jobfile. CUPS has extended this
1641 scope for PPDs to cover non-PostScript printers too. This was not
1642 very difficult, because it is a standardized file format. In a way
1643 it was logical too: CUPS handles PostScript and uses a PostScript
1644 RIP (=Ghostscript) to process the jobfiles. The only difference is:
1645 a PostScript printer has the RIP built-in, for other types of
1646 printers the Ghostscript RIP runs on the host computer.
1647 </para>
1649 <para>
1650 PPDs for a non-PS printer have a few lines that are unique to
1651 CUPS. The most important one looks similar to this:
1652 </para>
1654 <indexterm><primary>application/vnd.cups-raster</primary></indexterm>
1656 <para><screen>
1657  *cupsFilter: application/vnd.cups-raster  66   rastertoprinter
1658 </screen></para>
1660 <para>
1661 It is the last piece in the CUPS filtering puzzle. This line tells the
1662 CUPS daemon to use as a last filter "rastertoprinter".  This filter
1663 should be served as input an "application/vnd.cups-raster" MIME type
1664 file. Therefore CUPS should auto-construct a filtering chain, which
1665 delivers as its last output the specified MIME type. This is then
1666 taken as input to the specified "rastertoprinter" filter. After this
1667 the last filter has done its work ("rastertoprinter" is a Gimp-Print
1668 filter), the file should go to the backend, which sends it to the
1669 output device.
1670 </para>
1672 <para>
1673 CUPS by default ships only a few generic PPDs, but they are good for
1674 several hundred printer models. You may not be able to control
1675 different paper trays, or you may get larger margins than your
1676 specific model supports):
1677 </para>
1679 <table frame="all">
1680         <title>PPD's shipped with CUPS</title>
1681         <tgroup cols="2" align="left">
1682                 <colspec align="left"/>
1683                 <colspec align="justify" width="1*"/>
1684                 <thead><row><entry>PPD file</entry><entry>Printer type</entry></row></thead>
1685                 <tbody>
1686                         <row><entry>deskjet.ppd</entry><entry>older HP inkjet printers and compatible</entry></row>
1688                 <row><entry>deskjet2.ppd</entry> <entry>newer HP inkjet printers and compatible </entry> </row>
1690                 <row><entry>dymo.ppd</entry> <entry>label printers </entry> </row>
1692                 <row><entry>epson9.ppd</entry> <entry>Epson 24pin impact printers and compatible </entry> </row>
1694                 <row><entry>epson24.ppd</entry> <entry>Epson 24pin impact printers and compatible </entry> </row>
1696                 <row><entry>okidata9.ppd</entry> <entry>Okidata 9pin impact printers and compatible </entry> </row>
1698                 <row><entry>okidat24.ppd</entry> <entry>Okidata 24pin impact printers and compatible </entry> </row>
1700                 <row><entry>stcolor.ppd</entry> <entry>older Epson Stylus Color printers </entry> </row>
1702                 <row><entry>stcolor2.ppd</entry> <entry>newer Epson Stylus Color printers </entry> </row>
1704                 <row><entry>stphoto.ppd</entry> <entry>older Epson Stylus Photo printers </entry> </row>
1706                 <row><entry>stphoto2.ppd</entry> <entry>newer Epson Stylus Photo printers </entry> </row>
1708                 <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>
1710                 </tbody>
1711         </tgroup>
1712 </table>
1714 </sect2>
1716 <sect2>
1717 <title>Difference between <emphasis>cupsomatic/foomatic-rip</emphasis> and
1718 <emphasis>native CUPS</emphasis> printing</title>
1720 <indexterm><primary>cupsomatic</primary></indexterm>
1721 <indexterm><primary>foomatic-rip</primary></indexterm>
1723 <para>
1724 Native CUPS rasterization works in two steps.
1725 </para>
1727 <itemizedlist>
1728 <listitem><para>
1729 First is the "pstoraster" step. It uses the special "cups"
1730 <indexterm><primary>ESP</primary><secondary>Ghostscript</secondary></indexterm>
1731 device from ESP Ghostscript 7.05.x as its tool
1732 </para></listitem>
1734 <listitem><para>
1735 Second comes the "rasterdriver" step. It uses various
1736 device-specific filters; there are several vendors who provide good
1737 quality filters for this step, some are Free Software, some are
1738 Shareware/Non-Free, some are proprietary.</para></listitem>
1739 </itemizedlist>
1741 <para>
1742 Often this produces better quality (and has several more
1743 advantages) than other methods.
1744 </para>
1746 <para>
1747         <image><imagedescription>cupsomatic/foomatic processing versus Native CUPS</imagedescription>
1748                 <imagefile>10small</imagefile>
1749         </image>
1750 </para>
1752 <para>
1753 One other method is the <emphasis>cupsomatic/foomatic-rip</emphasis>
1754 way. Note that cupsomatic is <emphasis>not</emphasis> made by the CUPS
1755 developers. It is an independent contribution to printing development,
1756 made by people from Linuxprinting.org (see also <ulink
1757         noescape="1" url="http://www.cups.org/cups-help.html">http://www.cups.org/cups-help.html</ulink>).
1758 cupsomatic is no longer developed and maintained and is no longer
1759 supported. It has now been replaced by
1760 <emphasis>foomatic-rip</emphasis>. foomatic-rip is a complete re-write
1761 of the old cupsomatic idea, but very much improved and generalized to
1762 other (non-CUPS) spoolers. An upgrade to foomatic-rip is strongly
1763 advised, especially if you are upgrading to a recent version of CUPS
1764 too.
1765 </para>
1767 <para>
1768         <indexterm><primary>cupsomatic</primary></indexterm>
1769         <indexterm><primary>foomatic</primary></indexterm>
1770 Both the cupsomatic (old) and the foomatic-rip (new) methods from
1771 Linuxprinting.org use the traditional Ghostscript print file
1772 processing, doing everything in a single step. It therefore relies on
1773 all the other devices built-in into Ghostscript. The quality is as
1774 good (or bad) as Ghostscript rendering is in other spoolers. The
1775 advantage is that this method supports many printer models not
1776 supported (yet) by the more modern CUPS method.
1777 </para>
1779 <para>
1780 Of course, you can use both methods side by side on one system (and
1781 even for one printer, if you set up different queues), and find out
1782 which works best for you.
1783 </para>
1785 <para>
1786 cupsomatic "kidnaps" the printfile after the
1787 <emphasis>application/vnd.cups-postscript</emphasis> stage and
1788 deviates it through the CUPS-external, system wide Ghostscript
1789 installation: Therefore the printfile bypasses the "pstoraster" filter
1790 (and thus also bypasses the CUPS-raster-drivers
1791 "rastertosomething"). After Ghostscript finished its rasterization,
1792 cupsomatic hands the rendered file directly to the CUPS backend. The
1793 flowchart above illustrates the difference between native CUPS
1794 rendering and the Foomatic/cupsomatic method.
1795 </para>
1796 </sect2>
1798 <sect2>
1799 <title>Examples for filtering Chains</title>
1801 <para>
1802 Here are a few examples of commonly occurring filtering chains to
1803 illustrate the workings of CUPS.
1804 </para>
1806 <para>
1807 Assume you want to print a PDF file to a HP JetDirect-connected
1808 PostScript printer, but you want to print the pages 3-5, 7, 11-13
1809 only, and you want to print them "2-up" and "duplex":
1810 </para>
1812 <itemizedlist>
1813 <listitem><para>your print options (page selection as required, 2-up,
1814 duplex) are passed to CUPS on the commandline;</para></listitem>
1816 <listitem><para>the (complete) PDF file is sent to CUPS and autotyped as
1817 <emphasis>application/pdf</emphasis>;</para></listitem>
1819 <listitem><para>the file therefore first must pass the
1820 <emphasis>pdftops</emphasis> pre-filter, which produces PostScript
1821 MIME type <emphasis>application/postscript</emphasis> (a preview here
1822 would still show all pages of the original PDF);</para></listitem>
1824 <listitem><para>the file then passes the <emphasis>pstops</emphasis>
1825 filter which applies the commandline options: it selects the pages
1826 2-5, 7 and 11-13, creates and imposed layout "2 pages on 1 sheet" and
1827 inserts the correct "duplex" command (as is defined in the printer's
1828 PPD) into the new PostScript file; the file now is of PostScript MIME
1829 type
1830 <emphasis>application/vnd.cups-postscript</emphasis>;</para></listitem>
1832 <listitem><para>the file goes to the <emphasis>socket</emphasis>
1833 backend, which transfers the job to the printers.</para></listitem>
1834 </itemizedlist>
1836 <para>
1837         The resulting filter chain therefore is as drawn in <link linkend="pdftosocket"/>.
1838 </para>
1840 <image><imagefile>pdftosocket</imagefile><imagedescription>PDF to socket chain</imagedescription></image>
1842 <para>
1843 Assume your want to print the same filter to an USB-connected
1844 Epson Stylus Photo printer, installed with the CUPS
1845 <filename>stphoto2.ppd</filename>. The first few filtering stages
1846 are nearly the same:
1847 </para>
1849 <itemizedlist>
1850 <listitem><para>your print options (page selection as required, 2-up,
1851 duplex) are passed to CUPS on the commandline;</para></listitem>
1853 <listitem><para>the (complete) PDF file is sent to CUPS and autotyped as
1854 <emphasis>application/pdf</emphasis>;</para></listitem>
1856 <listitem><para>the file therefore first must pass the
1857 <emphasis>pdftops</emphasis> pre-filter, which produces PostScript
1858 MIME type <emphasis>application/postscript</emphasis> (a preview here
1859 would still show all pages of the original PDF);</para></listitem>
1861 <listitem><para>the file then passes the "pstops" filter which applies
1862 the commandline options: it selects the pages 2-5, 7 and 11-13,
1863 creates and imposed layout "2 pages on 1 sheet" and inserts the
1864 correct "duplex" command... (OOoops -- this printer and his PPD
1865 don't support duplex printing at all -- this option will be ignored
1866 then) into the new PostScript file; the file now is of PostScript
1867 MIME type 
1868 <emphasis>application/vnd.cups-postscript</emphasis>;</para></listitem>
1870 <listitem><para>the file then passes the
1871 <emphasis>pstoraster</emphasis> stage and becomes MIME type
1872 <emphasis>application/cups-raster</emphasis>;</para></listitem>
1874 <listitem><para>finally, the <emphasis>rastertoepson</emphasis> filter
1875 does its work (as is indicated in the printer's PPD), creating the
1876 printer-specific raster data and embedding any user-selected
1877 print-options into the print data stream;</para></listitem>
1879 <listitem><para>the file goes to the <emphasis>usb</emphasis> backend,
1880 which transfers the job to the printers.</para></listitem>
1881 </itemizedlist>
1883 <para>
1884         The resulting filter chain therefore is as drawn in <link linkend="pdftoepsonusb"/>.
1885 </para>
1887 <image><imagefile>pdftoepsonusb</imagefile><imagedescription>PDF to USB chain</imagedescription></image>
1888 </sect2>
1890 <sect2>
1891 <title>Sources of CUPS drivers / PPDs</title>
1893 <para>
1894 On the internet you can find now many thousand CUPS-PPD files
1895 (with their companion filters), in many national languages,
1896 supporting more than 1000 non-PostScript models.
1897 </para>
1899 <itemizedlist>
1900 <indexterm><primary>ESP</primary><secondary>Print Pro</secondary></indexterm>
1901 <indexterm><primary>PrintPro</primary><see>ESP Print Pro</see></indexterm>
1902 <listitem><para><ulink url="http://wwwl.easysw.com/printpro/">ESP
1903 PrintPro</ulink> (commercial,
1904 non-Free) is packaged with more than 3000 PPDs, ready for
1905 successful use "out of the box" on Linux, Mac OS X, IBM-AIX,
1906 HP-UX, Sun-Solaris, SGI-IRIX, Compaq Tru64, Digital UNIX and some
1907 more commercial Unices (it is written by the CUPS developers
1908 themselves and its sales help finance the further development of
1909 CUPS, as they feed their creators).</para></listitem>
1911 <listitem><para>the <ulink
1912 url="http://gimp-print.sourceforge.net/">Gimp-Print-Project
1913 </ulink> (GPL, Free Software)
1914 provides around 140 PPDs (supporting nearly 400 printers, many driven
1915 to photo quality output), to be used alongside the Gimp-Print CUPS
1916 filters;</para></listitem>
1918 <listitem><para><ulink url="http://www.turboprint.com/">TurboPrint
1919 </ulink> (Shareware, non-Free) supports
1920 roughly the same amount of printers in excellent
1921 quality;</para></listitem>
1923 <listitem><para><ulink
1924 url="http://www-124.ibm.com/developerworks/oss/linux/projects/omni/">OMNI
1925 </ulink>
1926 (LPGL, Free) is a package made by IBM, now containing support for more
1927 than 400 printers, stemming from the inheritance of IBM OS/2 Know-How
1928 ported over to Linux (CUPS support is in a Beta-stage at
1929 present);</para></listitem>
1931 <listitem><para><ulink url="http://hpinkjet.sourceforge.net/">HPIJS
1932 </ulink> (BSD-style licenses, Free)
1933 supports around 150 of HP's own printers and is also providing
1934 excellent print quality now (currently available only via the Foomatic
1935 path);</para></listitem>
1937 <listitem><para><ulink
1938 url="http://www.linuxprinting.org/">Foomatic/cupsomatic
1939 </ulink> (LPGL, Free) from
1940 Linuxprinting.org are providing PPDs for practically every Ghostscript
1941 filter known to the world (including Omni, Gimp-Print and
1942 HPIJS).</para></listitem>
1943 </itemizedlist>
1945 <note><para>
1946 The cupsomatic/Foomatic trick from Linuxprinting.org works
1947 differently from the other drivers. This is explained elsewhere in this
1948 document.
1949 </para></note>
1950 </sect2>
1952 <sect2>
1953 <title>Printing with Interface Scripts</title>
1955 <para>
1956 CUPS also supports the usage of "interface scripts" as known from
1957 System V AT&amp;T printing systems. These are often used for PCL
1958 printers, from applications that generate PCL print jobs.  Interface
1959 scripts are specific to printer models. They have a similar role as
1960 PPDs for PostScript printers. Interface scripts may inject the Escape
1961 sequences as required into the print data stream, if the user has
1962 chosen to select a certain paper tray, or print landscape, or use A3
1963 paper, etc. Interfaces scripts are practically unknown in the Linux
1964 realm. On HP-UX platforms they are more often used. You can use any
1965 working interface script on CUPS too. Just install the printer with
1966 the <command>-i</command> option:
1967 </para>
1969 <para><screen>
1970 &rootprompt;<userinput>lpadmin -p pclprinter -v socket://11.12.13.14:9100 \
1971   -i /path/to/interface-script</userinput>
1972 </screen></para>
1974 <para>
1975 Interface scripts might be the "unknown animal" to many.  However,
1976 with CUPS they provide the most easy way to plug in your own
1977 custom-written filtering script or program into one specific print
1978 queue (some information about the traditional usage of interface scripts is
1979 to be found at <ulink
1980         noescape="1" url="http://playground.sun.com/printing/documentation/interface.html">http://playground.sun.com/printing/documentation/interface.html</ulink>).
1981 </para>
1982 </sect2>
1983 </sect1>
1985 <sect1>
1986 <title>Network printing (purely Windows)</title>
1988 <para>
1989 Network printing covers a lot of ground. To understand what exactly
1990 goes on with Samba when it is printing on behalf of its Windows
1991 clients, let's first look at a "purely Windows" setup: Windows clients
1992 with a Windows NT print server.
1993 </para>
1995 <sect2>
1996 <title>From Windows Clients to an NT Print Server</title>
1998 <para>
1999 Windows clients printing to an NT-based print server have two
2000 options. They may
2001 </para>
2003 <indexterm><primary>GDI</primary></indexterm>
2004 <indexterm><primary>EMF</primary></indexterm>
2006 <itemizedlist>
2007 <listitem><para>execute the driver locally and render the GDI output
2008 (EMF) into the printer specific format on their own,
2009 or</para></listitem>
2011 <listitem><para>send the GDI output (EMF) to the server, where the
2012 driver is executed to render the printer specific
2013 output.</para></listitem>
2014 </itemizedlist>
2016 <para>
2017 Both print paths are shown in the flowcharts below.
2018 </para>
2019 </sect2>
2021 <sect2>
2022 <title>Driver Execution on the Client</title>
2024 <para>
2025 In the first case the print server must spool the file as "raw",
2026 meaning it shouldn't touch the jobfile and try to convert it in any
2027 way. This is what traditional UNIX-based print server can do too; and
2028 at a better performance and more reliably than NT print server. This
2029 is what most Samba administrators probably are familiar with. One
2030 advantage of this setup is that this "spooling-only" print server may
2031 be used even if no driver(s) for UNIX are available it is sufficient
2032 to have the Windows client drivers available and installed on the
2033 clients.
2034 </para>
2036 <para>
2037         <image><imagedescription>Print Driver execution on the Client</imagedescription>
2038                 <imagefile>11small</imagefile>
2039         </image>
2040 </para>
2041 </sect2>
2043 <sect2>
2044 <title>Driver Execution on the Server</title>
2046 <indexterm><primary>PostScript</primary></indexterm>
2047 <indexterm><primary>PCL</primary></indexterm>
2048 <indexterm><primary>ESC/P</primary></indexterm>
2049 <indexterm><primary>EMF</primary></indexterm>
2050 <indexterm><primary>GDI</primary></indexterm>
2052 <para>
2053 The other path executes the printer driver on the server. The clients
2054 transfers print files in EMF format to the server. The server uses the
2055 PostScript, PCL, ESC/P or other driver to convert the EMF file into
2056 the printer-specific language. It is not possible for UNIX to do the
2057 same. Currently there is no program or method to convert a Windows
2058 client's GDI output on a UNIX server into something a printer could
2059 understand.
2060 </para>
2062 <para>
2063         <image><imagedescription>Print Driver execution on the Server</imagedescription>
2064                 <imagefile>12small</imagefile>
2065         </image>
2066 </para>
2068 <para>
2069 However, there is something similar possible with CUPS. Read on...
2070 </para>
2071 </sect2>
2072 </sect1>
2074 <sect1>
2075 <title>Network Printing (Windows clients -- UNIX/Samba Print
2076 Servers)</title>
2078 <para>
2079 Since UNIX print servers <emphasis>cannot</emphasis> execute the Win32
2080 program code on their platform, the picture is somewhat
2081 different. However, this doesn't limit your options all that
2082 much. In the contrary, you may have a way here to implement printing
2083 features which are not possible otherwise.
2084 </para>
2086 <sect2>
2087 <title>From Windows Clients to a CUPS/Samba Print Server</title>
2089 <para>
2090 Here is a simple recipe showing how you can take advantage of CUPS
2091 powerful features for the benefit of your Windows network printing
2092 clients:
2093 </para>
2095 <itemizedlist>
2097 <listitem><para>Let the Windows clients send PostScript to the CUPS
2098 server.</para></listitem>
2100 <listitem><para>Let the CUPS server render the PostScript into device
2101 specific raster format.</para></listitem>
2102 </itemizedlist>
2104 <para>
2105 This requires the clients to use a PostScript driver (even if the
2106 printer is a non-PostScript model. It also requires that you have a
2107 "driver" on the CUPS server.
2108 </para>
2110 <para>
2111 Firstly, to enable CUPS based printing through Samba the
2112 following options should be set in your &smb.conf; file [global]
2113 section:
2114 </para>
2116 <itemizedlist>
2117 <listitem><para><smbconfoption><name>printing</name><value>cups</value></smbconfoption></para></listitem>
2119 <listitem><para><smbconfoption><name>printcap</name><value>cups</value></smbconfoption></para></listitem>
2120 </itemizedlist>
2122 <para>
2123 When these parameters are specified, all manually set print directives
2124 (like <smbconfoption><name>print command</name></smbconfoption>, or <smbconfoption><name>lppause command</name></smbconfoption>) in &smb.conf; (as well as
2125 in samba itself) will be ignored. Instead, Samba will directly
2126 interface with CUPS through it's application program interface (API) -
2127 as long as Samba has been compiled with CUPS library (libcups)
2128 support. If Samba has NOT been compiled with CUPS support, and if no
2129 other print commands are set up, then printing will use the
2130 <emphasis>System V</emphasis> AT&amp;T command set, with the -oraw
2131 option automatically passing through (if you want your own defined
2132 print commands to work with a Samba that has CUPS support compiled in,
2133 simply use <smbconfoption><name>printing</name><value>sysv</value></smbconfoption>).
2134 </para>
2136 <para>
2137 <image><imagedescription>Printing via CUPS/samba server</imagedescription>
2138         <imagefile>13small</imagefile>
2139 </image>
2140 </para>
2141 </sect2>
2143 <sect2>
2144 <title>Samba receiving Jobfiles and passing them to CUPS</title>
2146 <para>
2147 Samba <emphasis>must</emphasis> use its own spool directory (it is set
2148 by a line similar to <smbconfoption><name>path</name><value>/var/spool/samba</value></smbconfoption>,
2149 in the <smbconfsection>[printers]</smbconfsection> or
2150 <smbconfsection>[printername]</smbconfsection> section of
2151 &smb.conf;). Samba receives the job in its own
2152 spool space and passes it into the spool directory of CUPS (the CUPS
2153 spooling directory is set by the <parameter>RequestRoot</parameter>
2154 directive, in a line that defaults to <parameter>RequestRoot
2155 /var/spool/cups</parameter>).  CUPS checks the access rights of its
2156 spool dir and resets it to healthy values with every re-start. We have
2157 seen quite some people who had used a common spooling space for Samba
2158 and CUPS, and were struggling for weeks with this "problem".
2159 </para>
2161 <para>
2162 A Windows user authenticates only to Samba (by whatever means is
2163 configured). If Samba runs on the same host as CUPS, you only need to
2164 allow "localhost" to print. If they run on different machines, you
2165 need to make sure the Samba host gets access to printing on CUPS.
2166 </para>
2167 </sect2>
2168 </sect1>
2170 <sect1>
2171 <title>Network PostScript RIP: CUPS Filters on Server -- clients use
2172 PostScript Driver with CUPS-PPDs</title>
2174 <indexterm><primary>PostScript</primary></indexterm>
2175 <indexterm><primary>PCL</primary></indexterm>
2176 <indexterm><primary>PJL</primary></indexterm>
2178 <para>
2179 PPDs can control all print device options. They are usually provided
2180 by the manufacturer; if you own a PostScript printer, that is. PPD
2181 files (PostScript Printer Descriptions) are always a component of
2182 PostScript printer drivers on MS Windows or Apple Mac OS systems. They
2183 are ASCII files containing user-selectable print options, mapped to
2184 appropriate PostScript, PCL or PJL commands for the target
2185 printer. Printer driver GUI dialogs translate these options
2186 "on-the-fly" into buttons and drop-down lists for the user to select.
2187 </para>
2189 <para>
2190 CUPS can load, without any conversions, the PPD file from any Windows
2191 (NT is recommended) PostScript driver and handle the options. There is
2192 a web browser interface to the print options (select <ulink
2193 noescape="1" url="http://localhost:631/printers/">http://localhost:631/printers/</ulink>
2194 and click on one <emphasis>Configure Printer</emphasis> button to see
2195 it), or a commandline interface (see <command>man lpoptions</command>
2196 or see if you have lphelp on your system). There are also some
2197 different GUI frontends on Linux/UNIX, which can present PPD options
2198 to users. PPD options are normally meant to be evaluated by the
2199 PostScript RIP on the real PostScript printer.
2200 </para>
2202 <sect2>
2203 <title>PPDs for non-PS Printers on UNIX</title>
2205 <indexterm><primary>PPD</primary></indexterm>
2207 <para>
2208 CUPS doesn't limit itself to "real" PostScript printers in its usage
2209 of PPDs. The CUPS developers have extended the scope of the PPD
2210 concept, to also describe available device and driver options for
2211 non-PostScript printers through CUPS-PPDs.
2212 </para>
2214 <para>
2215 This is logical, as CUPS includes a fully featured PostScript
2216 interpreter (RIP). This RIP is based on Ghostscript. It can process
2217 all received PostScript (and additionally many other file formats)
2218 from clients. All CUPS-PPDs geared to non-PostScript printers contain
2219 an additional line, starting with the keyword
2220 <parameter>*cupsFilter</parameter> . This line tells the CUPS print
2221 system which printer-specific filter to use for the interpretation of
2222 the supplied PostScript. Thus CUPS lets all its printers appear as
2223 PostScript devices to its clients, because it can act as a PostScript
2224 RIP for those printers, processing the received PostScript code into a
2225 proper raster print format.
2226 </para>
2227 </sect2>
2229 <sect2>
2230 <title>PPDs for non-PS Printers on Windows</title>
2232 <indexterm><primary>PPD</primary></indexterm>
2233 <para>
2234 CUPS-PPDs can also be used on Windows-Clients, on top of a
2235 "core" PostScript driver (now recommended is the "CUPS PostScript
2236 Driver for WindowsNT/2K/XP"; you can also use the Adobe one, with
2237 limitations). This feature enables CUPS to do a few tricks no other
2238 spooler can do:
2239 </para>
2241 <itemizedlist>
2243 <listitem><para>act as a networked PostScript RIP (Raster Image
2244 Processor), handling printfiles from all client platforms in a uniform
2245 way;</para></listitem>
2247 <listitem><para>act as a central accounting and billing server, since
2248 all files are passed through the pstops filter and are therefore
2249 logged in the CUPS <filename>page_log</filename> file.
2250 <emphasis>NOTE:</emphasis> this can not happen with "raw" print jobs,
2251 which always remain unfiltered per definition;</para></listitem>
2253 <listitem><para>enable clients to consolidate on a single PostScript
2254 driver, even for many different target printers.</para></listitem>
2255 </itemizedlist>
2257 <para>
2258 Using CUPS PPDs on Windows clients enables these to control
2259 all print job settings just as a UNIX client can do too.
2260 </para>
2261 </sect2>
2262 </sect1>
2264 <sect1>
2265 <title>Windows Terminal Servers (WTS) as CUPS Clients</title>
2267 <para>
2268 This setup may be of special interest to people experiencing major
2269 problems in WTS environments. WTS need often a multitude of
2270 non-PostScript drivers installed to run their clients' variety of
2271 different printer models. This often imposes the price of much
2272 increased instability.
2273 </para>
2275 <sect2>
2276 <title>Printer Drivers running in "Kernel Mode" cause many
2277 Problems</title>
2279 <para>
2280 The reason is that in Win NT printer drivers run in "Kernel
2281 Mode", this introduces a high risk for the stability of the system
2282 if the driver is not really stable and well-tested. And there are a
2283 lot of bad drivers out there! Especially notorious is the example
2284 of the PCL printer driver that had an additional sound module
2285 running, to notify users via soundcard of their finished jobs. Do I
2286 need to say that this one was also reliably causing "Blue Screens
2287 of Death" on a regular basis?
2288 </para>
2290 <para>
2291 PostScript drivers generally are very well tested. They are not known
2292 to cause any problems, even though they run in Kernel Mode too. This
2293 might be because there have so far only been 2 different PostScript
2294 drivers: the ones from Adobe and the one from Microsoft. Both are
2295 very well tested and are as stable as you ever can imagine on
2296 Windows. The CUPS driver is derived from the Microsoft one.
2297 </para>
2298 </sect2>
2300 <sect2>
2301 <title>Workarounds impose Heavy Limitations</title>
2303 <para>
2304 In many cases, in an attempt to work around this problem, site
2305 administrators have resorted to restrict the allowed drivers installed
2306 on their WTS to one generic PCL- and one PostScript driver. This
2307 however restricts the clients in the amount of printer options
2308 available for them; often they can't get out more than simplex
2309 prints from one standard paper tray, while their devices could do much
2310 better, if driven by a different driver! )
2311 </para>
2312 </sect2>
2314 <sect2>
2315 <title>CUPS: a "Magical Stone"?</title>
2317 <indexterm><primary>PPD</primary></indexterm>
2318 <indexterm><primary>PostScript</primary></indexterm>
2320 <para>
2321 Using a PostScript driver, enabled with a CUPS-PPD, seems to be a very
2322 elegant way to overcome all these shortcomings. There are, depending
2323 on the version of Windows OS you use, up to 3 different PostScript
2324 drivers available: Adobe, Microsoft and CUPS PostScript drivers. None
2325 of them is known to cause major stability problems on WTS (even if
2326 used with many different PPDs). The clients will be able to (again)
2327 chose paper trays, duplex printing and other settings. However, there
2328 is a certain price for this too: a CUPS server acting as a PostScript
2329 RIP for its clients requires more CPU and RAM than when just acting as
2330 a "raw spooling" device.  Plus, this setup is not yet widely tested,
2331 although the first feedbacks look very promising.
2332 </para>
2333 </sect2>
2335 <sect2>
2336 <title>PostScript Drivers with no major problems -- even in Kernel
2337 Mode</title>
2339 <indexterm><primary>DDK</primary></indexterm>
2340 <para>
2341 More recent printer drivers on W2K and XP don't run in Kernel mode
2342 (unlike Win NT) any more. However, both operating systems can still
2343 use the NT drivers, running in Kernel mode (you can roughly tell which
2344 is which as the drivers in subdirectory "2" of "W32X86" are "old"
2345 ones).  As was said before, the Adobe as well as the Microsoft
2346 PostScript drivers are not known to cause any stability problems. The
2347 CUPS driver is derived from the Microsoft one. There is a simple
2348 reason for this: The MS DDK (Device Development Kit) for Win NT (which
2349 used to be available at no cost to licensees of Visual Studio)
2350 includes the source code of the Microsoft driver, and licensees of
2351 Visual Studio are allowed to use and modify it for their own driver
2352 development efforts. This is what the CUPS people have done. The
2353 license doesn't allow them to publish the whole of the source code.
2354 However, they have released the "diff" under the GPL, and if you are
2355 owner of an "MS DDK for Win NT", you can check the driver yourself.
2356 </para>
2357 </sect2>
2358 </sect1>
2360 <sect1>
2361 <title>Setting up CUPS for driver Download</title>
2363 <para>
2364 As we have said before: all previously known methods to prepare client
2365 printer drivers on the Samba server for download and "Point'n'Print"
2366 convenience of Windows workstations are working with CUPS too. These
2367 methods were described in the previous chapter. In reality, this is a
2368 pure Samba business, and only relates to the Samba/Win client
2369 relationship.
2370 </para>
2372 <sect2>
2373 <title><emphasis>cupsaddsmb</emphasis>: the unknown Utility</title>
2375 <indexterm><primary>cupsaddsmb</primary></indexterm>
2377 <para>
2378 The cupsaddsmb utility (shipped with all current CUPS versions) is an
2379 alternative method to transfer printer drivers into the Samba
2380 <smbconfsection>[print$]</smbconfsection> share. Remember, this share is where
2381 clients expect drivers deposited and setup for download and
2382 installation.  It makes the sharing of any (or all) installed CUPS
2383 printers very easy. cupsaddsmb can use the Adobe PostScript driver as
2384 well as the newly developed <emphasis>CUPS PostScript Driver for
2385 WinNT/2K/XP</emphasis>. Note, that cupsaddsmb does
2386 <emphasis>not</emphasis> work with arbitrary vendor printer drivers,
2387 but only with the <emphasis>exact</emphasis> driver files that are
2388 named in its man page.
2389 </para>
2391 <para>
2392 The CUPS printer driver is available from the CUPS download site. Its
2393 package name is <filename>cups-samba-[version].tar.gz</filename> . It
2394 is preferred over the Adobe drivers since it has a number of
2395 advantages:
2396 </para>
2398 <itemizedlist>
2399 <listitem><para>it supports a much more accurate page
2400 accounting;</para></listitem>
2402 <listitem><para>it supports banner pages, and page labels on all
2403 printers;</para></listitem>
2405 <listitem><para>it supports the setting of a number of job IPP
2406 attributes (such as job-priority, page-label and
2407 job-billing)</para></listitem>
2408 </itemizedlist>
2410 <para>
2411 However, currently only Windows NT, 2000, and XP are supported by the
2412 CUPS drivers. You will need to get the respective part of Adobe driver
2413 too if you need to support Windows 95, 98, and ME clients.
2414 </para>
2415 </sect2>
2417 <sect2>
2418 <title>Prepare your &smb.conf; for cupsaddsmb</title>
2420 <para>
2421 Prior to running cupsaddsmb, you need the following settings in
2422 &smb.conf;:
2423 </para>
2425 <para><smbconfexample>
2426                 <title>smb.conf for cupsaddsmb usage</title>
2427 <smbconfsection>[global]</smbconfsection>
2428 <smbconfoption><name>load printers</name><value>yes</value></smbconfoption>
2429 <smbconfoption><name>printing</name><value>cups</value></smbconfoption>
2430 <smbconfoption><name>printcap name</name><value>cups</value></smbconfoption>
2432 <smbconfsection>[printers]</smbconfsection>
2433 <smbconfoption><name>comment</name><value>All Printers</value></smbconfoption>
2434 <smbconfoption><name>path</name><value>/var/spool/samba</value></smbconfoption>
2435 <smbconfoption><name>browseable</name><value>no</value></smbconfoption>
2436 <smbconfoption><name>public</name><value>yes</value></smbconfoption>
2437 <smbconfcomment>setting depends on your requirements</smbconfcomment>
2438 <smbconfoption><name>guest ok</name><value>yes</value></smbconfoption>
2439 <smbconfoption><name>writable</name><value>no</value></smbconfoption>
2440 <smbconfoption><name>printable</name><value>yes</value></smbconfoption>
2441 <smbconfoption><name>printer admin</name><value>root</value></smbconfoption>
2442  <smbconfsection>[print$]</smbconfsection>
2443 <smbconfoption><name>comment</name><value>Printer Drivers</value></smbconfoption>
2444 <smbconfoption><name>path</name><value>/etc/samba/drivers</value></smbconfoption>
2445 <smbconfoption><name>browseable</name><value>yes</value></smbconfoption>
2446 <smbconfoption><name>guest ok</name><value>no</value></smbconfoption>
2447 <smbconfoption><name>read only</name><value>yes</value></smbconfoption>
2448 <smbconfoption><name>write list</name><value>root</value></smbconfoption>
2449 </smbconfexample></para>
2450 </sect2>
2452 <sect2>
2453 <title>CUPS Package of "PostScript Driver for WinNT/2k/XP"</title>
2454 <indexterm><primary>PostScript</primary></indexterm>
2456 <para>
2457 CUPS users may get the exactly same packages from <ulink
2458 noescape="1" url="http://www.cups.org/software.html">http://www.cups.org/software.html</ulink>.
2459 It is a separate package from the CUPS base software files, tagged as
2460 <emphasis>CUPS 1.1.x Windows NT/2k/XP Printer Driver for Samba
2461 (tar.gz, 192k)</emphasis>. The filename to download is
2462 <filename>cups-samba-1.1.x.tar.gz</filename>. Upon untar-/unzip-ing,
2463 it will reveal these files:
2464 </para>
2466 <para><screen>
2467 &rootprompt;<userinput>tar xvzf cups-samba-1.1.19.tar.gz</userinput>
2468 cups-samba.install
2469 cups-samba.license
2470 cups-samba.readme
2471 cups-samba.remove
2472 cups-samba.ss
2473 </screen></para>
2475 <para>
2476 <indexterm><primary>ESP</primary><secondary>meta packager</secondary></indexterm>
2477 <indexterm><primary>EPM</primary><see>ESP meta packager</see></indexterm>
2478 These have been packaged with the ESP meta packager software
2479 "EPM". The <filename>*.install</filename> and
2480 <filename>*.remove</filename> files are simple shell scripts, which
2481 untars the <filename>*.ss</filename> (the <filename>*.ss</filename> is
2482 nothing else but a tar-archive, which can be untar-ed by "tar"
2483 too). Then it puts the content into
2484 <filename>/usr/share/cups/drivers/</filename>. This content includes 3
2485 files:
2486 </para>
2488 <para><screen>
2489 &rootprompt;<userinput>tar tv cups-samba.ss</userinput>
2490 cupsdrvr.dll
2491 cupsui.dll
2492 cups.hlp  
2493 </screen></para>
2495 <para>
2496 The <emphasis>cups-samba.install</emphasis> shell scripts is easy to
2497 handle:
2498 </para>
2500 <para><screen>
2501 &rootprompt;<userinput>./cups-samba.install</userinput>
2502 [....]
2503 Installing software...
2504 Updating file permissions...
2505 Running post-install commands...
2506 Installation is complete.        
2507 </screen></para>
2509 <para>
2510 The script should automatically put the driver files into the
2511 <filename>/usr/share/cups/drivers/</filename> directory.
2512 </para>
2514 <warning><para>
2515 Due to a bug, one recent CUPS release puts the
2516 <filename>cups.hlp</filename> driver file
2517 into<filename>/usr/share/drivers/</filename> instead of
2518 <filename>/usr/share/cups/drivers/</filename>. To work around this,
2519 copy/move the file (after running the
2520 <command>./cups-samba.install</command> script) manually to the
2521 right place.
2522 </para></warning>
2524 <para><screen>
2525 &rootprompt;<userinput>cp /usr/share/drivers/cups.hlp /usr/share/cups/drivers/</userinput>
2526 </screen></para>
2528 <indexterm><primary>DDK</primary></indexterm>
2530 <para>
2531 This new CUPS PostScript driver is currently binary-only, but free of
2532 charge. No complete source code is provided (yet). The reason is this:
2533 it has been developed with the help of the <emphasis>Microsoft Driver
2534 Developer Kit</emphasis> (DDK) and compiled with Microsoft Visual
2535 Studio 6. Driver developers are not allowed to distribute the whole of
2536 the source code as Free Software. However, CUPS developers released
2537 the "diff" in source code under the GPL, so anybody with a license of
2538 Visual Studio and a DDK will be able to compile for him/herself.
2539 </para>
2540 </sect2>
2542 <sect2>
2543 <title>Recognize the different Driver Files</title>
2545 <para>
2546 The CUPS drivers don't support the "older" Windows 95/98/ME, but only
2547 the Windows NT/2000/XP client:
2548 </para>
2550 <para>Windows NT, 2000, and XP are supported by:</para>
2552 <para>
2553         <itemizedlist>
2554                 <listitem><para>cups.hlp</para></listitem>
2555                 <listitem><para>cupsdrvr.dll</para></listitem>
2556                 <listitem><para>cupsui.dll</para></listitem>
2557         </itemizedlist>
2558 </para>
2560 <para>
2561 Adobe drivers are available for the older Windows 95/98/ME as well as
2562 the Windows NT/2000/XP clients. The set of files is different for the
2563 different platforms.
2564 </para>
2566 <para>Windows 95, 98, and Me are supported by:</para>
2568 <para>
2569         <itemizedlist>
2570         <listitem><para>ADFONTS.MFM</para></listitem>
2571         <listitem><para>ADOBEPS4.DRV</para></listitem>
2572         <listitem><para>ADOBEPS4.HLP</para></listitem>
2573         <listitem><para>DEFPRTR2.PPD</para></listitem>
2574         <listitem><para>ICONLIB.DLL</para></listitem>
2575         <listitem><para>PSMON.DLL</para></listitem>
2576 </itemizedlist>
2577 </para>
2579 <para>Windows NT, 2000, and XP are supported by:</para>
2581 <para>
2582 <itemizedlist>
2583         <listitem><para>ADOBEPS5.DLL</para></listitem>
2584         <listitem><para>ADOBEPSU.DLL</para></listitem>
2585         <listitem><para>ADOBEPSU.HLP</para></listitem>
2586 </itemizedlist>
2588 </para>
2590 <note><para>
2591 If both, the Adobe driver files and the CUPS driver files for the
2592 support of WinNT/2k/XP are present in , the Adobe ones will be ignored
2593 and the CUPS ones will be used. If you prefer -- for whatever reason
2594 -- to use Adobe-only drivers, move away the 3 CUPS driver files. The
2595 Win95/98/ME clients use the Adobe drivers in any case.
2596 </para></note>
2597 </sect2>
2599 <sect2>
2600 <title>Acquiring the Adobe Driver Files</title>
2602 <para>
2603 Acquiring the Adobe driver files seems to be unexpectedly difficult
2604 for many users. They are not available on the Adobe website as single
2605 files and the self-extracting and/or self-installing Windows-exe is
2606 not easy to locate either. Probably you need to use the included
2607 native installer and run the installation process on one client
2608 once. This will install the drivers (and one Generic PostScript
2609 printer) locally on the client.  When they are installed, share the
2610 Generic PostScript printer.  After this, the client's
2611 <smbconfsection>[print$]</smbconfsection> share holds the Adobe files, from
2612 where you can get them with smbclient from the CUPS host. A more
2613 detailed description about this is in the next (the CUPS printing)
2614 chapter.
2615 </para>
2616 </sect2>
2618 <sect2>
2619 <title>ESP Print Pro Package of "PostScript Driver for
2620 WinNT/2k/XP"</title>
2623 <indexterm><primary>ESP</primary><secondary>Print Pro</secondary></indexterm>
2625 <para>
2626 Users of the ESP Print Pro software are able to install their "Samba
2627 Drivers" package for this purpose with no problem. Retrieve the driver
2628 files from the normal download area of the ESP Print Pro software
2629 at <ulink
2630         noescape="1" url="http://www.easysw.com/software.html">http://www.easysw.com/software.html</ulink>.
2631 You need to locate the link labelled "SAMBA" amongst the
2632 <emphasis>Download Printer Drivers for ESP Print Pro 4.x</emphasis>
2633 area and download the package. Once installed, you can prepare any
2634 driver by simply highlighting the printer in the Printer Manager GUI
2635 and select <emphasis>Export Driver...</emphasis> from the menu. Of
2636 course you need to have prepared Samba beforehand too to handle the
2637 driver files; i.e.  mainly setup the <smbconfsection>[print$]</smbconfsection>
2638 share, etc. The ESP Print Pro package includes the CUPS driver files
2639 as well as a (licensed) set of Adobe drivers for the Windows 95/98/ME
2640 client family.
2641 </para>
2642 </sect2>
2644 <sect2>
2645 <title>Caveats to be considered</title>
2647 <indexterm><primary>cupsaddsmb</primary></indexterm>
2649 <para>
2650 Once you have run the install script (and possibly manually
2651 moved the <filename>cups.hlp</filename> file to
2652 <filename>/usr/share/cups/drivers/</filename>), the driver is
2653 ready to be put into Samba's <smbconfsection>[print$]</smbconfsection> share (which often maps to
2654 <filename>/etc/samba/drivers/</filename> and contains a subdir
2655 tree with <emphasis>WIN40</emphasis> and
2656 <emphasis>W32X86</emphasis> branches): You do this by running
2657 "cupsaddsmb" (see also <command>man cupsaddsmb</command> for
2658 CUPS since release 1.1.16).
2659 </para>
2661 <tip><para>
2662 <indexterm><primary>Single Sign On</primary></indexterm>
2663 You may need to put root into the smbpasswd file by running
2664 <command>smbpasswd</command>; this is especially important if you
2665 should run this whole procedure for the first time, and are not
2666 working in an environment where everything is configured for
2667 <emphasis>Single Sign On</emphasis> to a Windows Domain Controller.
2668 </para></tip>
2670 <para>
2671 Once the driver files are in the <smbconfsection>[print$]</smbconfsection> share
2672 and are initialized, they are ready to be downloaded and installed by
2673 the Win NT/2k/XP clients.
2674 </para>
2676 <note><para>
2677 <orderedlist>
2678 <listitem><para>
2679 Win 9x/ME clients won't work with the CUPS PostScript driver. For
2680 these you'd still need to use the <filename>ADOBE*.*</filename>
2681 drivers as previously.
2682 </para></listitem>
2684 <listitem><para>
2685 It is not harmful if you still have the
2686 <filename>ADOBE*.*</filename> driver files from previous
2687 installations in the <filename>/usr/share/cups/drivers/</filename>
2688 directory. The new <emphasis>cupsaddsmb</emphasis> (from 1.1.16) will
2689 automatically prefer "its own" drivers if it finds both.
2690 </para></listitem>
2692 <listitem><para>
2693 <indexterm><primary>"Printers" folder</primary></indexterm>
2694 Should your Win clients have had the old <filename>ADOBE*.*</filename>
2695 files for the Adobe PostScript driver installed, the download and
2696 installation of the new CUPS PostScript driver for Windows NT/2k/XP
2697 will fail at first. You need to wipe the old driver from the clients
2698 first. It is not enough to "delete" the printer, as the driver files
2699 will still be kept by the clients and re-used if you try to re-install
2700 the printer. To really get rid of the Adobe driver files on the
2701 clients, open the "Printers" folder (possibly via <emphasis>Start, Settings, Control Panel, Printers</emphasis>),
2702 right-click onto the folder background and select <emphasis>Server
2703 Properties</emphasis>. When the new dialog opens, select the
2704 <emphasis>Drivers</emphasis> tab. On the list select the driver you
2705 want to delete and click on the <emphasis>Delete</emphasis>
2706 button. This will only work if there is not one single printer left
2707 which uses that particular driver. You need to "delete" all printers
2708 using this driver in the "Printers" folder first. You will need
2709 Administrator privileges to do this.
2710 </para></listitem>
2712 <listitem><para>
2713 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
2714 Once you have successfully downloaded the CUPS PostScript driver to a
2715 client, you can easily switch all printers to this one by proceeding
2716 as described in <link linkend="printing"/>: either change
2717 a driver for an existing printer by running the "Printer Properties"
2718 dialog, or use <command>rpcclient</command> with the
2719 <command>setdriver</command> sub-command.
2720 </para></listitem>
2721 </orderedlist>
2722 </para></note>
2723 </sect2>
2725 <sect2>
2726 <title>Benefits of using "CUPS PostScript Driver for
2727 Windows NT/2k/XP" instead of Adobe Driver</title>
2729 <para>
2730 You are interested in a comparison between the CUPS and the Adobe
2731 PostScript drivers? For our purposes these are the most important
2732 items which weigh in favor of the CUPS ones:
2733 </para>
2735 <itemizedlist>
2736 <listitem><para>no hassle with the Adobe EULA</para></listitem>
2738 <listitem><para>no hassle with the question <quote>Where do I
2739 get the ADOBE*.* driver files from?</quote></para></listitem>
2741 <indexterm><primary>PJL</primary></indexterm>
2742 <listitem><para>the Adobe drivers (on request of the printer PPD
2743 associated with them) often put a PJL header in front of the main
2744 PostScript part of the print file. Thus the printfile starts with
2745 <parameter>&lt;1B &gt;%-12345X</parameter> or
2746 <parameter>&lt;escape&gt;%-12345X</parameter> instead
2747 of <parameter>%!PS</parameter>). This leads to the
2748 CUPS daemon auto-typing the incoming file as a print-ready file,
2749 not initiating a pass through the "pstops" filter (to speak more
2750 technically, it is not regarded as the generic MIME type 
2751 <indexterm><primary>application/postscript</primary></indexterm>
2752 <emphasis>application/postscript</emphasis>, but as
2753 the more special MIME type
2754 <indexterm><primary>application/cups.vnd-postscript</primary></indexterm>
2755 <emphasis>application/cups.vnd-postscript</emphasis>),
2756 which therefore also leads to the page accounting in
2757 <emphasis>/var/log/cups/page_log</emphasis> not
2758 receiving the exact number of pages; instead the dummy page number
2759 of "1" is logged in a standard setup)</para></listitem>
2761 <listitem><para>the Adobe driver has more options to "mis-configure" the
2762 PostScript generated by it (like setting it inadvertently to
2763 <emphasis>Optimize for Speed</emphasis>, instead of
2764 <emphasis>Optimize for Portability</emphasis>, which
2765 could lead to CUPS being unable to process it)</para></listitem>
2767 <listitem><para>the CUPS PostScript driver output sent by Windows
2768 clients to the CUPS server will be guaranteed to be auto-typed always
2769 as generic MIME type <emphasis>application/postscript</emphasis>,
2770 thusly passing through the CUPS "pstops" filter and logging the
2771 correct number of pages in the <filename>page_log</filename> for
2772 accounting and quota purposes</para></listitem>
2774 <listitem><para>the CUPS PostScript driver supports the sending of
2775 additional standard (IPP) print options by Win NT/2k/XP clients.  Such
2776 additional print options are: naming the CUPS standard
2777 <emphasis>banner pages</emphasis> (or the custom ones, should they be
2778 installed at the time of driver download), using the CUPS
2779 <emphasis>page-label</emphasis> option, setting a
2780 <emphasis>job-priority</emphasis> and setting the <emphasis>scheduled
2781 time of printing</emphasis> (with the option to support additional
2782 useful IPP job attributes in the future).</para></listitem>
2784 <listitem><para>the CUPS PostScript driver supports the inclusion of
2785 the new <emphasis>*cupsJobTicket</emphasis> comments at the
2786 beginning of the PostScript file (which could be used in the future
2787 for all sort of beneficial extensions on the CUPS side, but which will
2788 not disturb any other applications as they will regard it as a comment
2789 and simply ignore it).</para></listitem>
2791 <listitem><para>the CUPS PostScript driver will be the heart of the
2792 fully fledged CUPS IPP client for Windows NT/2K/XP to be released soon
2793 (probably alongside the first Beta release for CUPS
2794 1.2).</para></listitem>
2795 </itemizedlist>
2797 </sect2>
2799 <sect2>
2800 <title>Run "cupsaddsmb" (quiet Mode)</title>
2802 <indexterm><primary>cupsaddsmb</primary></indexterm>
2803 <indexterm><primary>point and print</primary></indexterm>
2805 <para>
2806 The cupsaddsmb command copies the needed files into your
2807 <smbconfsection>[print$]</smbconfsection> share. Additionally, the PPD
2808 associated with this printer is copied from
2809 <filename>/etc/cups/ppd/</filename> to
2810 <smbconfsection>[print$]</smbconfsection>. There the files wait for convenient
2811 Windows client installations via Point'n'Print. Before we can run the
2812 command successfully, we need to be sure that we can authenticate
2813 towards Samba. If you have a small network you are probably using user
2814 level security (<smbconfoption><name>security</name><value>user</value></smbconfoption>). 
2815 </para>
2817 <para>
2818 Here is an example of a successfully run cupsaddsmb command. 
2819 </para>
2821 <para><screen>
2822 &rootprompt;<userinput>cupsaddsmb -U root infotec_IS2027</userinput>
2823 Password for root required to access localhost via Samba: <userinput>['secret']</userinput>
2824 </screen></para>
2826 <para>
2827 To share <emphasis>all</emphasis> printers and drivers, use the
2828 <option>-a</option> parameter instead of a printer name. Since
2829 cupsaddsmb "exports" the printer drivers to Samba, it should be
2830 obvious that it only works for queues with a CUPS driver associated.
2831 </para>
2832 </sect2>
2834 <sect2>
2835 <title>Run "cupsaddsmb" with verbose Output</title>
2837 <indexterm><primary>cupsaddsmb</primary></indexterm>
2839 <para>
2840 Probably you want to see what's going on. Use the
2841 <option>-v</option> parameter to get a more verbose output. The
2842 output below was edited for better readability: all "\" at the end of
2843 a line indicate that I inserted an artificial line break plus some
2844 indentation here:
2845 </para>
2847 <warning><para>
2848 You will see the root password for the Samba account printed on
2849 screen. 
2850 </para></warning>
2852 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
2853 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
2854 <para><screen>
2855 &rootprompt;<userinput>cupsaddsmb -U root -v infotec_2105</userinput>
2856 Password for root required to access localhost via &example.server.samba;:
2857 Running command: smbclient //localhost/print\$ -N -U'root%secret' \
2858     -c 'mkdir W32X86; \
2859     put /var/spool/cups/tmp/3e98bf2d333b5 W32X86/infotec_2105.ppd; \
2860         put /usr/share/cups/drivers/cupsdrvr.dll W32X86/cupsdrvr.dll; \
2861     put /usr/share/cups/drivers/cupsui.dll W32X86/cupsui.dll; \
2862     put /usr/share/cups/drivers/cups.hlp W32X86/cups.hlp'
2863 added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
2864 Domain=[CUPS-PRINT] OS=[UNIX] Server=[Samba 2.2.7a]
2865 NT_STATUS_OBJECT_NAME_COLLISION making remote directory \W32X86
2866 putting file /var/spool/cups/tmp/3e98bf2d333b5 as \W32X86/infotec_2105.ppd
2867 putting file /usr/share/cups/drivers/cupsdrvr.dll as \W32X86/cupsdrvr.dll
2868 putting file /usr/share/cups/drivers/cupsui.dll as \W32X86/cupsui.dll
2869 putting file /usr/share/cups/drivers/cups.hlp as \W32X86/cups.hlp
2870   
2871 Running command: rpcclient localhost -N -U'root%secret' 
2872    -c 'adddriver "Windows NT x86"   \
2873    "infotec_2105:cupsdrvr.dll:infotec_2105.ppd:cupsui.dll:cups.hlp:NULL:   \
2874     RAW:NULL"'
2875 cmd = adddriver "Windows NT x86" \
2876     "infotec_2105:cupsdrvr.dll:infotec_2105.ppd:cupsui.dll:cups.hlp:NULL:RAW:NULL"
2877 Printer Driver infotec_2105 successfully installed.
2878   
2879 Running command: smbclient //localhost/print\$ -N -U'root%secret' \
2880 -c 'mkdir WIN40; \
2881     put /var/spool/cups/tmp/3e98bf2d333b5 WIN40/infotec_2105.PPD; \
2882         put /usr/share/cups/drivers/ADFONTS.MFM WIN40/ADFONTS.MFM;   \
2883     put /usr/share/cups/drivers/ADOBEPS4.DRV WIN40/ADOBEPS4.DRV; \
2884     put /usr/share/cups/drivers/ADOBEPS4.HLP WIN40/ADOBEPS4.HLP; \
2885     put /usr/share/cups/drivers/DEFPRTR2.PPD WIN40/DEFPRTR2.PPD; \
2886         put /usr/share/cups/drivers/ICONLIB.DLL WIN40/ICONLIB.DLL; \
2887         put /usr/share/cups/drivers/PSMON.DLL WIN40/PSMON.DLL;'
2888   added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
2889   Domain=[CUPS-PRINT] OS=[UNIX] Server=[Samba 2.2.7a]
2890   NT_STATUS_OBJECT_NAME_COLLISION making remote directory \WIN40
2891   putting file /var/spool/cups/tmp/3e98bf2d333b5 as \WIN40/infotec_2105.PPD
2892   putting file /usr/share/cups/drivers/ADFONTS.MFM as \WIN40/ADFONTS.MFM
2893   putting file /usr/share/cups/drivers/ADOBEPS4.DRV as \WIN40/ADOBEPS4.DRV
2894   putting file /usr/share/cups/drivers/ADOBEPS4.HLP as \WIN40/ADOBEPS4.HLP
2895   putting file /usr/share/cups/drivers/DEFPRTR2.PPD as \WIN40/DEFPRTR2.PPD
2896   putting file /usr/share/cups/drivers/ICONLIB.DLL as \WIN40/ICONLIB.DLL
2897   putting file /usr/share/cups/drivers/PSMON.DLL as \WIN40/PSMON.DLL
2898   
2899   Running command: rpcclient localhost -N -U'root%secret' \
2900    -c 'adddriver "Windows 4.0"      \
2901    "infotec_2105:ADOBEPS4.DRV:infotec_2105.PPD:NULL:ADOBEPS4.HLP: \
2902    PSMON.DLL:RAW:ADOBEPS4.DRV,infotec_2105.PPD,ADOBEPS4.HLP,PSMON.DLL, \
2903     ADFONTS.MFM,DEFPRTR2.PPD,ICONLIB.DLL"'
2904   cmd = adddriver "Windows 4.0" "infotec_2105:ADOBEPS4.DRV:infotec_2105.PPD:NULL:          \
2905     ADOBEPS4.HLP:PSMON.DLL:RAW:ADOBEPS4.DRV,infotec_2105.PPD,ADOBEPS4.HLP,  \
2906                    PSMON.DLL,ADFONTS.MFM,DEFPRTR2.PPD,ICONLIB.DLL"
2907   Printer Driver infotec_2105 successfully installed.
2908   
2909   Running command: rpcclient localhost -N -U'root%secret'  \
2910    -c 'setdriver infotec_2105 infotec_2105'
2911   cmd = setdriver infotec_2105 infotec_2105
2912   Successfully set infotec_2105 to driver infotec_2105.
2914 </screen></para>
2916 <para>
2917 If you look closely, you'll discover your root password was transferred
2918 unencrypted over the wire, so beware! Also, if you look further her,
2919 you'll discover error messages like NT_STATUS_OBJECT_NAME_COLLISION in
2920 between. They occur, because the directories WIN40 and W32X86 already
2921 existed in the <smbconfsection>[print$]</smbconfsection> driver download share
2922 (from a previous driver installation). They are harmless here.
2923 </para>
2924 </sect2>
2926 <sect2>
2927 <title>Understanding cupsaddsmb</title>
2929 <indexterm><primary>cupsaddsmb</primary></indexterm>
2931 <para>
2932 What has happened? What did cupsaddsmb do? There are five stages of
2933 the procedure
2934 </para>
2936 <orderedlist>
2937         <indexterm><primary>IPP</primary></indexterm>
2938 <listitem><para>call the CUPS server via IPP and request the
2939 driver files and the PPD file for the named printer;</para></listitem>
2941 <listitem><para>store the files temporarily in the local
2942 TEMPDIR (as defined in
2943 <filename>cupsd.conf</filename>);</para></listitem>
2945 <listitem><para>connect via smbclient to the Samba server's
2946  <smbconfsection>[print$]</smbconfsection> share and put the files into the
2947  share's WIN40 (for Win95/98/ME) and W32X86/ (for WinNT/2k/XP) sub
2948  directories;</para></listitem>
2950 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
2951 <listitem><para>connect via rpcclient to the Samba server and
2952 execute the "adddriver" command with the correct
2953 parameters;</para></listitem>
2955 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
2956 <listitem><para>connect via rpcclient to the Samba server a second
2957 time and execute the "setdriver" command.</para></listitem>
2958 </orderedlist>
2960 <para>
2961 Note, that you can run the cupsaddsmb utility with parameters to
2962 specify one remote host as Samba host and a second remote host as CUPS
2963 host. Especially if you want to get a deeper understanding, it is a
2964 good idea try it and see more clearly what is going on (though in real
2965 life most people will have their CUPS and Samba servers run on the
2966 same host):
2967 </para>
2969 <para><screen>
2970 &rootprompt;<userinput>cupsaddsmb -H sambaserver -h cupsserver -v printername</userinput>
2971 </screen></para>
2972 </sect2>
2974 <sect2>
2975 <title>How to recognize if cupsaddsmb completed successfully</title>
2977 <para>
2978 You <emphasis>must</emphasis> always check if the utility completed
2979 successfully in all fields. You need as a minimum these 3 messages
2980 amongst the output:
2981 </para>
2983 <orderedlist>
2985 <listitem><para><emphasis>Printer Driver infotec_2105 successfully
2986 installed.</emphasis> # (for the W32X86 == WinNT/2K/XP
2987 architecture...)</para></listitem>
2989 <listitem><para><emphasis>Printer Driver infotec_2105 successfully
2990 installed.</emphasis> # (for the WIN40 == Win9x/ME
2991 architecture...)</para></listitem>
2993 <listitem><para><emphasis>Successfully set [printerXPZ] to driver
2994 [printerXYZ].</emphasis></para></listitem>
2995 </orderedlist>
2997 <para>
2998 These messages probably not easily recognized in the general
2999 output. If you run cupsaddsmb with the <option>-a</option>
3000 parameter (which tries to prepare <emphasis>all</emphasis> active CUPS
3001 printer drivers for download), you might miss if individual printers
3002 drivers had problems to install properly. Here a redirection of the
3003 output will help you analyze the results in retrospective.
3004 </para>
3006 <note><para>
3007 It is impossible to see any diagnostic output if you don't run
3008 cupsaddsmb in verbose mode.  Therefore we strongly recommend to not
3009 use the default quiet mode.  It will hide any problems from you which
3010 might occur.
3011 </para></note>
3012 </sect2>
3014 <sect2>
3015 <title>cupsaddsmb with a Samba PDC</title>
3017 <indexterm><primary>cupsaddsmb</primary></indexterm>
3019 <para>
3020 You can't get the standard cupsaddsmb command to run on a Samba PDC?
3021 You are asked for the password credential all over again and again and
3022 the command just will not take off at all? Try one of these
3023 variations:
3024 </para>
3026 <para><screen>
3027 &rootprompt;<userinput>cupsaddsmb -U &example.workgroup;\\root -v printername</userinput>
3028 &rootprompt;<userinput>cupsaddsmb -H &example.pdc.samba; -U &example.workgroup;\\root -v printername</userinput>
3029 &rootprompt;<userinput>cupsaddsmb -H &example.pdc.samba; -U &example.workgroup;\\root -h cups-server -v printername</userinput>
3030 </screen></para>
3032 <para>
3033 (Note the two backslashes: the first one is required to
3034 "escape" the second one).
3035 </para>
3036 </sect2>
3038 <sect2>
3039 <title>cupsaddsmb Flowchart</title>
3041 <indexterm><primary>cupsaddsmb</primary></indexterm>
3042 <para>
3043 Here is a chart about the procedures, commandflows and
3044 dataflows of the "cupaddsmb" command. Note again: cupsaddsmb is
3045 not intended to, and does not work with, "raw" queues!
3046 </para>
3048 <para>
3049         <image><imagedescription>cupsaddsmb flowchart</imagedescription>
3050                 <imagefile>14small</imagefile></image>
3051 </para>
3052 </sect2>
3054 <sect2>
3055 <title>Installing the PostScript Driver on a Client</title>
3057 <indexterm><primary>point and print</primary></indexterm>
3058 <para>
3059 After cupsaddsmb completed, your driver is prepared for the clients to
3060 use. Here are the steps you must perform to download and install it
3061 via "Point'n'Print". From a Windows client, browse to the CUPS/Samba
3062 server;
3063 </para>
3065 <itemizedlist>
3067 <indexterm><primary>"Printers" folder</primary></indexterm>
3069 <listitem><para>open the <emphasis>Printers</emphasis>
3070 share of Samba in Network Neighbourhood;</para></listitem>
3072 <listitem><para>right-click on the printer in
3073 question;</para></listitem>
3075 <listitem><para>from the opening context-menu select
3076 <emphasis>Install...</emphasis> or 
3077 <emphasis>Connect...</emphasis> (depending on the Windows version you
3078 use).</para></listitem>
3079 </itemizedlist>
3081 <para>
3082 After a few seconds, there should be a new printer in your
3083 client's <emphasis>local</emphasis> "Printers" folder: On Windows
3084 XP it will follow a naming convention of <emphasis>PrinterName on
3085 SambaServer</emphasis>. (In my current case it is "infotec_2105 on
3086 kde-bitshop"). If you want to test it and send your first job from
3087 an application like Winword, the new printer will appears in a
3088 <filename>\\SambaServer\PrinterName</filename> entry in the
3089 dropdown list of available printers.
3090 </para>
3092 <note><para>
3093 <indexterm><primary>PPD</primary></indexterm>
3094 cupsaddsmb will only reliably work with CUPS version 1.1.15 or higher
3095 and Samba from 2.2.4. If it doesn't work, or if the automatic printer
3096 driver download to the clients doesn't succeed, you can still manually
3097 install the CUPS printer PPD on top of the Adobe PostScript driver on
3098 clients. Then point the client's printer queue to the Samba printer
3099 share for a UNC type of connection:
3100 </para></note>
3102 <para><screen>
3103 &dosprompt;<userinput>net use lpt1: \\sambaserver\printershare /user:ntadmin</userinput>
3104 </screen></para>
3106 <para>
3107 should you desire to use the CUPS networked PostScript RIP
3108 functions. (Note that user "ntadmin" needs to be a valid Samba user
3109 with the required privileges to access the printershare) This would
3110 set up the printer connection in the traditional
3111 <emphasis>LanMan</emphasis> way (not using MS-RPC).
3112 </para>
3113 </sect2>
3115 <sect2>
3116 <title>Avoiding critical PostScript Driver Settings on the
3117 Client</title>
3119 <para>
3120 Soooo: printing works, but there are still problems. Most jobs print
3121 well, some don't print at all. Some jobs have problems with fonts,
3122 which don't look very good. Some jobs print fast, and some are
3123 dead-slow. Many of these problems can be greatly reduced or even
3124 completely eliminated if you follow a few guidelines. Remember, if
3125 your print device is not PostScript-enabled, you are treating your
3126 Ghostscript installation on your CUPS host with the output your client
3127 driver settings produce. Treat it well:
3128 </para>
3130 <itemizedlist>
3131 <listitem><para>Avoid the <emphasis>PostScript Output Option: Optimize
3132 for Speed</emphasis> setting. Rather use the <emphasis>Optimize for
3133 Portability</emphasis> instead (Adobe PostScript
3134 driver).</para></listitem>
3136 <listitem><para>Don't use the <emphasis>Page Independence:
3137 NO</emphasis> setting. Instead use <emphasis>Page Independence
3138 YES</emphasis> (CUPS PostScript Driver)</para></listitem>
3140 <listitem><para>Recommended is the <emphasis>True Type Font
3141 Downloading Option: Native True Type</emphasis> over
3142 <emphasis>Automatic</emphasis> and <emphasis>Outline</emphasis>; you
3143 should by all means avoid <emphasis>Bitmap</emphasis> (Adobe
3144 PostScript Driver)</para></listitem>
3146 <listitem><para>Choose <emphasis>True Type Font: Download as Softfont
3147 into Printer</emphasis> over the default <emphasis>Replace by Device
3148 Font</emphasis> (for exotic fonts you may need to change it back to
3149 get a printout at all) (Adobe)</para></listitem>
3151 <listitem><para>Sometimes you can choose <emphasis>PostScript Language
3152 Level</emphasis>: in case of problems try <emphasis>2</emphasis>
3153 instead of <emphasis>3</emphasis> (the latest ESP Ghostscript package
3154 handles Level 3 PostScript very well) (Adobe).</para></listitem>
3156 <listitem><para>Say <emphasis>Yes</emphasis> to <emphasis>PostScript
3157 Error Handler</emphasis> (Adobe)</para></listitem>
3158 </itemizedlist>
3159 </sect2>
3160 </sect1>
3162 <sect1>
3163 <title>Installing PostScript Driver Files manually (using
3164 rpcclient)</title>
3166 <para>
3167 Of course you can run all the commands which are embedded into the
3168 cupsaddsmb convenience utility yourself, one by one, and hereby upload
3169 and prepare the driver files for future client downloads.
3170 </para>
3172 <orderedlist>
3173 <listitem><para>prepare Samba (a CUPS printqueue with the name of the
3174 printer should be there. We are providing the driver
3175 now);</para></listitem>
3177 <listitem><para>copy all files to
3178                 <smbconfsection>[print$]</smbconfsection></para></listitem>
3180 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3181 <listitem><para>run <command>rpcclient adddriver</command>
3182 (for each client architecture you want to support):</para></listitem>
3184 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
3185 <listitem><para>run <command>rpcclient
3186 setdriver.</command></para></listitem>
3187 </orderedlist>
3189 <para>
3190 <indexterm><primary>rpcclient</primary><secondary>enumports</secondary></indexterm>
3191 <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3192 <indexterm><primary>rpcclient</primary><secondary>enumdrivers</secondary></indexterm>
3193 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
3194 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3195 We are going to do this now. First, read the man page on "rpcclient"
3196 to get a first idea. Look at all the printing related
3197 sub-commands. <command>enumprinters</command>,
3198 <command>enumdrivers</command>, <command>enumports</command>,
3199 <command>adddriver</command>, <command>setdriver</command> are amongst
3200 the most interesting ones. rpcclient implements an important part of
3201 the MS-RPC protocol. You can use it to query (and command) a Win NT
3202 (or 2K/XP) PC too. MS-RPC is used by Windows clients, amongst other
3203 things, to benefit from the "Point'n'Print" features. Samba can now
3204 mimic this too.
3205 </para>
3207 <sect2>
3208 <title>A Check of the rpcclient man Page</title>
3210 <para>
3211 First let's have a little check of the rpcclient man page. Here are
3212 two relevant passages:
3213 </para>
3215 <para>
3216 <command>adddriver &lt;arch&gt; &lt;config&gt;</command> Execute an
3217 AddPrinterDriver() RPC to install the printer driver information on
3218 the server.  Note that the driver files should already exist in the
3219 directory returned by <command>getdriverdir</command>.  Possible
3220 values for <parameter>arch</parameter> are the same as those for the
3221 <command>getdriverdir</command> command.  The
3222 <parameter>config</parameter> parameter is defined as follows:
3223 </para>
3224                 
3225 <para><screen>
3226 Long Printer Name:\
3227 Driver File Name:\
3228 Data File Name:\
3229 Config File Name:\
3230 Help File Name:\
3231 Language Monitor Name:\
3232 Default Data Type:\
3233 Comma Separated list of Files
3234 </screen></para>
3236 <para>Any empty fields should be enter as the string "NULL". </para>
3238 <para>Samba does not need to support the concept of Print Monitors
3239 since these only apply to local printers whose driver can make use of
3240 a bi-directional link for communication.  This field should be "NULL".
3241 On a remote NT print server, the Print Monitor for a driver must
3242 already be installed prior to adding the driver or else the RPC will
3243 fail
3244 </para>
3246 <para>
3247 <command>setdriver &lt;printername&gt; &lt;drivername&gt;</command>
3248 Execute a <command>SetPrinter()</command> command to update the
3249 printer driver associated with an installed printer. The printer
3250 driver must already be correctly installed on the print server.
3251 </para>
3253 <para> See also the enumprinters and enumdrivers commands for
3254 obtaining a list of installed printers and drivers.
3255 </para>
3257 </sect2>
3259 <sect2>
3260 <title>Understanding the rpcclient man page</title>
3262 <para>
3263 The <emphasis>exact</emphasis> format isn't made too clear by the man
3264 page, since you have to deal with some parameters containing
3265 spaces. Here is a better description for it. We have line-broken the
3266 command and indicated the breaks with "\". Usually you would type the
3267 command in one line without the linebreaks:
3268 </para>
3270 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3272 <para><screen>
3273  adddriver "Architecture" \
3274            "LongPrinterName:DriverFile:DataFile:ConfigFile:HelpFile:\
3275            LanguageMonitorFile:DataType:ListOfFiles,Comma-separated"
3276 </screen></para>
3278 <para>
3279 What the man pages denotes as a simple &lt;config&gt;
3280 keyword, does in reality consist of 8 colon-separated fields. The
3281 last field may take multiple (in some, very insane, cases, even
3282 20 different additional files. This might sound confusing at first.
3283 Note, that what the man pages names the "LongPrinterName" in
3284 reality should rather be called the "Driver Name". You can name it
3285 anything you want, as long as you use this name later in the
3286 <emphasis>rpcclient ... setdriver</emphasis> command. For
3287 practical reasons, many name the driver the same as the
3288 printer.
3289 </para>
3291 <para>
3292 True: it isn't simple at all. I hear you asking:
3293 <emphasis>How do I know which files are "Driver
3294 File", "Data File", "Config File", "Help File" and "Language
3295 Monitor File" in each case?</emphasis> -- For an answer you may
3296 want to have a look at how a Windows NT box with a shared printer
3297 presents the files to us. Remember, that this whole procedure has
3298 to be developed by the Samba Team by overhearing the traffic caused
3299 by Windows computers on the wire. We may as well turn to a Windows
3300 box now, and access it from a UNIX workstation. We will query it
3301 with <command>rpcclient</command> to see what it tells us and
3302 try to understand the man page more clearly which we've read just
3303 now.
3304 </para>
3305 </sect2>
3307 <sect2>
3308 <title>Producing an Example by querying a Windows Box</title>
3310 <para>
3311         <indexterm><primary>rpcclient</primary><secondary>getdriver</secondary></indexterm>
3312         <indexterm><primary>rpcclient</primary><secondary>getprinter</secondary></indexterm>
3313 We could run <command>rpcclient</command> with a
3314 <command>getdriver</command> or a <command>getprinter</command>
3315 subcommand (in level 3 verbosity) against it. Just sit down at UNIX or
3316 Linux workstation with the Samba utilities installed. Then type the
3317 following command:
3318 </para>
3320 <para><screen>
3321 &rootprompt;<userinput>rpcclient -U'USERNAME%PASSWORD' NT-SERVER-NAME -c 'getdriver printername 3'</userinput>
3322 </screen></para>
3324 <para>
3325 From the result it should become clear which is which. Here is an
3326 example from my installation:
3327 </para>
3329         <indexterm><primary>rpcclient</primary><secondary>getdriver</secondary></indexterm>
3330 <para><screen>
3331 &rootprompt;<userinput>rpcclient -U'Danka%xxxx' W2KSERVER \
3332         -c'getdriver "DANKA InfoStream Virtual Printer" 3'</userinput>
3333  cmd = getdriver "DANKA InfoStream Virtual Printer" 3
3335  [Windows NT x86]
3336  Printer Driver Info 3:
3337          Version: [2]
3338          Driver Name: [DANKA InfoStream]
3339          Architecture: [Windows NT x86]
3340          Driver Path: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\PSCRIPT.DLL]
3341          Datafile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\INFOSTRM.PPD]
3342          Configfile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\PSCRPTUI.DLL]
3343          Helpfile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\PSCRIPT.HLP]
3345          Dependentfiles: []
3346          Dependentfiles: []
3347          Dependentfiles: []
3348          Dependentfiles: []
3349          Dependentfiles: []
3350          Dependentfiles: []
3351          Dependentfiles: []
3353          Monitorname: []
3354          Defaultdatatype: []
3356 </screen></para>
3358 <para>
3359 Some printer drivers list additional files under the label
3360 "Dependentfiles": these would go into the last field
3361 <emphasis>ListOfFiles,Comma-separated</emphasis>. For the CUPS
3362 PostScript drivers we don't need any (nor would we for the Adobe
3363 PostScript driver): therefore the field will get a "NULL" entry.
3364 </para>
3365 </sect2>
3367 <sect2>
3368 <title>What is required for adddriver and setdriver to succeed</title>
3370 <para>
3371 From the manpage (and from the quoted output
3372 of <emphasis>cupsaddsmb</emphasis>, above) it becomes clear that you
3373 need to have certain conditions in order to make the manual uploading
3374 and initializing of the driver files succeed. The two rpcclient
3375 <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3376 subcommands (<command>adddriver</command> and
3377 <command>setdriver</command>) need to encounter the following
3378 pre-conditions to complete successfully:
3379 </para>
3380 <itemizedlist>
3382 <listitem><para>you are connected as <smbconfoption><name>printer admin</name></smbconfoption>, or root (note,
3383 that this is <emphasis>not</emphasis> the "Printer Operators" group in
3384 NT, but the <emphasis>printer admin</emphasis> group, as defined in
3385 the <smbconfsection>[global]</smbconfsection> section of
3386 &smb.conf;);</para></listitem>
3388 <listitem><para>copy all required driver files to
3389 <filename>\\sambaserver\print$\w32x86</filename> and
3390 <filename>\\sambaserver\print$\win40</filename> as appropriate. They
3391 will end up in the "0" respective "2" subdirectories later -- for now
3392 <emphasis>don't</emphasis> put them there, they'll be automatically
3393 used by the <command>adddriver</command> subcommand.! (if you use
3394 "smbclient" to put the driver files into the share, note that you need
3395 to escape the "$": <command>smbclient //sambaserver/print\$ -U
3396 root</command>);</para></listitem>
3398 <listitem><para>the user you're connecting as must be able to write to
3399 the <smbconfsection>[print$]</smbconfsection> share and create
3400 subdirectories;</para></listitem>
3402 <listitem><para>the printer you are going to setup for the Windows
3403 clients, needs to be installed in CUPS already;</para></listitem>
3405 <listitem><para>
3406         <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
3407         <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3408                 the CUPS printer must be known to Samba, otherwise the
3409 <command>setdriver</command> subcommand fails with an
3410 NT_STATUS_UNSUCCESSFUL error. To check if the printer is known by
3411 Samba you may use the <command>enumprinters</command> subcommand to
3412 rpcclient. A long-standing bug prevented a proper update of the
3413 printer list until every smbd process had received a SIGHUP or was
3414 restarted. Remember this in case you've created the CUPS printer just
3415 shortly ago and encounter problems: try restarting
3416 Samba.</para></listitem>
3417 </itemizedlist>
3418 </sect2>
3420 <sect2>
3421 <title>Manual Driver Installation in 15 Steps</title>
3423 <para>
3424 We are going to install a printer driver now by manually executing all
3425 required commands. As this may seem a rather complicated process at
3426 first, we go through the procedure step by step, explaining every
3427 single action item as it comes up.
3428 </para>
3430 <procedure>
3431         <title>Manual Driver Installation installation</title>
3433 <step>
3434 <title>Install the Printer on CUPS</title>
3436 <para><screen>
3437 &rootprompt;<userinput>lpadmin -p mysmbtstprn -v socket://10.160.51.131:9100 -E -P canonIR85.ppd</userinput>
3438 </screen></para>
3440 <para>
3441 This installs printer with the name <emphasis>mysmbtstprn</emphasis>
3442 to the CUPS system. The printer is accessed via a socket
3443 (a.k.a. JetDirect or Direct TCP/IP) connection. You need to be root
3444 for this step
3445 </para>
3446 </step>
3448 <step>
3449 <title>(optional) Check if the Printer is recognized by
3450 Samba</title>
3452         <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3453 <para><screen>
3454 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'enumprinters' localhost | grep -C2 mysmbtstprn</userinput>
3455 flags:[0x800000]
3456 name:[\\kde-bitshop\mysmbtstprn]
3457 description:[\\kde-bitshop\mysmbtstprn,,mysmbtstprn]
3458 comment:[mysmbtstprn]
3459 </screen></para>
3461 <para>
3462 This should show the printer in the list. If not, stop and re-start
3463 the Samba daemon (smbd), or send a HUP signal: <command>kill -HUP
3464 `pidof smbd`</command>. Check again.  Troubleshoot and repeat until
3465 success. Note the "empty" field between the two commas in the
3466 "description" line. Here would the driver name appear if there was one
3467 already. You need to know root's Samba password (as set by the
3468 <command>smbpasswd</command> command) for this step and most of the
3469 following steps. Alternatively you can authenticate as one of the
3470 users from the "write list" as defined in &smb.conf; for
3471 <smbconfsection>[print$]</smbconfsection>.
3472 </para>
3473 </step>
3475 <step>
3476 <title>(optional) Check if Samba knows a Driver for the
3477 Printer</title>
3479         <indexterm><primary>rpcclient</primary><secondary>getprinter</secondary></indexterm>
3480         <indexterm><primary>rpcclient</primary><secondary>getdriver</secondary></indexterm>
3481 <para><screen>
3482 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' localhost \
3483                         | grep driver </userinput>
3484 drivername:[]
3486 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' localhost \
3487         | grep -C4 driv</userinput>
3488 servername:[\\kde-bitshop]
3489 printername:[\\kde-bitshop\mysmbtstprn]
3490 sharename:[mysmbtstprn]
3491 portname:[Samba Printer Port]
3492 drivername:[]
3493 comment:[mysmbtstprn]
3494 location:[]
3495 sepfile:[]
3496 printprocessor:[winprint]
3498 &rootprompt;<userinput>rpcclient -U root%xxxx -c 'getdriver mysmbtstprn' localhost</userinput>
3499  result was WERR_UNKNOWN_PRINTER_DRIVER
3501 </screen></para>
3503 <para>
3504 Neither method of the three commands shown above should show a driver.
3505 This step was done for the purpose of demonstrating this condition. An
3506 attempt to connect to the printer at this stage will prompt the
3507 message along the lines: "The server has not the required printer
3508 driver installed".
3509 </para>
3510 </step>
3512 <step>
3513 <title>Put all required Driver Files into Samba's
3514 [print$]</title>
3516 <para><screen>
3517 &rootprompt;<userinput>smbclient //localhost/print\$ -U 'root%xxxx' \
3518         -c 'cd W32X86; \
3519         put /etc/cups/ppd/mysmbtstprn.ppd mysmbtstprn.PPD; \ 
3520         put /usr/share/cups/drivers/cupsui.dll cupsui.dll; \
3521         put /usr/share/cups/drivers/cupsdrvr.dll cupsdrvr.dll; \
3522         put /usr/share/cups/drivers/cups.hlp cups.hlp'</userinput>
3523 </screen></para>
3525 <para>
3526 (Note that this command should be entered in one long single
3527 line. Line-breaks and the line-end indicating "\" has been inserted
3528 for readability reasons.) This step is <emphasis>required</emphasis>
3529 for the next one to succeed. It makes the driver files physically
3530 present in the <smbconfsection>[print$]</smbconfsection> share. However, clients
3531 would still not be able to install them, because Samba does not yet
3532 treat them as driver files. A client asking for the driver would still
3533 be presented with a "not installed here" message.
3534 </para>
3535 </step>
3537 <step>
3538 <title>Verify where the Driver Files are now</title>
3540 <para><screen>
3541 &rootprompt;<userinput>ls -l /etc/samba/drivers/W32X86/</userinput>
3542 total 669
3543 drwxr-sr-x    2 root     ntadmin       532 May 25 23:08 2
3544 drwxr-sr-x    2 root     ntadmin       670 May 16 03:15 3
3545 -rwxr--r--    1 root     ntadmin     14234 May 25 23:21 cups.hlp
3546 -rwxr--r--    1 root     ntadmin    278380 May 25 23:21 cupsdrvr.dll
3547 -rwxr--r--    1 root     ntadmin    215848 May 25 23:21 cupsui.dll
3548 -rwxr--r--    1 root     ntadmin    169458 May 25 23:21 mysmbtstprn.PPD
3549 </screen></para>
3551 <para>
3552 The driver files now are in the W32X86 architecture "root" of
3553 <smbconfsection>[print$]</smbconfsection>.
3554 </para>
3555 </step>
3557 <step>
3558 <title>Tell Samba that these are
3559 <emphasis>Driver</emphasis> Files
3560 (<command>adddriver</command>)</title>
3562         <indexterm><primary>rpcclient</primary><secondary>adddriver</secondary></indexterm>
3563 <para><screen>
3564 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c `adddriver "Windows NT x86" "mydrivername: \
3565   cupsdrvr.dll:mysmbtstprn.PPD: \
3566   cupsui.dll:cups.hlp:NULL:RAW<citation>:</citation>NULL" \
3567   localhost</userinput>
3568 Printer Driver mydrivername successfully installed.
3569 </screen></para>
3571 <para>
3572 Note that your cannot repeat this step if it fails. It could fail even
3573 as a result of a simple typo. It will most likely have moved a part of
3574 the driver files into the "2" subdirectory. If this step fails, you
3575 need to go back to the fourth step and repeat it, before you can try
3576 this one again. In this step you need to choose a name for your
3577 driver. It is normally a good idea to use the same name as is used for
3578 the printername; however, in big installations you may use this driver
3579 for a number of printers which have obviously different names. So the
3580 name of the driver is not fixed.
3581 </para>
3582 </step>
3584 <step>
3585 <title>Verify where the Driver Files are now</title>
3587 <para><screen>
3588 &rootprompt;<userinput>ls -l /etc/samba/drivers/W32X86/</userinput>
3589 total 1
3590 drwxr-sr-x    2 root     ntadmin       532 May 25 23:22 2
3591 drwxr-sr-x    2 root     ntadmin       670 May 16 03:15 3
3593 &rootprompt;<userinput>ls -l /etc/samba/drivers/W32X86/2</userinput>
3594 total 5039
3595 [....]
3596 -rwxr--r--    1 root     ntadmin     14234 May 25 23:21 cups.hlp
3597 -rwxr--r--    1 root     ntadmin    278380 May 13 13:53 cupsdrvr.dll
3598 -rwxr--r--    1 root     ntadmin    215848 May 13 13:53 cupsui.dll
3599 -rwxr--r--    1 root     ntadmin    169458 May 25 23:21 mysmbtstprn.PPD
3600 </screen></para>
3602 <para>
3603 Notice how step 6 did also move the driver files to the appropriate
3604 subdirectory. Compare with the situation after step 5.
3605 </para>
3606 </step>
3608 <step>
3609 <title>(optional) Verify if Samba now recognizes the
3610 Driver</title>
3612         <indexterm><primary>rpcclient</primary><secondary>enumdrivers</secondary></indexterm>
3613 <para><screen>
3614 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'enumdrivers 3' localhost \
3615         | grep -B2 -A5 mydrivername</userinput>
3616 Printer Driver Info 3:
3617 Version: [2]
3618 Driver Name: [mydrivername]
3619 Architecture: [Windows NT x86]
3620 Driver Path: [\\kde-bitshop\print$\W32X86\2\cupsdrvr.dll]
3621 Datafile: [\\kde-bitshop\print$\W32X86\2\mysmbtstprn.PPD]
3622 Configfile: [\\kde-bitshop\print$\W32X86\2\cupsui.dll]
3623 Helpfile: [\\kde-bitshop\print$\W32X86\2\cups.hlp]
3624 </screen></para>
3626 <para>
3627 Remember, this command greps for the name you did choose for the
3628 driver in step Six. This command must succeed before you can proceed.
3629 </para>
3630 </step>
3632 <step>
3633 <title>Tell Samba which Printer should use these Driver
3634 Files (<command>setdriver</command>)</title>
3636 <indexterm><primary>rpcclient</primary><secondary>setdriver</secondary></indexterm>
3638 <para><screen>
3639 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'setdriver mysmbtstprn mydrivername' localhost</userinput>
3640 Successfully set mysmbtstprn to driver mydrivername
3641 </screen></para>
3643 <para>
3644 Since you can bind any printername (=printqueue) to any driver, this
3645 is a very convenient way to setup many queues which use the same
3646 driver. You don't need to repeat all the previous steps for the
3647 setdriver command to succeed. The only pre-conditions are:
3648 <command>enumdrivers</command> must find the driver and
3649 <command>enumprinters</command> must find the printer.
3650 </para>
3651 </step>
3653 <step>
3654 <title>(optional) Verify if Samba has this Association
3655 recognized</title>
3657 <indexterm><primary>rpcclient</primary><secondary>getprinter</secondary></indexterm>
3658 <indexterm><primary>rpcclient</primary><secondary>getdriver</secondary></indexterm>
3659 <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3660 <para><screen>
3661 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' localhost \
3662   | grep driver</userinput>
3663 drivername:[mydrivername]
3665 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' localhost \
3666   | grep -C4 driv</userinput>
3667 servername:[\\kde-bitshop]
3668 printername:[\\kde-bitshop\mysmbtstprn]
3669 sharename:[mysmbtstprn]
3670 portname:[Done]
3671 drivername:[mydrivername]
3672 comment:[mysmbtstprn]
3673 location:[]
3674 sepfile:[]
3675 printprocessor:[winprint]
3677 &rootprompt;<userinput>rpcclient -U root%xxxx -c 'getdriver mysmbtstprn' localhost</userinput>
3678 [Windows NT x86]
3679 Printer Driver Info 3:
3680      Version: [2]
3681      Driver Name: [mydrivername]
3682      Architecture: [Windows NT x86]
3683      Driver Path: [\\kde-bitshop\print$\W32X86\2\cupsdrvr.dll]
3684      Datafile: [\\kde-bitshop\print$\W32X86\2\mysmbtstprn.PPD]
3685      Configfile: [\\kde-bitshop\print$\W32X86\2\cupsui.dll]
3686      Helpfile: [\\kde-bitshop\print$\W32X86\2\cups.hlp]
3687      Monitorname: []
3688      Defaultdatatype: [RAW]
3689      Monitorname: []
3690      Defaultdatatype: [RAW]
3692 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'enumprinters' localhost | grep mysmbtstprn</userinput>
3693      name:[\\kde-bitshop\mysmbtstprn]
3694      description:[\\kde-bitshop\mysmbtstprn,mydrivername,mysmbtstprn]
3695      comment:[mysmbtstprn]
3697 </screen></para>
3699 <para>
3700 <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3701 Compare these results with the ones from steps 2 and 3. Note that
3702 every single of these commands show the driver is installed.  Even
3703 the <command>enumprinters</command> command now lists the driver
3704 on the "description" line.
3705 </para>
3706 </step>
3708 <step>
3709 <title>(optional) Tickle the Driver into a correct
3710 Device Mode</title>
3712 <para>
3713 <indexterm><primary>"Printers" folder</primary></indexterm>
3714 You certainly know how to install the driver on the client.  In case
3715 you are not particularly familiar with Windows, here is a short
3716 recipe: browse the Network Neighbourhood, go to the Samba server, look
3717 for the shares. You should see all shared Samba printers.
3718 Double-click on the one in question. The driver should get
3719 installed, and the network connection set up. An alternative way is to
3720 open the "Printers (and Faxes)" folder, right-click on the printer in
3721 question and select "Connect" or "Install". As a result, a new printer
3722 should have appeared in your client's local "Printers (and Faxes)"
3723 folder, named something like "printersharename on Sambahostname".
3724 </para>
3726 <para>
3727 It is important that you execute this step as a Samba printer admin
3728 (as defined in &smb.conf;). Here is another method
3729 to do this on Windows XP. It uses a commandline, which you may type
3730 into the "DOS box" (type root's smbpassword when prompted):
3731 </para>
3733 <para><screen>
3734 &dosprompt;<userinput>runas /netonly /user:root "rundll32 printui.dll,PrintUIEntry /in /n\
3735                         \\sambacupsserver\mysmbtstprn"</userinput>
3736 </screen></para>
3738 <para>
3739 Change any printer setting once (like changing <emphasis>"portrait" to
3740         "landscape"</emphasis>), click <guibutton>Apply</guibutton>; change the setting
3741 back.
3742 </para>
3743 </step>
3745 <step>
3746 <title>Install the Printer on a Client
3747 ("Point'n'Print")</title>
3749 <indexterm significance="preferred"><primary>point and print</primary></indexterm>
3751 <para><screen>
3752 &dosprompt;<userinput>rundll32 printui.dll,PrintUIEntry /in /n "\\sambacupsserver\mysmbtstprn"</userinput>
3753 </screen></para>
3755 <para>
3756 If it doesn't work it could be a permission problem with the
3757 <smbconfsection>[print$]</smbconfsection> share.
3758 </para>
3759 </step>
3761 <step>
3762 <title>Thirteenth Step (optional): Print a Test Page</title>
3764 <para><screen>
3765 &dosprompt;<userinput>rundll32 printui.dll,PrintUIEntry /p /n "\\sambacupsserver\mysmbtstprn"</userinput>
3766 </screen></para>
3768 <para>
3769 Then hit [TAB] 5 times, [ENTER] twice, [TAB] once and [ENTER] again
3770 and march to the printer.
3771 </para>
3772 </step>
3774 <step>
3775 <title>Fourteenth Step (recommended): Study the Test Page</title>
3777 <para>
3778 Hmmm.... just kidding! By now you know everything about printer
3779 installations and you don't need to read a word. Just put it in a
3780 frame and bolt it to the wall with the heading "MY FIRST
3781 RPCCLIENT-INSTALLED PRINTER" - why not just throw it away!
3782 </para>
3783 </step>
3785 <step>
3786 <title>Fifteenth Step (obligatory): Enjoy. Jump. Celebrate your
3787 Success</title>
3789 <para><screen>
3790 &rootprompt;<userinput>echo "Cheeeeerioooooo! Success..." &gt;&gt; /var/log/samba/log.smbd</userinput>
3791 </screen></para>
3792 </step>
3793 </procedure>
3794 </sect2>
3796 <sect2>
3797 <title>Troubleshooting revisited</title>
3799 <para>
3800 The setdriver command will fail, if in Samba's mind the queue is not
3801 already there. You had promising messages about the:
3802 </para>
3804 <para><screen>
3806  Printer Driver ABC successfully installed.
3808 </screen></para>
3810 <para>
3811 after the "adddriver" parts of the procedure?  But you are also seeing
3812 a disappointing message like this one beneath?
3813 </para>
3815 <para><screen>
3817  result was NT_STATUS_UNSUCCESSFUL
3819 </screen></para>
3821 <para>
3822 <indexterm><primary>lpstat</primary></indexterm>
3823 It is not good enough that you
3824 can see the queue <emphasis>in CUPS</emphasis>, using
3825 the <command>lpstat -p ir85wm</command> command. A
3826 bug in most recent versions of Samba prevents the proper update of
3827 the queuelist. The recognition of newly installed CUPS printers
3828 fails unless you re-start Samba or send a HUP to all smbd
3829 processes. To verify if this is the reason why Samba doesn't
3830 execute the setdriver command successfully, check if Samba "sees"
3831 the printer: 
3832 </para>
3834 <indexterm><primary>rpcclient</primary><secondary>enumprinters</secondary></indexterm>
3835 <para><screen>
3836 &rootprompt;<userinput>rpcclient transmeta -N -U'root%secret' -c 'enumprinters 0'| grep  ir85wm</userinput>
3837         printername:[ir85wm]
3838 </screen></para>
3840 <para>
3841 An alternative command could be this: 
3842 </para>
3844 <indexterm><primary>rpcclient</primary><secondary>getprinter</secondary></indexterm>
3845 <para><screen>
3846 &rootprompt;<userinput>rpcclient transmeta -N -U'root%secret' -c 'getprinter ir85wm' </userinput>
3847         cmd = getprinter ir85wm
3848         flags:[0x800000]
3849         name:[\\transmeta\ir85wm]
3850         description:[\\transmeta\ir85wm,ir85wm,DPD]
3851         comment:[CUPS PostScript-Treiber for WinNT/2K/XP]
3852 </screen></para>
3854 <para>
3855 BTW, you can use these commands, plus a few more, of course,
3856 to install drivers on remote Windows NT print servers too!
3857 </para>
3858 </sect2>
3859 </sect1>
3861 <sect1>
3862 <title>The printing <filename>*.tdb</filename> Files</title>
3864 <para>
3865 <indexterm><primary>TDB</primary></indexterm>
3866 <indexterm><primary>connections.tdb</primary><seealso>TDB</seealso></indexterm>
3867 <indexterm><primary>printing.tdb</primary><seealso>TDB</seealso></indexterm>
3868 <indexterm><primary>share_info.tdb</primary><seealso>TDB</seealso></indexterm>
3869 <indexterm><primary>ntdrivers.tdb</primary><seealso>TDB</seealso></indexterm>
3870 <indexterm><primary>unexpected.tdb</primary><seealso>TDB</seealso></indexterm>
3871 <indexterm><primary>brlock.tdb</primary><seealso>TDB</seealso></indexterm>
3872 <indexterm><primary>locking.tdb</primary><seealso>TDB</seealso></indexterm>
3873 <indexterm><primary>ntforms.tdb</primary><seealso>TDB</seealso></indexterm>
3874 <indexterm><primary>messages.tdb</primary><seealso>TDB</seealso></indexterm>
3875 <indexterm><primary>ntprinters.tdb</primary><seealso>TDB</seealso></indexterm>
3876 <indexterm><primary>sessionid.tdb</primary><seealso>TDB</seealso></indexterm>
3877 <indexterm><primary>secrets.tdb</primary><seealso>TDB</seealso></indexterm>
3878 Some mystery is associated with the series of files with a
3879 tdb-suffix appearing in every Samba installation. They are
3880 <filename>connections.tdb</filename>,
3881 <filename>printing.tdb</filename>,
3882 <filename>share_info.tdb</filename> ,
3883 <filename>ntdrivers.tdb</filename>,
3884 <filename>unexpected.tdb</filename>,
3885 <filename>brlock.tdb</filename> ,
3886 <filename>locking.tdb</filename>,
3887 <filename>ntforms.tdb</filename>,
3888 <filename>messages.tdb</filename> ,
3889 <filename>ntprinters.tdb</filename>,
3890 <filename>sessionid.tdb</filename> and
3891 <filename>secrets.tdb</filename>. What is their purpose?
3892 </para>
3894 <sect2>
3895 <title>Trivial DataBase Files</title>
3897 <indexterm><primary>TDB</primary></indexterm>
3898 <para>
3899 A Windows NT (Print) Server keeps track of all information needed to serve
3900 its duty toward its clients by storing entries in the Windows
3901 "Registry". Client queries are answered by reading from the registry,
3902 Administrator or user configuration settings are saved by writing into
3903 the Registry. Samba and UNIX obviously don't have such a kind of
3904 Registry. Samba instead keeps track of all client related information in a
3905 series of <filename>*.tdb</filename> files. (TDB = Trivial Data
3906 Base). These are often located in <filename>/var/lib/samba/</filename>
3907 or <filename>/var/lock/samba/</filename> . The printing related files
3908 are <filename>ntprinters.tdb</filename>,
3909 <filename>printing.tdb</filename>,<filename>ntforms.tdb</filename> and
3910 <filename>ntdrivers.tdb</filename>.
3911 </para>
3912 </sect2>
3914 <sect2>
3915 <title>Binary Format</title>
3917 <para>
3918 <filename>*.tdb</filename> files are not human readable. They are
3919 written in a binary format. "Why not ASCII?", you may ask. "After all,
3920 ASCII configuration files are a good and proofed tradition on UNIX."
3921 -- The reason for this design decision by the Samba Team is mainly
3922 performance. Samba needs to be fast; it runs a separate
3923 <command>smbd</command> process for each client connection, in some
3924 environments many thousand of them. Some of these smbds might need to
3925 write-access the same <filename>*.tdb</filename> file <emphasis>at the
3926 same time</emphasis>. The file format of Samba's
3927 <filename>*.tdb</filename> files allows for this provision. Many smbd
3928 processes may write to the same <filename>*.tdb</filename> file at the
3929 same time. This wouldn't be possible with pure ASCII files.
3930 </para>
3931 </sect2>
3933 <sect2>
3934 <title>Losing <filename>*.tdb</filename> Files</title>
3936 <para>
3937 It is very important that all <filename>*.tdb</filename> files remain
3938 consistent over all write and read accesses. However, it may happen
3939 that these files <emphasis>do</emphasis> get corrupted. (A
3940 <command>kill -9 `pidof smbd`</command> while a write access is in
3941 progress could do the damage as well as a power interruption,
3942 etc.). In cases of trouble, a deletion of the old printing-related
3943 <filename>*.tdb</filename> files may be the only option. You need to
3944 re-create all print related setup after that.  Or you have made a
3945 backup of the <filename>*.tdb</filename> files in time.
3946 </para>
3947 </sect2>
3949 <sect2>
3950 <title>Using <emphasis>tdbbackup</emphasis></title>
3952 <indexterm><primary>TDB</primary><secondary>backing up</secondary><see>tdbbackup</see></indexterm>
3953 <indexterm><primary>tdbbackup</primary></indexterm>
3955 <para>
3956 Samba ships with a little utility which helps the root user of your
3957 system to back up your <filename>*.tdb</filename> files. If you run it
3958 with no argument, it prints a little usage message:
3959 </para>
3961 <para><screen>
3962 &rootprompt;<userinput>tdbbackup</userinput>
3963  Usage: tdbbackup [options] &lt;fname...&gt;
3965  Version:3.0a
3966    -h            this help message
3967    -s suffix     set the backup suffix
3968    -v            verify mode (restore if corrupt)
3970 </screen></para>
3972 <para>
3973 Here is how I backed up my printing.tdb file:
3974 </para>
3976 <para><screen>
3977 &rootprompt;<userinput>ls</userinput>
3978 .              browse.dat       locking.tdb     ntdrivers.tdb   printing.tdb
3979 ..             share_info.tdb   connections.tdb messages.tdb    ntforms.tdb
3980 printing.tdbkp unexpected.tdb   brlock.tdb      gmon.out        namelist.debug  
3981 ntprinters.tdb sessionid.tdb
3983 &rootprompt;<userinput>tdbbackup -s .bak printing.tdb</userinput>
3984  printing.tdb : 135 records
3986 &rootprompt;<userinput>ls -l printing.tdb*</userinput>
3987  -rw-------    1 root     root        40960 May  2 03:44 printing.tdb
3988  -rw-------    1 root     root        40960 May  2 03:44 printing.tdb.bak
3990 </screen></para>
3991 </sect2>
3992 </sect1>
3994 <sect1>
3995 <title>CUPS Print Drivers from Linuxprinting.org</title>
3997 <indexterm><primary>Linuxprinting.org</primary></indexterm>
3999 <para>
4000 CUPS ships with good support for HP LaserJet type printers.  You can
4001 install the generic driver as follows:
4002 </para>
4004 <indexterm><primary>lpadmin</primary></indexterm>
4006 <para><screen>
4007 &rootprompt;<userinput>lpadmin -p laserjet4plus -v parallel:/dev/lp0 -E -m laserjet.ppd</userinput>
4008 </screen></para>
4010 <para>
4011 The <option>-m</option> switch will retrieve the
4012 <filename>laserjet.ppd</filename> from the standard repository for
4013 not-yet-installed-PPDs, which CUPS typically stores in
4014 <filename>/usr/share/cups/model</filename>. Alternatively, you may use
4015 <option>-P /path/to/your.ppd</option>.
4016 </para>
4018 <para>
4019 The generic laserjet.ppd however does not support every special option
4020 for every LaserJet-compatible model. It constitutes a sort of "least
4021 denominator" of all the models. If for some reason it is ruled out to
4022 you to pay for the commercially available ESP Print Pro drivers, your
4023 first move should be to consult the database on <ulink
4024 noescape="1" url="http://www.linuxprinting.org/printer_list.cgi">http://www.linuxprinting.org/printer_list.cgi</ulink>.
4025 Linuxprinting.org has excellent recommendations about which driver is
4026 best used for each printer. Its database is kept current by the
4027 tireless work of Till Kamppeter from MandrakeSoft, who is also the
4028 principal author of the foomatic-rip utility.
4029 </para>
4031 <note><para>
4032 <indexterm><primary>foomatic-rip</primary></indexterm>
4033 The former "cupsomatic" concept is now be replaced by the new, much
4034 more powerful "foomatic-rip". foomatic-rip is the successor of
4035 cupsomatic. cupsomatic is no longer maintained. Here is the new URL
4036 to the Foomatic-3.0 database:<ulink
4037 noescape="1" url="http://www.linuxprinting.org/driver_list.cgi">http://www.linuxprinting.org/driver_list.cgi</ulink>.
4038 If you upgrade to foomatic-rip, don't forget to also upgrade to the
4039 new-style PPDs for your foomatic-driven printers. foomatic-rip will
4040 not work with PPDs generated for the old cupsomatic. The new-style
4041 PPDs are 100% compliant to the Adobe PPD specification. They are
4042 intended to be used by Samba and the cupsaddsmb utility also, to
4043 provide the driver files for the Windows clients also!
4044 </para></note>
4046 <sect2>
4047 <title>foomatic-rip and Foomatic explained</title>
4049 <indexterm significance="preferred"><primary>foomatic</primary></indexterm>
4050 <indexterm significance="preferred"><primary>foomatic-rip</primary></indexterm>
4052 <para>
4053 Nowadays most Linux distros rely on the utilities of Linuxprinting.org
4054 to create their printing related software (which, BTW, works on all
4055 UNIXes and on Mac OS X or Darwin too). It is not known as well as it
4056 should be, that it also has a very end-user friendly interface which
4057 allows for an easy update of drivers and PPDs, for all supported
4058 models, all spoolers, all operating systems and all package formats
4059 (because there is none). Its history goes back a few years.
4060 </para>
4062 <para>
4063 Recently Foomatic has achieved the astonishing milestone of <ulink
4064 url="http://www.linuxprinting.org/printer_list.cgi?make=Anyone">1000
4065 listed</ulink> printer models. Linuxprinting.org keeps all the
4066 important facts about printer drivers, supported models and which
4067 options are available for the various driver/printer combinations in
4068 its <ulink
4069 url="http://www.linuxprinting.org/foomatic.html">Foomatic</ulink>
4070 database. Currently there are <ulink
4071 url="http://www.linuxprinting.org/driver_list.cgi">245 drivers</ulink>
4072 in the database: many drivers support various models, and many models
4073 may be driven by different drivers; it's your choice!
4074 </para>
4076 <sect3>
4077 <title>690 "perfect" Printers</title>
4079 <para>
4080 At present there are 690 devices dubbed as working "perfectly", 181
4081 "mostly", 96 "partially" and 46 are "Paperweights". Keeping in mind
4082 that most of these are non-PostScript models (PostScript printers are
4083 automatically supported supported by CUPS to perfection, by using
4084 their own manufacturer-provided Windows-PPD...), and that a
4085 multifunctional device never qualifies as working "perfectly" if it
4086 doesn't also scan and copy and fax under GNU/Linux: then this is a
4087 truly astonishing achievement. Three years ago the number was not
4088 more than 500, and Linux or UNIX "printing" at the time wasn't
4089 anywhere near the quality it is today!
4090 </para>
4091 </sect3>
4093 <sect3>
4094 <title>How the "Printing HOWTO" started it all</title>
4096 <para>
4097 A few years ago <ulink
4098 url="http://www2.picante.com:81/~gtaylor/">Grant Taylor</ulink>
4099 started it all. The roots of today's Linuxprinting.org are in the
4100 first <ulink
4101 url="http://www.linuxprinting.org/foomatic2.9/howto/">Linux Printing
4102 HOWTO</ulink> which he authored. As a side-project to this document,
4103 which served many Linux users and admins to guide their first steps in
4104 this complicated and delicate setup (to a scientist, printing is
4105 "applying a structured deposition of distinct patterns of ink or toner
4106 particles on paper substrates" <emphasis>;-)</emphasis>, he started to
4107 build in a little Postgres database with information about the
4108 hardware and driver zoo that made up Linux printing of the time. This
4109 database became the core component of today's Foomatic collection of
4110 tools and data. In the meantime it has moved to an XML representation
4111 of the data.
4112 </para>
4113 </sect3>
4115 <sect3>
4116 <title>Foomatic's strange Name</title>
4118 <indexterm><primary>foomatic</primary></indexterm>
4120 <para>
4121 "Why the funny name?", you ask. When it really took off, around spring
4122 2000, CUPS was far less popular than today, and most systems used LPD,
4123 LPRng or even PDQ to print. CUPS shipped with a few generic "drivers"
4124 (good for a few hundred different printer models). These didn't
4125 support many device-specific options. CUPS also shipped with its own
4126 built-in rasterization filter ("pstoraster", derived from
4127 Ghostscript). On the other hand, CUPS provided brilliant support for
4128 <emphasis>controlling</emphasis> all printer options through
4129 standardized and well-defined "PPD files" (PostScript Printers
4130 Description files). Plus, CUPS was designed to be easily extensible.
4131 </para>
4133 <para>
4134 Grant already had in his database a respectable compilation
4135 of facts about a many more printers, and the Ghostscript "drivers"
4136 they run with. His idea, to generate PPDs from the database info
4137 and use them to make standard Ghostscript filters work within CUPS,
4138 proved to work very well. It also "killed several birds with one
4139 stone":
4140 </para>
4142 <itemizedlist>
4143 <listitem><para>It made all current and future Ghostscript filter
4144 developments available for CUPS;</para></listitem>
4146 <listitem><para>It made available a lot of additional printer models
4147 to CUPS users (because often the "traditional" Ghostscript way of
4148 printing was the only one available);</para></listitem>
4150 <listitem><para>It gave all the advanced CUPS options (web interface,
4151 GUI driver configurations) to users wanting (or needing) to use
4152 Ghostscript filters.</para></listitem>
4153 </itemizedlist>
4154 </sect3>
4156 <sect3>
4157 <title>cupsomatic, pdqomatic, lpdomatic, directomatic</title>
4159 <indexterm><primary>cupsomatic</primary></indexterm>
4160 <indexterm><primary>CUPS-PPD</primary></indexterm>
4161 <indexterm><primary>PPD</primary><secondary>CUPS</secondary><see>CUPS-PPD</see></indexterm>
4163 <para>
4164 CUPS worked through a quickly-hacked up filter script named <ulink
4165 url="http://www.linuxprinting.org/download.cgi?filename=cupsomatic&amp;show=0">cupsomatic</ulink>.
4166 cupsomatic ran the printfile through Ghostscript, constructing
4167 automatically the rather complicated command line needed. It just
4168 required to be copied into the CUPS system to make it work. To
4169 "configure" the way cupsomatic controls the Ghostscript rendering
4170 process, it needs a CUPS-PPD. This PPD is generated directly from the
4171 contents of the database. For CUPS and the respective printer/filter
4172 combo another Perl script named "CUPS-O-Matic" did the PPD
4173 generation. After that was working, Grant implemented within a few
4174 days a similar thing for two other spoolers. Names chosen for the
4175 config-generator scripts were <ulink
4176 url="http://www.linuxprinting.org/download.cgi?filename=lpdomatic&amp;show=0">PDQ-O-Matic</ulink>
4177 (for PDQ) and <ulink
4178 url="http://www.linuxprinting.org/download.cgi?filename=lpdomatic&amp;show=0">LPD-O-Matic</ulink>
4179 (for - you guessed it - LPD); the configuration here didn't use PPDs
4180 but other spooler-specific files.
4181 </para>
4183 <para>
4184 From late summer of that year, <ulink
4185 url="http://www.linuxprinting.org/till/">Till Kamppeter</ulink>
4186 started to put work into the database. Till had been newly employed by
4187 <ulink url="http://www.mandrakesoft.com/">MandrakeSoft</ulink> to
4188 convert their printing system over to CUPS, after they had seen his
4189 <ulink url="http://www.fltk.org/">FLTK</ulink>-based <ulink
4190 url="http://cups.sourceforge.net/xpp/">XPP</ulink> (a GUI frontend to
4191 the CUPS lp-command). He added a huge amount of new information and new
4192 printers. He also developed the support for other spoolers, like
4193 <ulink url="http://ppr.sourceforge.net/">PPR</ulink> (via ppromatic),
4194 <ulink url="http://sourceforge.net/projects/lpr/">GNUlpr</ulink> and
4195 <ulink url="http://www.lprng.org/">LPRng</ulink> (both via an extended
4196 lpdomatic) and "spoolerless" printing (<ulink
4197 url="http://www.linuxprinting.org/download.cgi?filename=directomatic&amp;show=0">directomatic</ulink>)....
4198 </para>
4200 <para>
4201 So, to answer your question: "Foomatic" is the general name for all
4202 the overlapping code and data behind the "*omatic" scripts.... --
4203 Foomatic up to versions 2.0.x required (ugly) Perl data structures
4204 attached the Linuxprinting.org PPDs for CUPS. It had a different
4205 "*omatic" script for every spooler, as well as different printer
4206 configuration files..
4207 </para>
4208 </sect3>
4210 <sect3>
4211 <title>The <emphasis>Grand Unification</emphasis>
4212 achieved...</title>
4214 <indexterm><primary>foomatic-rip</primary></indexterm>
4216 <para>
4217 This all has changed in Foomatic versions 2.9 (Beta) and released as
4218 "stable" 3.0. This has now achieved the convergence of all *omatic
4219 scripts: it is called the <ulink
4220 url="http://www.linuxprinting.org/foomatic2.9/download.cgi?filename=foomatic-rip&amp;show=0">foomatic-rip</ulink>.
4221 This single script is the unification of the previously different
4222 spooler-specific *omatic scripts. foomatic-rip is used by all the
4223 different spoolers alike. Because foomatic-rip can read PPDs (both the
4224 original PostScript printer PPDs and the Linuxprinting.org-generated
4225 ones), all of a sudden all supported spoolers can have the power of
4226 PPDs at their disposal; users only need to plug "foomatic-rip" into
4227 their system.... For users there is improved media type and source
4228 support; paper sizes and trays are easier to configure.
4229 </para>
4231 <para>
4232 Also, the New Generation of Linuxprinting.org PPDs doesn't contain
4233 Perl data structures any more. If you are a distro maintainer and have
4234 used the previous version of Foomatic, you may want to give the new
4235 one a spin: but don't forget to generate a new-version set of PPDs,
4236 via the new <ulink
4237 url="http://www.linuxprinting.org/download/foomatic/foomatic-db-engine-3.0.0beta1.tar.gz">foomatic-db-engine</ulink>!
4238 Individual users just need to generate a single new PPD specific to
4239 their model by <ulink
4240 url="http://www.linuxprinting.org/kpfeifle/LinuxKongress2002/Tutorial/II.Foomatic-User/II.tutorial-handout-foomatic-user.html">following
4241 the steps</ulink> outlined in the Foomatic tutorial or further
4242 below. This new development is truly amazing.
4243 </para>
4245 <para>
4246 foomatic-rip is a very clever wrapper around the need to run
4247 Ghostscript with a different syntax, different options, different
4248 device selections and/or different filters for each different printer
4249 or different spooler. At the same time it can read the PPD associated
4250 with a print queue and modify the print job according to the user
4251 selections. Together with this comes the 100% compliance of the new
4252 Foomatic PPDs with the Adobe spec. Some really innovative features of
4253 the Foomatic concept will surprise users: it will support custom paper
4254 sizes for many printers; and it will support printing on media drawn
4255 from different paper trays within the same job (in both cases: even
4256 where there is no support for this from Windows-based vendor printer
4257 drivers).
4258 </para>
4259 </sect3>
4261 <sect3>
4262 <title>Driver Development outside</title>
4264 <para>
4265 Most driver development itself does not happen within
4266 Linuxprinting.org. Drivers are written by independent maintainers.
4267 Linuxprinting.org just pools all the information, and stores it in its
4268 database. In addition, it also provides the Foomatic glue to integrate
4269 the many drivers into any modern (or legacy) printing system known to
4270 the world.
4271 </para>
4273 <para>
4274 Speaking of the different driver development groups: most of
4275 the work is currently done in three projects. These are:
4276 </para>
4278 <itemizedlist>
4279 <listitem><para><ulink
4280 url="http://www-124.ibm.com/developerworks/oss/linux/projects/omni/">Omni</ulink>
4281 -- a Free Software project by IBM which tries to convert their printer
4282 driver knowledge from good-ol' OS/2 times into a modern, modular,
4283 universal driver architecture for Linux/UNIX (still Beta).  This
4284 currently supports 437 models.</para></listitem>
4286 <listitem><para><ulink url="http://hpinkjet.sf.net/">HPIJS</ulink> --
4287 a Free Software project by HP to provide the support for their own
4288 range of models (very mature, printing in most cases is perfect and
4289 provides true photo quality). This currently supports 369
4290 models.</para></listitem>
4292 <listitem><para><ulink
4293 url="http://gimp-print.sf.net/">Gimp-Print</ulink> -- a Free software
4294 effort, started by Michael Sweet (also lead developer for CUPS), now
4295 directed by Robert Krawitz, which has achieved an amazing level of
4296 photo print quality (many Epson users swear that its quality is
4297 better than the vendor drivers provided by Epson for the Microsoft
4298 platforms). This currently supports 522 models.</para></listitem>
4299 </itemizedlist>
4300 </sect3>
4302 <sect3>
4303 <title>Forums, Downloads, Tutorials, Howtos -- also for Mac OS X and
4304 commercial UNIX</title>
4306 <para>
4307 Linuxprinting.org today is the one-stop "shop" to download printer
4308 drivers. Look for printer information and <ulink
4309 url="http://www.linuxprinting.org//kpfeifle/LinuxKongress2002/Tutorial/">tutorials</ulink>
4310 or solve printing problems in its popular <ulink
4311 url="http://www.linuxprinting.org/newsportal/">forums</ulink>.  But
4312 it's not just for GNU/Linux: users and admins of <ulink
4313 url="http://www.linuxprinting.org/macosx/">commercial UNIX
4314 systems</ulink> are also going there, and the relatively new <ulink
4315 url="http://www.linuxprinting.org/newsportal/thread.php3?name=linuxprinting.macosx.general">Mac
4316 OS X forum</ulink> has turned out to be one of the most frequented
4317 fora after only a few weeks.
4318 </para>
4320 <para>
4321 Linuxprinting.org and the Foomatic driver wrappers around Ghostscript
4322 are now a standard toolchain for printing on all the important
4323 distros. Most of them also have CUPS underneath. While in recent years
4324 most printer data had been added by Till (who works at Mandrake), many
4325 additional contributions came from engineers with SuSE, RedHat,
4326 Connectiva, Debian and others. Vendor-neutrality is an important goal
4327 of the Foomatic project.
4328 </para>
4330 <note><para>
4331 Till Kamppeter from MandrakeSoft is doing an excellent job in his
4332 spare time to maintain Linuxprinting.org and Foomatic. So if you use
4333 it often, please send him a note showing your appreciation.
4334 </para></note>
4335 </sect3>
4337 <sect3>
4338 <title>Foomatic Database generated PPDs</title>
4340 <para>
4341 The Foomatic database is an amazing piece of ingenuity in itself. Not
4342 only does it keep the printer and driver information, but it is
4343 organized in a way that it can generate "PPD" files "on the fly" from
4344 its internal XML-based datasets. While these PPDs are modelled to the
4345 Adobe specification of "PostScript Printer Descriptions" (PPDs), the
4346 Linuxprinting.org/Foomatic-PPDs don't normally drive PostScript
4347 printers: they are used to describe all the bells and whistles you
4348 could ring or blow on an Epson Stylus inkjet, or a HP Photosmart or
4349 what-have-you. The main "trick" is one little additional line, not
4350 envisaged by the PPD specification, starting with the "*cupsFilter"
4351 keyword: it tells the CUPS daemon how to proceed with the PostScript
4352 print file (old-style Foomatic-PPDs named the
4353 <emphasis>cupsomatic</emphasis> filter script, while the new-style
4354 PPDs now call <emphasis>foomatic-rip</emphasis>). This filter
4355 script calls Ghostscript on the host system (the recommended variant
4356 is ESP Ghostscript) to do the rendering work. foomatic-rip knows which
4357 filter or internal device setting it should ask from Ghostscript to
4358 convert the PostScript printjob into a raster format ready for the
4359 target device. This usage of PPDs to describe the options of non-PS
4360 printers was the invention of the CUPS developers. The rest is easy:
4361 GUI tools (like KDE's marvellous <ulink
4362 url="http://printing.kde.org/overview/kprinter.phtml">"kprinter"</ulink>,
4363 or the GNOME <ulink
4364 url="http://gtklp.sourceforge.net/">"gtklp"</ulink>, "xpp" and the CUPS
4365 web interface) read the PPD too and use this information to present
4366 the available settings to the user as an intuitive menu selection.
4367 </para>
4368 </sect3>
4369 </sect2>
4371 <sect2>
4372 <title>foomatic-rip and Foomatic-PPD Download and Installation</title>
4374 <para>
4375 Here are the steps to install a foomatic-rip driven "LaserJet 4 Plus"
4376 compatible printer in CUPS (note that recent distributions of SuSE,
4377 UnitedLinux and Mandrake may ship with a complete package of
4378 Foomatic-PPDs plus the foomatic-rip utility.  going directly to
4379 Linuxprinting.org ensures you to get the latest driver/PPD files):
4380 </para>
4381 <itemizedlist>
4382 <listitem><para>Surf to <ulink
4383 noescape="1" url="http://www.linuxprinting.org/printer_list.cgi">http://www.linuxprinting.org/printer_list.cgi</ulink>
4384 </para></listitem>
4386 <listitem><para>Check the complete list of printers in the database:
4387 <ulink noescape="1" 
4388 url="http://www.linuxprinting.org/printer_list.cgi?make=Anyone">http://www.linuxprinting.org/printer_list.cgi?make=Anyone</ulink>
4389 </para></listitem>
4391 <listitem><para>There select your model and click on the
4392 link.</para></listitem>
4394 <listitem><para>You'll arrive at a page listing all drivers working
4395 with this model (for all printers, there will always be
4396 <emphasis>one</emphasis> recommended driver. Try this one
4397 first).</para></listitem>
4399 <listitem><para>In our case ("HP LaserJet 4 Plus"), we'll arrive here:
4400                 <ulink noescape="1"
4401 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>
4402 </para></listitem>
4404 <listitem><para>The recommended driver is "ljet4".</para></listitem>
4406 <listitem><para>There are several links provided here. You should
4407 visit them all, if you are not familiar with the Linuxprinting.org
4408 database.</para></listitem>
4410 <listitem><para>There is a link to the database page for the "ljet4":
4411                 <ulink noescape="1"
4412 url="http://www.linuxprinting.org/show_driver.cgi?driver=ljet4">http://www.linuxprinting.org/show_driver.cgi?driver=ljet4</ulink>
4413 On the driver's page, you'll find important and detailed information
4414 about how to use that driver within the various available
4415 spoolers.</para></listitem>
4417 <listitem><para>Another link may lead you to the homepage of the
4418 driver author or the driver.</para></listitem>
4420 <listitem><para>Important links are the ones which provide hints with
4421 setup instructions for CUPS (<ulink noescape="1"
4422 url="http://www.linuxprinting.org/cups-doc.html">http://www.linuxprinting.org/cups-doc.html</ulink>),
4423 PDQ (<ulink noescape="1"
4424 url="http://www.linuxprinting.org/pdq-doc.html">http://www.linuxprinting.org/pdq-doc.html</ulink>),
4425 LPD, LPRng and GNUlpr (<ulink noescape="1"
4426 url="http://www.linuxprinting.org/lpd-doc.html">http://www.linuxprinting.org/lpd-doc.html</ulink>)
4427 as well as PPR (<ulink noescape="1"
4428 url="http://www.linuxprinting.org/ppr-doc.html">http://www.linuxprinting.org/ppr-doc.html)</ulink>
4429 or "spooler-less" printing (<ulink noescape="1"
4430 url="http://www.linuxprinting.org/direct-doc.html">http://www.linuxprinting.org/direct-doc.html</ulink>
4431 ).</para></listitem>
4433 <listitem><para>You can view the PPD in your browser through this
4434 link: <ulink noescape="1"
4435 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>
4436 </para></listitem> <listitem><para>You can also (most importantly)
4437 generate and download the PPD: <ulink noescape="1"
4438 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>
4439 </para></listitem>
4441 <listitem><para>The PPD contains all the information needed to use our
4442 model and the driver; this is, once installed, working transparently
4443 for the user. Later you'll only need to choose resolution, paper size
4444 etc. from the web-based menu, or from the print dialog GUI, or from
4445 the commandline.</para></listitem>
4447 <listitem><para>Should you have ended up on the driver's page (<ulink noescape="1"
4448 url="http://www.linuxprinting.org/show_driver.cgi?driver=ljet4">http://www.linuxprinting.org/show_driver.cgi?driver=ljet4</ulink>),
4449 you can choose to use the "PPD-O-Matic" online PPD generator
4450 program.</para></listitem>
4452 <listitem><para>Select the exact model and check either "download" or
4453 "display PPD file" and click on "Generate PPD file".</para></listitem>
4455 <listitem><para>If you save the PPD file from the browser view, please
4456 don't use "cut'n'past" (since it could possibly damage line endings
4457 and tabs, which makes the PPD likely to fail its duty), but use "Save
4458 as..." in your browser's menu. (Best is to use the "download" option
4459 from the web page directly).</para></listitem>
4461 <listitem><para>Another very interesting part on each driver page is
4462 the <emphasis>Show execution details</emphasis> button. If you
4463 select your printer model and click that button, you will get
4464 displayed a complete Ghostscript command line, enumerating all options
4465 available for that driver/printermodel combo. This is a great way to
4466 "Learn Ghostscript By Doing". It is also an excellent "cheat sheet"
4467 for all experienced users who need to re-construct a good command line
4468 for that damn printing script, but can't remember the exact
4469 syntax. ;-)</para></listitem>
4471 <listitem><para>Some time during your visit to Linuxprinting.org, save
4472 the PPD to a suitable place on your harddisk, say
4473 <filename>/path/to/my-printer.ppd</filename> (if you prefer to install
4474 your printers with the help of the CUPS web interface, save the PPD to
4475 the <filename>/usr/share/cups/model/</filename> path and re-start
4476 cupsd).</para></listitem>
4478 <listitem><para>Then install the printer with a suitable commandline,
4479 e.g.: 
4480 </para>
4482 <para><screen>
4483 &rootprompt;<userinput>lpadmin -p laserjet4plus -v parallel:/dev/lp0 -E -P path/to/my-printer.ppd</userinput>
4484 </screen></para></listitem>
4486 <listitem><para>Note again this: for all the new-style "Foomatic-PPDs"
4487 from Linuxprinting.org, you also need a special "CUPS filter" named
4488 "foomatic-rip".Get the latest version of "foomatic-rip" from: <ulink noescape="1"
4489 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>
4490 </para></listitem>
4492 <listitem><para>The foomatic-rip Perlscript itself also makes some
4493 interesting reading (<ulink noescape="1"
4494 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>),
4495 because it is very well documented by Till's inline comments (even
4496 non-Perl hackers will learn quite a bit about printing by reading
4497 it... ;-)</para></listitem>
4499 <listitem><para>Save foomatic-rip either directly in
4500 <filename>/usr/lib/cups/filter/foomatic-rip</filename> or somewhere in
4501 your $PATH (and don't forget to make it world-executable). Again,
4502 don't save by "copy'n'paste" but use the appropriate link, or the
4503 "Save as..."  menu item in your browser.</para></listitem>
4505 <listitem><para>If you save foomatic-rip in your $PATH, create a symlink:
4506 <command>cd /usr/lib/cups/filter/ ; ln -s `which
4507 foomatic-rip`</command>. For CUPS to discover this new
4508 available filter at startup, you need to re-start
4509 cupsd.</para></listitem>
4510 </itemizedlist>
4512 <para>
4513 Once you print to a printqueue set up with the Foomatic-PPD, CUPS will
4514 insert the appropriate commands and comments into the resulting
4515 PostScript jobfile. foomatic-rip is able to read and act upon
4516 these. foomatic-rip uses some specially encoded Foomatic comments,
4517 embedded in the jobfile. These in turn are used to construct
4518 (transparently for you, the user) the complicated ghostscript command
4519 line telling for the printer driver how exactly the resulting raster
4520 data should look like and which printer commands to embed into the
4521 data stream.
4522 </para>
4524 <para>
4525 You need:
4526 </para>
4528 <itemizedlist>
4530 <listitem><para>A "foomatic+something" PPD -- but it this not enough
4531 to print with CUPS (it is only <emphasis>one</emphasis> important
4532 component)</para></listitem>
4534 <listitem><para>The "foomatic-rip" filter script (Perl) in
4535 /usr/lib/cups/filters/</para></listitem>
4537 <listitem><para>Perl to make foomatic-rip run</para></listitem>
4539 <listitem><para>Ghostscript (because it is doing the main work,
4540 controlled by the PPD/foomatic-rip combo) to produce the raster data
4541 fit for your printermodel's consumption</para></listitem>
4543 <listitem><para>Ghostscript <emphasis>must</emphasis> (depending on
4544 the driver/model) contain support for a certain "device", representing
4545 the selected "driver" for your model (as shown by "gs
4546 -h")</para></listitem>
4548 <listitem><para>foomatic-rip needs a new version of PPDs (PPD versions
4549 produced for cupsomatic don't work with
4550 foomatic-rip).</para></listitem>
4551 </itemizedlist>
4552 </sect2>
4553 </sect1>
4555 <sect1>
4556 <title>Page Accounting with CUPS</title>
4559 <indexterm><primary>CUPS</primary><secondary>Page Accounting</secondary></indexterm>
4560 <para>
4561 Often there are questions regarding "print quotas" wherein Samba users
4562 (that is, Windows clients) should not be able to print beyond a
4563 certain amount of pages or data volume per day, week or month. This
4564 feature is dependent on the real print subsystem you're using.
4565 Samba's part is always to receive the job files from the clients
4566 (filtered <emphasis>or</emphasis> unfiltered) and hand it over to this
4567 printing subsystem.
4568 </para>
4570 <para>
4571 Of course one could "hack" things with one's own scripts. But then
4572 there is CUPS. CUPS supports "quotas" which can be based on sizes of
4573 jobs or on the number of pages or both, and are spanning any time
4574 period you want.
4575 </para>
4577 <sect2>
4578 <title>Setting up Quotas</title>
4580 <indexterm><primary>CUPS</primary><secondary>quotas</secondary></indexterm>
4581 <para>
4582 This is an example command how root would set a print quota in CUPS,
4583 assuming an existing printer named "quotaprinter":
4584 </para>
4586 <indexterm><primary>lpadmin</primary></indexterm>
4588 <para><screen>
4589 &rootprompt;<userinput>lpadmin -p quotaprinter -o job-quota-period=604800 \
4590         -o job-k-limit=1024 -o job-page-limit=100</userinput>
4591 </screen></para>
4593 <para>
4594 This would limit every single user to print 100 pages or 1024 KB of
4595 data (whichever comes first) within the last 604,800 seconds ( = 1
4596 week).
4597 </para>
4598 </sect2>
4600 <sect2>
4601 <title>Correct and incorrect Accounting</title>
4603 <para>
4604 For CUPS to count correctly, the printfile needs to pass the CUPS
4605 "pstops" filter, otherwise it uses a "dummy" count of "1".  Some
4606 printfiles don't pass it (eg: image files) but then those are mostly 1
4607 page jobs anyway. This also means that proprietary drivers for the
4608 target printer running on the client computers and CUPS/Samba, which
4609 then spool these files as "raw" (i.e. leaving them untouched, not
4610 filtering them), will be counted as "1-pagers" too!
4611 </para>
4613 <para>
4614 You need to send PostScript from the clients (i.e. run a PostScript
4615 driver there) to have the chance to get accounting done. If the
4616 printer is a non-PostScript model, you need to let CUPS do the job to
4617 convert the file to a print-ready format for the target printer. This
4618 will be working for currently about 1,000 different printer models,
4619 see <ulink
4620         url="http://www.linuxprinting.org/printer_list.cgi">the driver list at linuxprinting.org/</ulink>.
4621 </para>
4622 </sect2>
4624 <sect2>
4625 <title>Adobe and CUPS PostScript Drivers for Windows Clients</title>
4627 <para>
4628 Before CUPS-1.1.16 your only option was to use the Adobe PostScript
4629 Driver on the Windows clients. The output of this driver was not
4630 always passed through the "pstops" filter on the CUPS/Samba side, and
4631 therefore was not counted correctly (the reason is that it often,
4632 depending on the "PPD" being used, wrote a "PJL"-header in front of
4633 the real PostScript which caused CUPS to skip pstops and go directly
4634 to the "pstoraster" stage).
4635 </para>
4637 <para>
4638 From CUPS-1.1.16 onward you can use the "CUPS PostScript Driver for
4639 Windows NT/2K/XP clients" (which is tagged in the download area of
4640 http://www.cups.org/ as the "cups-samba-1.1.16.tar.gz" package). It does
4641 <emphasis>not</emphasis> work for Win9x/ME clients. But it guarantees:
4642 </para>
4644 <itemizedlist>
4645 <indexterm><primary>PJL</primary></indexterm>
4647 <listitem><para>to not write an PJL-header</para></listitem>
4649 <listitem><para>to still read and support all PJL-options named in the
4650 driver PPD with its own means</para></listitem>
4652 <listitem><para> that the file will pass through the "pstops" filter
4653 on the CUPS/Samba server</para></listitem>
4655 <listitem><para>to page-count correctly the
4656 printfile</para></listitem>
4657 </itemizedlist>
4659 <para>
4660 You can read more about the setup of this combination in the manpage
4661 for "cupsaddsmb" (which is only present with CUPS installed, and only
4662 current from CUPS 1.1.16).
4663 </para>
4664 </sect2>
4666 <sect2>
4667 <title>The page_log File Syntax</title>
4669 <indexterm><primary>page_log</primary></indexterm>
4670 <para>
4671 These are the items CUPS logs in the "page_log" for every
4672 single <emphasis>page</emphasis> of a job:
4673 </para>
4675 <itemizedlist>
4676 <listitem><para>Printer name</para></listitem>
4678 <listitem><para>User name</para></listitem>
4680 <listitem><para>Job ID</para></listitem>
4682 <listitem><para>Time of printing</para></listitem>
4684 <listitem><para>the page number</para></listitem>
4686 <listitem><para>the number of copies</para></listitem>
4688 <listitem><para>a billing information string
4689 (optional)</para></listitem>
4691 <listitem><para>the host which sent the job (included since version
4692 1.1.19)</para></listitem>
4693 </itemizedlist>
4695 <para>
4696 Here is an extract of my CUPS server's page_log file to illustrate the
4697 format and included items:
4698 </para>
4700 <para><screen>
4701 infotec_IS2027 kurt 401 [22/Apr/2003:10:28:43 +0100] 1 3 #marketing 10.160.50.13
4702 infotec_IS2027 kurt 401 [22/Apr/2003:10:28:43 +0100] 2 3 #marketing 10.160.50.13
4703 infotec_IS2027 kurt 401 [22/Apr/2003:10:28:43 +0100] 3 3 #marketing 10.160.50.13
4704 infotec_IS2027 kurt 401 [22/Apr/2003:10:28:43 +0100] 4 3 #marketing 10.160.50.13
4705 DigiMaster9110 boss 402 [22/Apr/2003:10:33:22 +0100] 1 440 finance-dep 10.160.51.33
4706 </screen></para>
4708 <para>
4709 This was job ID "401", printed on "infotec_IS2027" by user "kurt", a
4710 64-page job printed in 3 copies and billed to "#marketing", sent
4711 from IP address 10.160.50.13. The next job had ID "402", was sent by
4712 user "boss" from IP address 10.160.51.33,printed from one page 440
4713 copies and is set to be billed to "finance-dep".
4714 </para>
4715 </sect2>
4717 <sect2>
4718 <title>Possible Shortcomings</title>
4720 <para>
4721 What flaws or shortcomings are there with this quota system?
4722 </para>
4724 <itemizedlist>
4725 <listitem><para>the ones named above (wrongly logged job in case of
4726 printer hardware failure, etc.)</para></listitem>
4728 <listitem><para>in reality, CUPS counts the job pages that are being
4729 processed in <emphasis>software</emphasis> (that is, going through the
4730 "RIP") rather than the physical sheets successfully leaving the
4731 printing device. Thus if there is a jam while printing the 5th sheet out
4732 of 1000 and the job is aborted by the printer, the "page count" will
4733 still show the figure of 1000 for that job</para></listitem>
4735 <listitem><para>all quotas are the same for all users (no flexibility
4736 to give the boss a higher quota than the clerk), no support for
4737 groups</para></listitem>
4739 <listitem><para>no means to read out the current balance or the
4740 "used-up" number of current quota</para></listitem>
4742 <listitem><para>a user having used up 99 sheets of 100 quota will
4743 still be able to send and print a 1,000 sheet job</para></listitem>
4745 <listitem><para>a user being denied a job because of a filled-up quota
4746 doesn't get a meaningful error message from CUPS other than
4747 "client-error-not-possible".</para></listitem>
4748 </itemizedlist>
4749 </sect2>
4751 <sect2>
4752 <title>Future Developments</title>
4754 <para>
4755 This is the best system currently available, and there are huge
4756 improvements under development for CUPS 1.2:
4757 </para>
4759 <itemizedlist>
4760 <listitem><para>page counting will go into the "backends" (these talk
4761 directly to the printer and will increase the count in sync with the
4762 actual printing process: thus a jam at the 5th sheet will lead to a
4763 stop in the counting)</para></listitem>
4765 <listitem><para>quotas will be handled more flexibly</para></listitem>
4767 <listitem><para>probably there will be support for users to inquire
4768 their "accounts" in advance</para></listitem>
4770 <listitem><para>probably there will be support for some other tools
4771 around this topic</para></listitem>
4772 </itemizedlist>
4773 </sect2>
4775 <sect2>
4776 <title>Other Accounting Tools</title>
4778 <para>
4779 PrintAnalyzer, pyKota, printbill, LogReport.
4780 </para>
4781 </sect2>
4782 </sect1>
4784 <sect1>
4785 <title>Additional Material</title>
4787 <para>
4788 A printer queue with <emphasis>no</emphasis> PPD associated to it is a
4789 "raw" printer and all files will go directly there as received by the
4790 spooler. The exceptions are file types "application/octet-stream"
4791 which need "passthrough feature" enabled. "Raw" queues don't do any
4792 filtering at all, they hand the file directly to the CUPS backend.
4793 This backend is responsible for the sending of the data to the device
4794 (as in the "device URI" notation: <filename>lpd://, socket://,
4795 smb://, ipp://, http://, parallel:/, serial:/, usb:/</filename> etc.)
4796 </para>
4798 <para>
4799 "cupsomatic"/Foomatic are <emphasis>not</emphasis> native CUPS drivers
4800 and they don't ship with CUPS. They are a Third Party add-on,
4801 developed at Linuxprinting.org. As such, they are a brilliant hack to
4802 make all models (driven by Ghostscript drivers/filters in traditional
4803 spoolers) also work via CUPS, with the same (good or bad!) quality as
4804 in these other spoolers. "cupsomatic" is only a vehicle to execute a
4805 ghostscript commandline at that stage in the CUPS filtering chain,
4806 where "normally" the native CUPS "pstoraster" filter would kick
4807 in. cupsomatic by-passes pstoraster, "kidnaps" the printfile from CUPS
4808 away and re-directs it to go through Ghostscript. CUPS accepts this,
4809 because the associated CUPS-O-Matic-/Foomatic-PPD specifies:
4810 </para>
4812 <para><programlisting>
4813   *cupsFilter:  "application/vnd.cups-postscript 0 cupsomatic"
4814 </programlisting></para>
4816 <para>
4817 This line persuades CUPS to hand the file to cupsomatic, once it has
4818 successfully converted it to the MIME type
4819 "application/vnd.cups-postscript". This conversion will not happen for
4820 Jobs arriving from Windows which are auto-typed
4821 "application/octet-stream", with the according changes in
4822 <filename>/etc/cups/mime.types</filename> in place.
4823 </para>
4825 <para>
4826 CUPS is widely configurable and flexible, even regarding its filtering
4827 mechanism. Another workaround in some situations would be to have in
4828 <filename>/etc/cups/mime.types</filename> entries as follows:
4829 </para>
4831 <para><programlisting>
4832  application/postscript           application/vnd.cups-raw  0  -
4833  application/vnd.cups-postscript  application/vnd.cups-raw  0  -
4834 </programlisting></para>
4836 <para>
4837 This would prevent all Postscript files from being filtered (rather,
4838 they will through the virtual <emphasis>nullfilter</emphasis>
4839 denoted with "-").  This could only be useful for PS printers. If you
4840 want to print PS code on non-PS printers (provided they support ASCII
4841 text printing) an entry as follows could be useful:
4842 </para>
4844 <para><programlisting>
4845  */*           application/vnd.cups-raw  0  -
4846 </programlisting></para>
4848 <para>
4849 and would effectively send <emphasis>all</emphasis> files to the
4850 backend without further processing.
4851 </para>
4853 <para>
4854 Lastly, you could have the following entry:
4855 </para>
4857 <para><programlisting>
4858 application/vnd.cups-postscript application/vnd.cups-raw 0 my_PJL_stripping_filter
4859 </programlisting></para>
4861 <para>
4862 You will need to write a <emphasis>my_PJL_stripping_filter</emphasis>
4863 (could be a shellscript) that parses the PostScript and removes the
4864 unwanted PJL. This would need to conform to CUPS filter design
4865 (mainly, receive and pass the parameters printername, job-id,
4866 username, jobtitle, copies, print options and possibly the
4867 filename). It would be installed as world executable into
4868 <filename>/usr/lib/cups/filters/</filename> and will be called by CUPS
4869 if it encounters a MIME type "application/vnd.cups-postscript".
4870 </para>
4872 <para>
4873 CUPS can handle <emphasis>-o job-hold-until=indefinite</emphasis>.
4874 This keeps the job in the queue "on hold". It will only be printed
4875 upon manual release by the printer operator. This is a requirement in
4876 many "central reproduction departments", where a few operators manage
4877 the jobs of hundreds of users on some big machine, where no user is
4878 allowed to have direct access (such as when the operators often need
4879 to load the proper paper type before running the 10,000 page job
4880 requested by marketing for the mailing, etc.).
4881 </para>
4882 </sect1>
4884 <sect1>
4885 <title>Auto-Deletion or Preservation of CUPS Spool Files</title>
4887 <para>
4888 Samba print files pass through two "spool" directories. One is the
4889 incoming directory managed by Samba, (set in the <smbconfoption><name>path</name><value>/var/spool/samba</value></smbconfoption> directive in the
4890 <smbconfsection>[printers]</smbconfsection> section of
4891 &smb.conf;). The other is the spool directory of
4892 your UNIX print subsystem. For CUPS it is normally
4893 <filename>/var/spool/cups/</filename>, as set by the cupsd.conf
4894 directive <filename>RequestRoot /var/spool/cups</filename>.
4895 </para>
4897 <sect2>
4898 <title>CUPS Configuration Settings explained</title>
4900 <para>
4901 Some important parameter settings in the CUPS configuration file
4902 <filename>cupsd.conf</filename> are:
4903 </para>
4905 <variablelist>
4907 <varlistentry><term>PreserveJobHistory Yes</term>
4908 <listitem><para>
4909 This keeps some details of jobs in cupsd's mind (well it keeps the
4910 "c12345", "c12346" etc. files in the CUPS spool directory, which do a
4911 similar job as the old-fashioned BSD-LPD control files). This is set
4912 to "Yes" as a default.
4913 </para></listitem></varlistentry>
4915 <varlistentry><term>PreserveJobFiles Yes</term>
4916 <listitem><para>
4917 This keeps the job files themselves in cupsd's mind
4918 (well it keeps the "d12345", "d12346" etc. files in the CUPS spool
4919 directory...). This is set to "No" as the CUPS
4920 default.
4921 </para></listitem></varlistentry>
4923 <varlistentry><term><emphasis>"MaxJobs 500"</emphasis></term>
4924 <listitem><para>
4925 This directive controls the maximum number of jobs
4926 that are kept in memory. Once the number of jobs reaches the limit,
4927 the oldest completed job is automatically purged from the system to
4928 make room for the new one. If all of the known jobs are still
4929 pending or active then the new job will be rejected. Setting the
4930 maximum to 0 disables this functionality. The default setting is
4932 </para></listitem></varlistentry>
4933 </variablelist>
4935 <para>
4936 (There are also additional settings for "MaxJobsPerUser" and
4937 "MaxJobsPerPrinter"...)
4938 </para>
4939 </sect2>
4941 <sect2>
4942 <title>Pre-conditions</title>
4944 <para>
4945 For everything to work as announced, you need to have three
4946 things:
4947 </para>
4949 <itemizedlist>
4950 <listitem><para>a Samba-smbd which is compiled against "libcups" (Check
4951 on Linux by running "ldd `which smbd`")</para></listitem>
4953 <listitem><para>a Samba-&smb.conf; setting of
4954                 <smbconfoption><name>printing</name><value>cups</value></smbconfoption></para></listitem>
4956 <listitem><para>another Samba-&smb.conf; setting of
4957                 <smbconfoption><name>printcap</name><value>cups</value></smbconfoption></para></listitem>
4958 </itemizedlist>
4960 <note><para>
4961 In this case all other manually set printing-related commands (like
4962 <smbconfoption><name>print command</name></smbconfoption>, 
4963 <smbconfoption><name>lpq command</name></smbconfoption>, 
4964 <smbconfoption><name>lprm command</name></smbconfoption>, 
4965 <smbconfoption><name>lppause command</name></smbconfoption> or
4966 <smbconfoption><name>lpresume command</name></smbconfoption>) are ignored and they should normally have no
4967 influence what-so-ever on your printing.
4968 </para></note>
4969 </sect2>
4971 <sect2>
4972 <title>Manual Configuration</title>
4974 <para>
4975 If you want to do things manually, replace the <smbconfoption><name>printing</name><value>cups</value></smbconfoption>
4976 by <smbconfoption><name>printing</name><value>bsd</value></smbconfoption>. Then your manually set commands may work
4977 (haven't tested this), and a <smbconfoption><name>print command</name><value>lp -d %P %s; rm %s"</value></smbconfoption>
4978 may do what you need.
4979 </para>
4980 </sect2>
4981 </sect1>
4983 <sect1>
4984 <title>In Case of Trouble.....</title>
4986 <para>
4987 If you have more problems, post the output of these commands
4988 to the CUPS or Samba mailing lists (choose the one which seems more
4989 relevant to your problem):
4990 </para>
4992 <para><screen>
4993 &prompt;<userinput>grep -v ^# /etc/cups/cupsd.conf | grep -v ^$</userinput>
4994 &prompt;<userinput>grep -v ^# /etc/samba/smb.conf | grep -v ^$ | grep -v "^;"</userinput>
4995 </screen></para>
4997 <para>
4998 (adapt paths as needed). These commands leave out the empty
4999 lines and lines with comments, providing the "naked settings" in a
5000 compact way. Don't forget to name the CUPS and Samba versions you
5001 are using! This saves bandwidth and makes for easier readability
5002 for experts (and you are expecting experts to read them, right?
5004 </para>
5006 </sect1>
5008 <sect1>
5009 <title>Printing <emphasis>from</emphasis> CUPS to Windows attached
5010 Printers</title>
5012 <para>
5013 From time to time the question arises, how you can print
5014 <emphasis>to</emphasis> a Windows attached printer
5015 <emphasis>from</emphasis> Samba. Normally the local connection
5016 from Windows host to printer would be done by USB or parallel
5017 cable, but this doesn't matter to Samba. From here only an SMB
5018 connection needs to be opened to the Windows host. Of course, this
5019 printer must be "shared" first. As you have learned by now, CUPS uses
5020 <emphasis>backends</emphasis> to talk to printers and other
5021 servers. To talk to Windows shared printers you need to use the
5022 <emphasis>smb</emphasis> (surprise, surprise!) backend. Check if this
5023 is in the CUPS backend directory. This resides usually in
5024 <filename>/usr/lib/cups/backend/</filename>. You need to find a "smb"
5025 file there. It should be a symlink to <filename>smbspool</filename>
5026 which file must exist and be executable:
5027 </para>
5029 <para><screen>
5030 &rootprompt;<userinput>ls -l /usr/lib/cups/backend/</userinput>
5031 total 253
5032 drwxr-xr-x    3 root     root          720 Apr 30 19:04 .
5033 drwxr-xr-x    6 root     root          125 Dec 19 17:13 ..
5034 -rwxr-xr-x    1 root     root        10692 Feb 16 21:29 canon
5035 -rwxr-xr-x    1 root     root        10692 Feb 16 21:29 epson
5036 lrwxrwxrwx    1 root     root            3 Apr 17 22:50 http -&gt; ipp
5037 -rwxr-xr-x    1 root     root        17316 Apr 17 22:50 ipp
5038 -rwxr-xr-x    1 root     root        15420 Apr 20 17:01 lpd
5039 -rwxr-xr-x    1 root     root         8656 Apr 20 17:01 parallel
5040 -rwxr-xr-x    1 root     root         2162 Mar 31 23:15 pdfdistiller
5041 lrwxrwxrwx    1 root     root           25 Apr 30 19:04 ptal -&gt; /usr/sbin/ptal-cups
5042 -rwxr-xr-x    1 root     root         6284 Apr 20 17:01 scsi
5043 lrwxrwxrwx    1 root     root           17 Apr  2 03:11 smb -&gt; /usr/bin/smbspool
5044 -rwxr-xr-x    1 root     root         7912 Apr 20 17:01 socket
5045 -rwxr-xr-x    1 root     root         9012 Apr 20 17:01 usb
5047 &rootprompt;<userinput>ls -l `which smbspool`</userinput>
5048 -rwxr-xr-x    1 root     root       563245 Dec 28 14:49 /usr/bin/smbspool
5049 </screen></para>
5051 <para>
5052 If this symlink doesn't exist, create it:
5053 </para>
5055 <para><screen>
5056 &rootprompt;<userinput>ln -s `which smbspool` /usr/lib/cups/backend/smb</userinput>
5057 </screen></para>
5059 <para>
5060 smbspool has been written by Mike Sweet from the CUPS folks.  It is
5061 included and ships with Samba. It may also be used with print
5062 subsystems other than CUPS, to spool jobs to Windows printer shares. To
5063 set up printer "winprinter" on CUPS, you need to have a "driver" for
5064 it. Essentially this means to convert the print data on the CUPS/Samba
5065 host to a format that the printer can digest (the Windows host is
5066 unable to convert any files you may send).  This also means you should
5067 be able to print to the printer if it were hooked directly at your
5068 Samba/CUPS host. For troubleshooting purposes, this is what you
5069 should do, to determine if that part of the process chain is in
5070 order. Then proceed to fix the network connection/authentication to
5071 the Windows host, etc.
5072 </para>
5074 <para>
5075 To install a printer with the smb backend on CUPS, use this command:
5076 </para>
5078 <para><screen>
5079 &rootprompt;<userinput>lpadmin -p winprinter -v smb://WINDOWSNETBIOSNAME/printersharename \
5080   -P /path/to/PPD</userinput>
5081 </screen></para>
5083 <para>
5084 The <emphasis>PPD</emphasis> must be able to direct CUPS to generate
5085 the print data for the target model. For PostScript printers just use
5086 the PPD that would be used with the Windows NT PostScript driver. But
5087 what can you do if the printer is only accessible with a password? Or
5088 if the printer's host is part of another workgroup? This is provided
5089 for: you can include the required parameters as part of the
5090 <filename>smb://</filename> device-URI. Like this:
5091 </para>
5093 <itemizedlist>
5094         <listitem><para>smb://WORKGROUP/WINDOWSNETBIOSNAME/printersharename </para></listitem>
5095         <listitem><para>smb://username:password@WORKGROUP/WINDOWSNETBIOSNAME/printersharename</para></listitem>
5096         <listitem><para>smb://username:password@WINDOWSNETBIOSNAME/printersharename</para></listitem>
5097 </itemizedlist>
5099 <para>
5100 Note that the device-URI will be visible in the process list of the
5101 Samba server (e.g. when someone uses the <command>ps -aux</command>
5102 command on Linux), even if the username and passwords are sanitized
5103 before they get written into the log files.  So this is an inherently
5104 insecure option. However it is the only one. Don't use it if you want
5105 to protect your passwords. Better share the printer in a way that
5106 doesn't require a password! Printing will only work if you have a
5107 working netbios name resolution up and running. Note that this is a
5108 feature of CUPS and you don't necessarily need to have smbd running
5109 (but who wants that? :-).
5110 </para>
5111 </sect1>
5113 <sect1>
5114 <title>More CUPS filtering Chains</title>
5116 <para>
5117 The following diagrams reveal how CUPS handles print jobs.
5118 </para>
5120 <image><imagefile>cups1</imagefile><imagedescription>Filtering chain 1</imagedescription></image>
5122 <image><imagefile>cups2</imagefile><imagedescription>Filtering chain with cupsomatic</imagedescription></image>
5124 <note><para>
5125 Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
5126 CUPS and ESP PrintPro plug-in where rastertosomething is noted.
5127 </para></note>
5129 <!--FIXME: Put this into diagrams... ?
5131 #########################################################################
5133 # And this is how it works for ESP PrintPro from 4.3:
5134 # ===================================================
5136 # SOMETHNG-FILEFORMAT
5137 #      |
5138 #      V
5139 #     somethingtops
5140 #      |
5141 #      V
5142 # APPLICATION/POSTSCRIPT
5143 #      |
5144 #      V
5145 #     pstops
5146 #      |
5147 #      V
5148 # APPLICATION/VND.CUPS-POSTSCRIPT
5149 #      |
5150 #      V
5151 #     gsrip
5152 #      |  (= "postscipt interpreter")
5153 #      V
5154 # APPLICATION/VND.CUPS-RASTER
5155 #      |
5156 #      V
5157 #     rastertosomething  (e.g. Gimp-Print filters may be plugged in here)
5158 #      |   (= "raster driver")
5159 #      V
5160 # SOMETHING-DEVICE-SPECIFIC
5161 #      |
5162 #      V
5163 #     backend
5165 # NOTE: Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
5166 #       CUPS and ESP PrintPro plug-in where rastertosomething is noted.
5168 #########################################################################
5169 </screen>
5171 <screen>
5172 #########################################################################
5174 # This is how "cupsomatic" would come into play with ESP PrintPro:
5175 # ================================================================
5178 # SOMETHNG-FILEFORMAT
5179 #      |
5180 #      V
5181 #    somethingtops
5182 #      |
5183 #      V
5184 # APPLICATION/POSTSCRIPT
5185 #      |
5186 #      V
5187 #    pstops
5188 #      |
5189 #      V
5190 # APPLICATION/VND.CUPS-POSTSCRIPT ================+
5191 #      |                                          V
5192 #      V                                         cupsomatic
5193 #    gsrip                                       (constructs complicated
5194 #      |  (= "postscipt interpreter")            Ghostscript commandline
5195 #      |                                         to let the file be
5196 #      V                                         processed by a
5197 # APPLICATION/VND.CUPS-RASTER                    "-sDEVICE=s.th."
5198 #      |                                         call...)
5199 #      V                                          |
5200 #    rastertosomething                            V
5201 #      |   (= "raster driver")      +=========================+
5202 #      |                            | Ghostscript at work.... |
5203 #      V                            |                         |
5204 # SOMETHING-DEVICE-SPECIFIC         *=========================+
5205 #      |                                          |
5206 #      V                                          |
5207 #    backend &lt;=================================+
5208 #      |
5209 #      V
5210 #    THE PRINTER
5212 # NOTE: Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
5213 #       CUPS and ESP PrintPro plug-in where rastertosomething is noted.
5215 #########################################################################
5216 </screen>
5218 <screen>
5219 #########################################################################
5221 # And this is how it works for CUPS from 1.1.15:
5222 # ==============================================
5224 # SOMETHNG-FILEFORMAT
5225 #      |
5226 #      V
5227 #     somethingtops
5228 #      |
5229 #      V
5230 # APPLICATION/POSTSCRIPT
5231 #      |
5232 #      V
5233 #     pstops
5234 #      |
5235 #      V
5236 # APPLICATION/VND.CUPS-POSTSCRIPT=====+
5237 #                  +==================v==============================+
5238 #                  | Ghostscript                                     |
5239 #                  | at work...                                      |
5240 #                  | (with                                           |
5241 #                  | "-sDEVICE=cups")                                |
5242 #                  |                                                 |
5243 #                  |         (= "postscipt interpreter")             |
5244 #                  |                                                 |
5245 #                  +==================v==============================+
5246 #                                     |
5247 # APPLICATION/VND.CUPS-RASTER &gt;====+
5248 #      |
5249 #      V
5250 #     rastertosomething
5251 #      |   (= "raster driver")
5252 #      V
5253 # SOMETHING-DEVICE-SPECIFIC
5254 #      |
5255 #      V
5256 #     backend
5259 # NOTE: since version 1.1.15 CUPS "outsourced" the pstoraster process to
5260 #       Ghostscript. GNU Ghostscript needs to be patched to handle the
5261 #       CUPS requirement; ESP Ghostscript has this builtin. In any case,
5262 #       "gs -h" needs to show up a "cups" device. pstoraster is now a
5263 #       calling an appropriate "gs -sDEVICE=cups..." commandline to do
5264 #       the job. It will output "application/vnd.cup-raster", which will
5265 #       be finally processed by a CUPS raster driver "rastertosomething"
5266 #       Note the difference to "cupsomatic", which will <emphasis>not</emphasis> output
5267 #       CUPS-raster, but a final version of the printfile, ready to be
5268 #       sent to the printer. cupsomatic also doesn't use the "cups"
5269 #       devicemode in Ghostscript, but one of the classical devicemodes....
5271 # NOTE: Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
5272 #       CUPS and ESP PrintPro plug-in where rastertosomething is noted.
5274 #########################################################################
5275 </screen>
5277 <screen>
5278 #########################################################################
5280 # And this is how it works for CUPS from 1.1.15, with cupsomatic included:
5281 # ========================================================================
5283 # SOMETHNG-FILEFORMAT
5284 #      |
5285 #      V
5286 #     somethingtops
5287 #      |
5288 #      V
5289 # APPLICATION/POSTSCRIPT
5290 #      |
5291 #      V
5292 #     pstops
5293 #      |
5294 #      V
5295 # APPLICATION/VND.CUPS-POSTSCRIPT=====+
5296 #                  +==================v==============================+
5297 #                  | Ghostscript        . Ghostscript at work....    |
5298 #                  | at work...         . (with "-sDEVICE=           |
5299 #                  | (with              .            s.th."          |
5300 #                  | "-sDEVICE=cups")   .                            |
5301 #                  |                    .                            |
5302 #                  | (CUPS standard)    .      (cupsomatic)          |
5303 #                  |                    .                            |
5304 #                  |          (= "postscript interpreter")           |
5305 #                  |                    .                            |
5306 #                  +==================v==============v===============+
5307 #                                     |              |
5308 # APPLICATION/VND.CUPS-RASTER &gt;=======+              |
5309 #      |                                             |
5310 #      V                                             |
5311 #     rastertosomething                              |
5312 #      |   (= "raster driver")                       |
5313 #      V                                             |
5314 # SOMETHING-DEVICE-SPECIFIC &gt;========================+
5315 #      |
5316 #      V
5317 #     backend
5320 # NOTE: Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
5321 #       CUPS and ESP PrintPro plug-in where rastertosomething is noted.
5323 ##########################################################################
5324 </screen>-->
5325 </sect1>
5327 <sect1>
5328         <title>Common Errors</title>
5330         <sect2>
5331                 <title>Win9x client can't install driver</title>
5333                 <para>For Win9x clients require the printer names to be 8
5334 chars (or "8 plus 3 chars suffix") max; otherwise the driver files
5335 won't get transferred when you want to download them from
5336 Samba.</para>
5338         </sect2>
5340         <sect2>
5341                 <title>"cupsaddsmb" keeps asking for root password in
5342                         neverending loop</title>
5344                 <para>Have you <smbconfoption><name>security</name><value>user</value></smbconfoption>? Have
5345 you used <command>smbpasswd</command> to give root a Samba account?
5346 You can do 2 things: open another terminal and execute
5347 <command>smbpasswd -a root</command> to create the account, and
5348 continue with entering the password into the first terminal. Or break
5349 out of the loop by hitting ENTER twice (without trying to type a
5350 password).</para>
5352         </sect2>
5354         <sect2>
5355                 <title>"cupsaddsmb" gives "No PPD file for printer..."
5356                         message while PPD file is present</title>
5358                 <para>Have you enabled printer sharing on CUPS? This means:
5359 do you have a <parameter>&lt;Location
5360 /printers&gt;....&lt;/Location&gt;</parameter> section in CUPS
5361 server's <filename>cupsd.conf</filename> which doesn't deny access to
5362 the host you run "cupsaddsmb" from?  It <emphasis>could</emphasis> be
5363 an issue if you use cupsaddsmb remotely, or if you use it with a
5364 <option>-h</option> parameter: <userinput>cupsaddsmb -H
5365         sambaserver -h cupsserver -v printername</userinput>.
5366 </para>
5367 <para>Is your
5368 "TempDir" directive in
5369 <emphasis>cupsd.conf</emphasis>
5370 set to a valid value and is it writeable?
5371 </para>
5373         </sect2>
5375         <sect2>
5376                 <title>Client can't connect to Samba printer</title>
5377         <para>Use <command>smbstatus</command> to check which user
5378 you are from Samba's point of view. Do you have the privileges to
5379 write into the <smbconfsection>[print$]</smbconfsection>
5380 share?</para>
5382         </sect2>
5384         <sect2>
5385                 <title>Can't reconnect to Samba under new account
5386                         from Win2K/XP</title>
5387         <para>Once you are connected as the "wrong" user (for
5388 example as "nobody", which often occurs if you have 
5389 <smbconfoption><name>map to guest</name><value>bad user</value></smbconfoption>), Windows Explorer will not accept an
5390 attempt to connect again as a different user. There won't be any byte
5391 transfered on the wire to Samba, but still you'll see a stupid error
5392 message which makes you think that Samba has denied access. Use
5393 <command>smbstatus</command> to check for active connections. Kill the
5394 PIDs. You still can't re-connect and get the dreaded
5395 <computeroutput>You can't connect with a second account from the same
5396 machine</computeroutput> message, as soon as you are trying? And you
5397 don't see any single byte arriving at Samba (see logs; use "ethereal")
5398 indicating a renewed connection attempt? Shut all Explorer Windows.
5399 This makes Windows forget what it has cached in its memory as
5400 established connections. Then re-connect as the right user. Best
5401 method is to use a DOS terminal window and <emphasis>first</emphasis>
5402 do <userinput>net use z: \\&example.server.samba;\print$ /user:root</userinput>. Check
5403 with <command>smbstatus</command> that you are connected under a
5404 different account. Now open the "Printers" folder (on the Samba server
5405 in the <emphasis>Network Neighbourhood</emphasis>), right-click the
5406 printer in question and select
5407 <emphasis>Connect...</emphasis></para></sect2>
5409 <sect2>
5410         <title>Avoid being connected to the Samba server as the
5411                 "wrong" user</title>
5412         
5413         <para>You see per <command>smbstatus</command> that you are
5414 connected as user "nobody"; while you wanted to be "root" or
5415 "printeradmin"? This is probably due to 
5416 <smbconfoption><name>map to guest</name><value>bad user</value></smbconfoption>, which silently connects you under the guest account,
5417 when you gave (maybe by accident) an incorrect username. Remove
5418 <smbconfoption><name>map to guest</name></smbconfoption>, if you want to prevent
5419 this.</para></sect2>
5421 <sect2><title>Upgrading to CUPS drivers from Adobe drivers on
5422                 NT/2K/XP clients gives problems</title>
5424         <para>First delete all "old" Adobe-using printers. Then
5425 delete all "old" Adobe drivers. (On Win2K/XP, right-click in
5426 background of "Printers" folder, select "Server Properties...", select
5427 tab "Drivers" and delete here).</para></sect2>
5429 <sect2><title>Can't use "cupsaddsmb" on Samba server which is
5430                 a PDC</title>
5431 <para>Do you use the "naked" root user name? Try to do it
5432 this way: <userinput>cupsaddsmb -U <replaceable>DOMAINNAME</replaceable>\\root -v
5433 <replaceable>printername</replaceable></userinput>> (note the two backslashes: the first one is
5434 required to "escape" the second one).</para></sect2>
5436 <sect2><title>Deleted Win2K printer driver is still shown</title>
5437 <para>Deleting a printer on the client won't delete the
5438 driver too (to verify, right-click on the white background of the
5439 "Printers" folder, select "Server Properties" and click on the
5440 "Drivers" tab). These same old drivers will be re-used when you try to
5441 install a printer with the same name. If you want to update to a new
5442 driver, delete the old ones first. Deletion is only possible if no
5443 other printer uses the same driver.</para></sect2>
5445 <sect2><title>Win2K/XP "Local Security
5446                 Policies"</title>
5447 <para><emphasis>Local Security Policies</emphasis> may not
5448 allow the installation of unsigned drivers. "Local Security Policies"
5449 may not allow the installation of printer drivers at
5450 all.</para></sect2>
5452 <sect2><title>WinXP clients: "Administrator can not install
5453                 printers for all local users"</title>
5454 <para>Windows XP handles SMB printers on a "per-user" basis.
5455 This means every user needs to install the printer himself. To have a
5456 printer available for everybody, you might want to use the built-in
5457 IPP client capabilities of WinXP. Add a printer with the print path of
5458 <emphasis>http://cupsserver:631/printers/printername</emphasis>.
5459 Still looking into this one: maybe a "logon script" could
5460 automatically install printers for all
5461 users.</para></sect2>
5463 <sect2><title>"Print Change Notify" functions on
5464                 NT-clients</title>
5465 <para>For "print change notify" functions on NT++ clients,
5466 these need to run the "Server" service first (re-named to
5467 <emphasis>File &amp; Print Sharing for MS Networks</emphasis> in
5468 XP).</para></sect2>
5470 <sect2><title>WinXP-SP1</title>
5471 <para>WinXP-SP1 introduced a <emphasis>Point and Print
5472 Restriction Policy</emphasis> (this restriction doesn't apply to
5473 "Administrator" or "Power User" groups of users).  In Group Policy
5474 Object Editor: go to <emphasis>User Configuration,
5475         Administrative Templates, Control Panel,
5476 Printers</emphasis>. The policy is automatically set to
5477 <emphasis>Enabled</emphasis> and the <emphasis>Users can only Point
5478 and Print to machines in their Forest</emphasis> . You probably need
5479 to change it to <emphasis>Disabled</emphasis> or <emphasis>Users can
5480 only Point and Print to these servers</emphasis> in order to make
5481 driver downloads from Samba possible.</para></sect2>
5483 <sect2><title>Print options for all     users can't be set on Win2K/XP</title>
5485 <para>How are you doing it? I bet the wrong way (it is not
5486 very easy to find out, though). There are 3 different ways to bring
5487 you to a dialog that <emphasis>seems</emphasis> to set everything. All
5488 three dialogs <emphasis>look</emphasis> the same. Only one of them
5489 <emphasis>does</emphasis> what you intend. You need to be
5490 Administrator or Print Administrator to do this for all users.  Here
5491 is how I do in on XP:
5492 </para>
5494 <orderedlist numeration="upperalpha">
5496 <listitem><para>The first "wrong" way:
5498 <orderedlist numeration="arabic">
5499 <listitem><para>Open the <emphasis>Printers</emphasis>
5500 folder.</para></listitem>
5502 <listitem><para>Right-click on the printer
5503 (<emphasis>remoteprinter on cupshost</emphasis>) and
5504 select in context menu <emphasis>Printing
5505 Preferences...</emphasis></para></listitem>
5507 <listitem><para>Look at this dialog closely and remember what it looks
5508 like.</para></listitem>
5509 </orderedlist>
5510 </para>
5511 </listitem>
5513 <listitem><para>The second "wrong" way:
5515 <orderedlist numeration="arabic">
5516 <listitem><para>Open the <emphasis>Printers</emphasis>
5517 folder.</para></listitem>
5519 <listitem><para>Right-click on the printer (<emphasis>remoteprinter on
5520 cupshost</emphasis>) and select in the context menu
5521 <emphasis>Properties</emphasis></para></listitem>
5523 <listitem><para>Click on the <emphasis>General</emphasis>
5524 tab</para></listitem>
5526 <listitem><para>Click on the button <emphasis>Printing
5527 Preferences...</emphasis></para></listitem>
5529 <listitem><para>A new dialog opens. Keep this dialog open and go back
5530 to the parent dialog.</para></listitem>
5531 </orderedlist>
5532 </para>
5533 </listitem>
5535 <listitem><para>The third, the "correct" way: (should you do
5536 this from the beginning, just carry out steps 1. and 2. from second
5537 "way" above)
5539 <orderedlist numeration="arabic">
5540 <listitem><para>Click on the <emphasis>Advanced</emphasis>
5541 tab. (Hmmm... if everything is "Grayed Out", then you are not logged
5542 in as a user with enough privileges).</para></listitem>
5544 <listitem><para>Click on the <emphasis>Printing
5545 Defaults...</emphasis> button.</para></listitem>
5547 <listitem><para>On any of the two new tabs, click on the
5548 <emphasis>Advanced...</emphasis>
5549 button.</para></listitem>
5551 <listitem><para>A new dialog opens. Compare this one to the other,
5552 identical looking one from "B.5" or A.3".</para></listitem>
5553 </orderedlist>
5554 </para>
5555 </listitem>
5556 </orderedlist>
5558 <para>
5559 Do you see any difference? I don't either... However, only the last
5560 one, which you arrived at with steps "C.1.-6." will save any settings
5561 permanently and be the defaults for new users. If you want all clients
5562 to get the same defaults, you need to conduct these steps <emphasis>as
5563 Administrator</emphasis> (<smbconfoption><name>printer admin</name></smbconfoption> in
5564 &smb.conf;) <emphasis>before</emphasis> a client
5565 downloads the driver (the clients can later set their own
5566 <emphasis>per-user defaults</emphasis> by following the
5567 procedures <emphasis>A.</emphasis> or <emphasis>B.</emphasis>
5568 above).</para></sect2>
5570 <sect2><title>Most common blunders in driver
5571                 settings on Windows clients</title>
5572         <para>Don't use <emphasis>Optimize for
5573 Speed</emphasis>: use <emphasis>Optimize for
5574 Portability</emphasis> instead (Adobe PS Driver) Don't use
5575 <emphasis>Page Independence: No</emphasis>: always
5576 settle with  <emphasis>Page Independence:
5577 Yes</emphasis> (Microsoft PS Driver and CUPS PS Driver for
5578 WinNT/2K/XP) If there are problems with fonts: use
5579 <emphasis>Download as Softfont into
5580 printer</emphasis> (Adobe PS Driver). For
5581 <emphasis>TrueType Download Options</emphasis>
5582 choose <emphasis>Outline</emphasis>. Use PostScript
5583 Level 2, if you are having trouble with a non-PS printer, and if
5584 there is a choice.</para></sect2>
5586 <sect2><title><command>cupsaddsmb</command> does not work
5587                 with newly installed printer</title>
5588 <para>Symptom: the last command of
5589 <command>cupsaddsmb</command> doesn't complete successfully:
5590 <command>cmd = setdriver printername printername</command> result was
5591 NT_STATUS_UNSUCCESSFUL then possibly the printer was not yet
5592 "recognized" by Samba. Did it show up in <emphasis>Network
5593 Neighbourhood</emphasis>? Did it show up in <command>rpcclient
5594 hostname -c 'enumprinters'</command>? Restart smbd (or send a
5595 <command>kill -HUP</command> to all processes listed by
5596 <command>smbstatus</command> and try
5597 again.</para></sect2>
5599 <sect2><title>Permissions on
5600 <filename>/var/spool/samba/</filename> get reset after each
5601 reboot</title>
5602 <para>Have you by accident set the CUPS spool directory to
5603 the same location? (<parameter>RequestRoot
5604 /var/spool/samba/</parameter> in <filename>cupsd.conf</filename> or
5605 the other way round: <filename>/var/spool/cups/</filename> is set as
5606 <smbconfoption><name>path</name></smbconfoption>> in the <smbconfsection>[printers]</smbconfsection>
5607 section). These <emphasis>must</emphasis> be different. Set
5608 <parameter>RequestRoot /var/spool/cups/</parameter> in
5609 <filename>cupsd.conf</filename> and <smbconfoption><name>path</name><value>
5610 /var/spool/samba</value></smbconfoption> in the <smbconfsection>[printers]</smbconfsection>
5611 section of &smb.conf;. Otherwise cupsd will
5612 sanitize permissions to its spool directory with each restart, and
5613 printing will not work reliably.</para></sect2>
5615 <sect2><title>Printer named "lp"
5616 intermittently swallows jobs and spits out completely different
5617 ones</title>
5618 <para>It is a very bad idea to name any printer "lp". This
5619 is the traditional UNIX name for the default printer. CUPS may be set
5620 up to do an automatic creation of "Implicit Classes". This means, to
5621 group all printers with the same name to a pool of devices, and
5622 loadbalancing the jobs across them in a round-robin fashion.  Chances
5623 are high that someone else has an "lp" named printer too.  You may
5624 receive his jobs and send your own to his device unwittingly. To have
5625 tight control over the printer names, set <parameter>BrowseShortNames
5626 No</parameter>. It will present any printer as "printername@cupshost"
5627 then, giving you a better control over what may happen in a large
5628 networked environment.</para></sect2>
5630 <sect2><title>Location of Adobe PostScript driver files necessary for "cupsaddsmb"</title>
5631 <para>Use <command>smbclient</command> to connect to any
5632 Windows box with a shared PostScript printer: <command>smbclient
5633 //windowsbox/print\$ -U guest</command>. You can navigate to the
5634 <filename>W32X86/2</filename> subdir to <command>mget ADOBE*</command>
5635 and other files or to <filename>WIN40/0</filename> to do the same. --
5636 Another option is to download the <filename>*.exe</filename> packaged
5637 files from the Adobe website.</para></sect2>
5639 </sect1>
5641 <sect1>
5642 <title>An Overview of the CUPS Printing Processes</title>
5644 <image><imagedescription>CUPS Printing Overview</imagedescription>
5645         <imagefile>a_small</imagefile>
5646 </image>
5647 </sect1>
5649 </chapter>