source: vendor/current/docs-xml/Samba3-HOWTO/TOSHARG-CUPS-printing.xml

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

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