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