1 <chapter id="printing">
6 <firstname>Patrick</firstname><surname>Powell</surname>
8 <address><email>papowell@lprng.org</email></address>
11 <pubdate> (3 May 2001) </pubdate>
14 <title>Printing Support</title>
17 <title>Introduction</title>
19 <para>Beginning with the 2.2.0 release, Samba supports
20 the native Windows NT printing mechanisms implemented via
21 MS-RPC (i.e. the SPOOLSS named pipe). Previous versions of
22 Samba only supported LanMan printing calls.</para>
24 <para>The additional functionality provided by the new
25 SPOOLSS support includes:</para>
28 <listitem><para>Support for downloading printer driver
29 files to Windows 95/98/NT/2000 clients upon demand.
32 <listitem><para>Uploading of printer drivers via the
33 Windows NT Add Printer Wizard (APW) or the
34 Imprints tool set (refer to <ulink
35 url="http://imprints.sourceforge.net">http://imprints.sourceforge.net</ulink>).
38 <listitem><para>Support for the native MS-RPC printing
39 calls such as StartDocPrinter, EnumJobs(), etc... (See
40 the MSDN documentation at <ulink
41 url="http://msdn.microsoft.com/">http://msdn.microsoft.com/</ulink>
42 for more information on the Win32 printing API)
45 <listitem><para>Support for NT Access Control Lists (ACL)
46 on printer objects</para></listitem>
48 <listitem><para>Improved support for printer queue manipulation
49 through the use of an internal databases for spooled job
50 information</para></listitem>
54 There has been some initial confusion about what all this means
55 and whether or not it is a requirement for printer drivers to be
56 installed on a Samba host in order to support printing from Windows
57 clients. As a side note, Samba does not use these drivers in any way to process
58 spooled files. They are utilized entirely by the clients.
62 The following MS KB article, may be of some help if you are dealing with
63 Windows 2000 clients: <emphasis>How to Add Printers with No User
64 Interaction in Windows 2000</emphasis>
68 <ulink url="http://support.microsoft.com/support/kb/articles/Q189/1/05.ASP">http://support.microsoft.com/support/kb/articles/Q189/1/05.ASP</ulink>
75 <title>Configuration</title>
78 <title>[print$] vs. [printer$]</title>
81 Previous versions of Samba recommended using a share named [printer$].
82 This name was taken from the printer$ service created by Windows 9x
83 clients when a printer was shared. Windows 9x printer servers always have
84 a printer$ service which provides read-only access via no
85 password in order to support printer driver downloads.
89 However, the initial implementation allowed for a
90 parameter named <parameter>printer driver location</parameter>
91 to be used on a per share basis to specify the location of
92 the driver files associated with that printer. Another
93 parameter named <parameter>printer driver</parameter> provided
94 a means of defining the printer driver name to be sent to
101 <title>Creating [print$]</title>
104 In order to support the uploading of printer driver
105 files, you must first configure a file share named [print$].
106 The name of this share is hard coded in Samba's internals so
107 the name is very important (print$ is the service used by
108 Windows NT print servers to provide support for printer driver
112 <para>You should modify the server's smb.conf file to add the global
113 parameters and to create the
114 following file share (of course, some of the parameter values,
115 such as 'path' are arbitrary and should be replaced with
116 appropriate values for your site):</para>
118 <para><programlisting>
120 ; members of the ntadmin group should be able
121 ; to add drivers and set printer properties
122 ; root is implicitly a 'printer admin'
123 printer admin = @ntadmin
126 path = /usr/local/samba/printers
130 ; since this share is configured as read only, then we need
131 ; a 'write list'. Check the file system permissions to make
132 ; sure this account can copy files to the share. If this
133 ; is setup to a non-root account, then it should also exist
134 ; as a 'printer admin'
135 write list = @ntadmin,root
136 </programlisting></para>
138 <para>The <ulink url="smb.conf.5.html#WRITELIST"><parameter>
139 write list</parameter></ulink> is used to allow administrative
140 level user accounts to have write access in order to update files
141 on the share. See the <ulink url="smb.conf.5.html">smb.conf(5)
142 man page</ulink> for more information on configuring file shares.</para>
144 <para>The requirement for <ulink url="smb.conf.5.html#GUESTOK"><command>guest
145 ok = yes</command></ulink> depends upon how your
146 site is configured. If users will be guaranteed to have
147 an account on the Samba host, then this is a non-issue.</para>
150 <title>Author's Note</title>
153 The non-issue is that if all your Windows NT users are guaranteed to be
154 authenticated by the Samba server (such as a domain member server and the NT
155 user has already been validated by the Domain Controller in
156 order to logon to the Windows NT console), then guest access
157 is not necessary. Of course, in a workgroup environment where
158 you just want to be able to print without worrying about
159 silly accounts and security, then configure the share for
160 guest access. You'll probably want to add <ulink
161 url="smb.conf.5.html#MAPTOGUEST"><command>map to guest = Bad User
162 </command></ulink> in the [global] section as well. Make sure
163 you understand what this parameter does before using it
168 <para>In order for a Windows NT print server to support
169 the downloading of driver files by multiple client architectures,
170 it must create subdirectories within the [print$] service
171 which correspond to each of the supported client architectures.
172 Samba follows this model as well.</para>
174 <para>Next create the directory tree below the [print$] share
175 for each architecture you wish to support.</para>
177 <para><computeroutput>
179 |-W32X86 ; "Windows NT x86"
180 |-WIN40 ; "Windows 95/98"
181 |-W32ALPHA ; "Windows NT Alpha_AXP"
182 |-W32MIPS ; "Windows NT R4000"
183 |-W32PPC ; "Windows NT PowerPC"
184 </computeroutput></para>
187 <title>ATTENTION! REQUIRED PERMISSIONS</title>
190 In order to currently add a new driver to you Samba host,
191 one of two conditions must hold true:
195 <listitem><para>The account used to connect to the Samba host
196 must have a uid of 0 (i.e. a root account)</para></listitem>
198 <listitem><para>The account used to connect to the Samba host
199 must be a member of the <ulink
200 url="smb.conf.5.html#PRINTERADMIN"><parameter>printer
201 admin</parameter></ulink> list.</para></listitem>
205 Of course, the connected account must still possess access
206 to add files to the subdirectories beneath [print$]. Remember
207 that all file shares are set to 'read only' by default.
213 Once you have created the required [print$] service and
214 associated subdirectories, simply log onto the Samba server using
215 a root (or <parameter>printer admin</parameter>) account
216 from a Windows NT 4.0/2k client. Open "Network Neighbourhood" or
217 "My Network Places" and browse for the Samba host. Once you have located
218 the server, navigate to the "Printers..." folder.
219 You should see an initial listing of printers
220 that matches the printer shares defined on your Samba host.
225 <title>Setting Drivers for Existing Printers</title>
227 <para>The initial listing of printers in the Samba host's
228 Printers folder will have no real printer driver assigned
229 to them. This defaults to a NULL string to allow the use
230 of the local Add Printer Wizard on NT/2000 clients.
231 Attempting to view the printer properties for a printer
232 which has this default driver assigned will result in
233 the error message:</para>
236 <emphasis>Device settings cannot be displayed. The driver
237 for the specified printer is not installed, only spooler
238 properties will be displayed. Do you want to install the
239 driver now?</emphasis>
243 Click "No" in the error dialog and you will be presented with
244 the printer properties window. The way to assign a driver to a
249 <listitem><para>Use the "New Driver..." button to install
250 a new printer driver, or</para></listitem>
252 <listitem><para>Select a driver from the popup list of
253 installed drivers. Initially this list will be empty.</para>
257 <para>If you wish to install printer drivers for client
258 operating systems other than "Windows NT x86", you will need
259 to use the "Sharing" tab of the printer properties dialog.</para>
261 <para>Assuming you have connected with a root account, you
262 will also be able modify other printer properties such as
263 ACLs and device settings using this dialog box.</para>
265 <para>A few closing comments for this section, it is possible
266 on a Windows NT print server to have printers
267 listed in the Printers folder which are not shared. Samba does
268 not make this distinction. By definition, the only printers of
269 which Samba is aware are those which are specified as shares in
270 <filename>smb.conf</filename>.</para>
272 <para>Another interesting side note is that Windows NT clients do
273 not use the SMB printer share, but rather can print directly
274 to any printer on another Windows NT host using MS-RPC. This
275 of course assumes that the printing client has the necessary
276 privileges on the remote host serving the printer. The default
277 permissions assigned by Windows NT to a printer gives the "Print"
278 permissions to the "Everyone" well-known group.
285 <title>Support a large number of printers</title>
287 <para>One issue that has arisen during the development
288 phase of Samba 2.2 is the need to support driver downloads for
289 100's of printers. Using the Windows NT APW is somewhat
290 awkward to say the list. If more than one printer are using the
291 same driver, the <ulink url="rpcclient.1.html"><command>rpcclient's
292 setdriver command</command></ulink> can be used to set the driver
293 associated with an installed driver. The following is example
294 of how this could be accomplished:</para>
297 <prompt>$ </prompt><userinput>rpcclient pogo -U root%secret -c "enumdrivers"</userinput>
299 Domain=[NARNIA] OS=[Unix] Server=[Samba 2.2.0-alpha3]
302 Printer Driver Info 1:
303 Driver Name: [HP LaserJet 4000 Series PS]
305 Printer Driver Info 1:
306 Driver Name: [HP LaserJet 2100 Series PS]
308 Printer Driver Info 1:
309 Driver Name: [HP LaserJet 4Si/4SiMX PS]
311 <prompt>$ </prompt><userinput>rpcclient pogo -U root%secret -c "enumprinters"</userinput>
313 Domain=[NARNIA] OS=[Unix] Server=[Samba 2.2.0-alpha3]
315 name:[\\POGO\hp-print]
316 description:[POGO\\POGO\hp-print,NO DRIVER AVAILABLE FOR THIS PRINTER,]
320 <prompt>$ </prompt><userinput>rpcclient pogo -U root%secret -c "setdriver hp-print \"HP LaserJet 4000 Series PS\""</userinput>
322 Domain=[NARNIA] OS=[Unix] Server=[Samba 2.2.0-alpha3]
323 Successfully set hp-print to driver HP LaserJet 4000 Series PS.
324 </programlisting></para>
330 <title>Adding New Printers via the Windows NT APW</title>
333 By default, Samba offers all printer shares defined in <filename>smb.conf</filename>
334 in the "Printers..." folder. Also existing in this folder is the Windows NT
335 Add Printer Wizard icon. The APW will be show only if
339 <listitem><para>The connected user is able to successfully
340 execute an OpenPrinterEx(\\server) with administrative
341 privileges (i.e. root or <parameter>printer admin</parameter>).
344 <listitem><para><ulink url="smb.conf.5.html#SHOWADDPRINTERWIZARD"><parameter>show
345 add printer wizard = yes</parameter></ulink> (the default).
350 In order to be able to use the APW to successfully add a printer to a Samba
351 server, the <ulink url="smb.conf.5.html#ADDPRINTERCOMMAND"><parameter>add
352 printer command</parameter></ulink> must have a defined value. The program
353 hook must successfully add the printer to the system (i.e.
354 <filename>/etc/printcap</filename> or appropriate files) and
355 <filename>smb.conf</filename> if necessary.
359 When using the APW from a client, if the named printer share does
360 not exist, <command>smbd</command> will execute the <parameter>add printer
361 command</parameter> and reparse to the <filename>smb.conf</filename>
362 to attempt to locate the new printer share. If the share is still not defined,
363 an error of "Access Denied" is returned to the client. Note that the
364 <parameter>add printer program</parameter> is executed under the context
365 of the connected user, not necessarily a root account.
369 There is a complementary <ulink url="smb.conf.5.html#DELETEPRINTERCOMMAND"><parameter>delete
370 printer command</parameter></ulink> for removing entries from the "Printers..."
375 The following is an example <ulink url="smb.conf.5.html#ADDPRINTERCOMMAN"><parameter>add printer command</parameter></ulink> script. It adds the appropriate entries to <filename>/etc/printcap.local</filename> (change that to what you need) and returns a line of 'Done' which is needed for the whole process to work.
381 # Script to insert a new printer entry into printcap.local
383 # $1, printer name, used as the descriptive name
384 # $2, share name, used as the printer name for Linux
387 # $5, location, used for the device file of the printer
391 # Make sure we use the location that RedHat uses for local printer defs
392 PRINTCAP=/etc/printcap.local
393 DATE=`date +%Y%m%d-%H%M%S`
395 RESTART="service lpd restart"
398 cp $PRINTCAP $PRINTCAP.$DATE
399 # Add the printer to $PRINTCAP
401 echo "$2|$1:\\" >> $PRINTCAP
402 echo " :sd=/var/spool/lpd/$2:\\" >> $PRINTCAP
403 echo " :mx=0:ml=0:sh:\\" >> $PRINTCAP
404 echo " :lp=/usr/local/samba/var/print/$5.prn:" >> $PRINTCAP
406 touch "/usr/local/samba/var/print/$5.prn" >> /tmp/printadd.$$ 2>&1
407 chown $LP "/usr/local/samba/var/print/$5.prn" >> /tmp/printadd.$$ 2>&1
409 mkdir /var/spool/lpd/$2
410 chmod 700 /var/spool/lpd/$2
411 chown $LP /var/spool/lpd/$2
412 #echo $1 >> "/usr/local/samba/var/print/$5.prn"
413 #echo $2 >> "/usr/local/samba/var/print/$5.prn"
414 #echo $3 >> "/usr/local/samba/var/print/$5.prn"
415 #echo $4 >> "/usr/local/samba/var/print/$5.prn"
416 #echo $5 >> "/usr/local/samba/var/print/$5.prn"
417 #echo $6 >> "/usr/local/samba/var/print/$5.prn"
418 $RESTART >> "/usr/local/samba/var/print/$5.prn"
419 # Not sure if this is needed
420 touch /usr/local/samba/lib/smb.conf
422 # You need to return a value, but I am not sure what it means.
432 <title>Samba and Printer Ports</title>
435 Windows NT/2000 print servers associate a port with each printer. These normally
436 take the form of LPT1:, COM1:, FILE:, etc... Samba must also support the
437 concept of ports associated with a printer. By default, only one printer port,
438 named "Samba Printer Port", exists on a system. Samba does not really a port in
439 order to print, rather it is a requirement of Windows clients.
443 Note that Samba does not support the concept of "Printer Pooling" internally
444 either. This is when a logical printer is assigned to multiple ports as
445 a form of load balancing or fail over.
449 If you require that multiple ports be defined for some reason,
450 <filename>smb.conf</filename> possesses a <ulink
451 url="smb.conf.5.html#ENUMPORTSCOMMAND"><parameter>enumports
452 command</parameter></ulink> which can be used to define an external program
453 that generates a listing of ports on a system.
462 <title>The Imprints Toolset</title>
464 <para>The Imprints tool set provides a UNIX equivalent of the
465 Windows NT Add Printer Wizard. For complete information, please
466 refer to the Imprints web site at <ulink url="http://imprints.sourceforge.net/">
467 http://imprints.sourceforge.net/</ulink> as well as the documentation
468 included with the imprints source distribution. This section will
469 only provide a brief introduction to the features of Imprints.</para>
473 <title>What is Imprints?</title>
475 <para>Imprints is a collection of tools for supporting the goals
479 <listitem><para>Providing a central repository information
480 regarding Windows NT and 95/98 printer driver packages</para>
483 <listitem><para>Providing the tools necessary for creating
484 the Imprints printer driver packages.</para></listitem>
486 <listitem><para>Providing an installation client which
487 will obtain and install printer drivers on remote Samba
488 and Windows NT 4 print servers.</para></listitem>
495 <title>Creating Printer Driver Packages</title>
497 <para>The process of creating printer driver packages is beyond
498 the scope of this document (refer to Imprints.txt also included
499 with the Samba distribution for more information). In short,
500 an Imprints driver package is a gzipped tarball containing the
501 driver files, related INF files, and a control file needed by the
502 installation client.</para>
507 <title>The Imprints server</title>
509 <para>The Imprints server is really a database server that
510 may be queried via standard HTTP mechanisms. Each printer
511 entry in the database has an associated URL for the actual
512 downloading of the package. Each package is digitally signed
513 via GnuPG which can be used to verify that package downloaded
514 is actually the one referred in the Imprints database. It is
515 <emphasis>not</emphasis> recommended that this security check
520 <title>The Installation Client</title>
522 <para>More information regarding the Imprints installation client
523 is available in the <filename>Imprints-Client-HOWTO.ps</filename>
524 file included with the imprints source package.</para>
526 <para>The Imprints installation client comes in two forms.</para>
529 <listitem><para>a set of command line Perl scripts</para>
532 <listitem><para>a GTK+ based graphical interface to
533 the command line perl scripts</para></listitem>
536 <para>The installation client (in both forms) provides a means
537 of querying the Imprints database server for a matching
538 list of known printer model names as well as a means to
539 download and install the drivers on remote Samba and Windows
540 NT print servers.</para>
542 <para>The basic installation process is in four steps and
543 perl code is wrapped around <command>smbclient</command>
544 and <command>rpcclient</command>.</para>
546 <para><programlisting>
547 foreach (supported architecture for a given driver)
549 1. rpcclient: Get the appropriate upload directory
551 2. smbclient: Upload the driver files
552 3. rpcclient: Issues an AddPrinterDriver() MS-RPC
555 4. rpcclient: Issue an AddPrinterEx() MS-RPC to actually
557 </programlisting></para>
559 <para>One of the problems encountered when implementing
560 the Imprints tool set was the name space issues between
561 various supported client architectures. For example, Windows
562 NT includes a driver named "Apple LaserWriter II NTX v51.8"
563 and Windows 95 calls its version of this driver "Apple
564 LaserWriter II NTX"</para>
566 <para>The problem is how to know what client drivers have
567 been uploaded for a printer. As astute reader will remember
568 that the Windows NT Printer Properties dialog only includes
569 space for one printer driver name. A quick look in the
570 Windows NT 4.0 system registry at</para>
572 <para><filename>HKLM\System\CurrentControlSet\Control\Print\Environment
575 <para>will reveal that Windows NT always uses the NT driver
576 name. This is ok as Windows NT always requires that at least
577 the Windows NT version of the printer driver is present.
578 However, Samba does not have the requirement internally.
579 Therefore, how can you use the NT driver name if is has not
580 already been installed?</para>
582 <para>The way of sidestepping this limitation is to require
583 that all Imprints printer driver packages include both the Intel
584 Windows NT and 95/98 printer drivers and that NT driver is
585 installed first.</para>
592 This comment from rpc_server/srv_spoolss_nt.c:_spoolss_open_printer_ex()
593 needs to be added into a section probably. This is to remind me it needs
597 * If the openprinterex rpc call contains a devmode,
598 * it's a per-user one. This per-user devmode is derivated
599 * from the global devmode. Openprinterex() contains a per-user
600 * devmode for when you do EMF printing and spooling.
601 * In the EMF case, the NT workstation is only doing half the job
602 * of rendering the page. The other half is done by running the printer
603 * driver on the server.
604 * The EMF file doesn't contain the page description (paper size, orientation, ...).
605 * The EMF file only contains what is to be printed on the page.
606 * So in order for the server to know how to print, the NT client sends
607 * a devicemode attached to the openprinterex call.
608 * But this devicemode is short lived, it's only valid for the current print job.
610 * If Samba would have supported EMF spooling, this devicemode would
611 * have been attached to the handle, to sent it to the driver to correctly
612 * rasterize the EMF file.
614 * As Samba only supports RAW spooling, we only receive a ready-to-print file,
615 * we just act as a pass-thru between windows and the printer.
617 * In order to know that Samba supports only RAW spooling, NT has to call
618 * getprinter() at level 2 (attribute field) or NT has to call startdoc()
619 * and until NT sends a RAW job, we refuse it.
621 * But to call getprinter() or startdoc(), you first need a valid handle,
622 * and to get an handle you have to call openprintex(). Hence why you have
623 * a devicemode in the openprinterex() call.
626 * Differences between NT4 and NT 2000.
629 * On NT4, you only have a global devicemode. This global devicemode can be changed
630 * by the administrator (or by a user with enough privs). Every time a user
631 * wants to print, the devicemode is reset to the default. In Word, every time
632 * you print, the printer's characteristics are always reset to the global devicemode.
636 * In W2K, there is the notion of per-user devicemode. The first time you use
637 * a printer, a per-user devicemode is build from the global devicemode.
638 * If you change your per-user devicemode, it is saved in the registry, under the
639 * H_KEY_CURRENT_KEY sub_tree. So that every time you print, you have your default
640 * printer preferences available.
642 * To change the per-user devicemode: it's the "Printing Preferences ..." button
643 * on the General Tab of the printer properties windows.
645 * To change the global devicemode: it's the "Printing Defaults..." button
646 * on the Advanced Tab of the printer properties window.
650 <title>Diagnosis</title>
653 <title>Introduction</title>
656 This is a short description of how to debug printing problems with
657 Samba. This describes how to debug problems with printing from a SMB
658 client to a Samba server, not the other way around. For the reverse
659 see the examples/printing directory.
663 Ok, so you want to print to a Samba server from your PC. The first
664 thing you need to understand is that Samba does not actually do any
665 printing itself, it just acts as a middleman between your PC client
666 and your Unix printing subsystem. Samba receives the file from the PC
667 then passes the file to a external "print command". What print command
668 you use is up to you.
672 The whole things is controlled using options in smb.conf. The most
673 relevant options (which you should look up in the smb.conf man page)
677 <para><programlisting>
679 print command - send a file to a spooler
680 lpq command - get spool queue status
681 lprm command - remove a job
683 path = /var/spool/lpd/samba
684 </programlisting></para>
687 The following are nice to know about:
690 <para><programlisting>
691 queuepause command - stop a printer or print queue
692 queueresume command - start a printer or print queue
693 </programlisting></para>
699 <para><programlisting>
700 print command = /usr/bin/lpr -r -P%p %s
701 lpq command = /usr/bin/lpq -P%p %s
702 lprm command = /usr/bin/lprm -P%p %j
703 queuepause command = /usr/sbin/lpc -P%p stop
704 queuepause command = /usr/sbin/lpc -P%p start
705 </programlisting></para>
708 Samba should set reasonable defaults for these depending on your
709 system type, but it isn't clairvoyant. It is not uncommon that you
710 have to tweak these for local conditions. The commands should
711 always have fully specified pathnames, as the smdb may not have
712 the correct PATH values.
716 When you send a job to Samba to be printed, it will make a temporary
717 copy of it in the directory specified in the [printers] section.
718 and it should be periodically cleaned out. The lpr -r option
719 requests that the temporary copy be removed after printing; If
720 printing fails then you might find leftover files in this directory,
721 and it should be periodically cleaned out. Samba used the lpq
722 command to determine the "job number" assigned to your print job
727 The %>letter< are "macros" that get dynamically replaced with appropriate
728 values when they are used. The %s gets replaced with the name of the spool
729 file that Samba creates and the %p gets replaced with the name of the
730 printer. The %j gets replaced with the "job number" which comes from
737 <title>Debugging printer problems</title>
740 One way to debug printing problems is to start by replacing these
741 command with shell scripts that record the arguments and the contents
742 of the print file. A simple example of this kind of things might
746 <para><programlisting>
747 print command = /tmp/saveprint %p %s
750 # we make sure that we are the right user
751 /usr/bin/id -p >/tmp/tmp.print
752 # we run the command and save the error messages
753 # replace the command with the one appropriate for your system
754 /usr/bin/lpr -r -P$1 $2 2>>&/tmp/tmp.print
755 </programlisting></para>
758 Then you print a file and try removing it. You may find that the
759 print queue needs to be stopped in order to see the queue status
763 <para><programlisting>
765 h4: {42} % echo hi >/tmp/hi
766 h4: {43} % smbclient //localhost/lw4
767 added interface ip=10.0.0.4 bcast=10.0.0.255 nmask=255.255.255.0
769 Domain=[ASTART] OS=[Unix] Server=[Samba 2.0.7]
770 smb: \> print /tmp/hi
771 putting file /tmp/hi as hi-17534 (0.0 kb/s) (average 0.0 kb/s)
775 Error cancelling job 1049 : code 0
780 </programlisting></para>
783 The 'code 0' indicates that the job was removed. The comment
784 by the smbclient is a bit misleading on this.
785 You can observe the command output and then and look at the
786 /tmp/tmp.print file to see what the results are. You can quickly
787 find out if the problem is with your printing system. Often people
788 have problems with their /etc/printcap file or permissions on
789 various print queues.
794 <title>What printers do I have?</title>
797 You can use the 'testprns' program to check to see if the printer
798 name you are using is recognized by Samba. For example, you can
802 <para><programlisting>
803 testprns printer /etc/printcap
804 </programlisting></para>
807 Samba can get its printcap information from a file or from a program.
808 You can try the following to see the format of the extracted
812 <para><programlisting>
813 testprns -a printer /etc/printcap
815 testprns -a printer '|/bin/cat printcap'
816 </programlisting></para>
821 <title>Setting up printcap and print servers</title>
824 You may need to set up some printcaps for your Samba system to use.
825 It is strongly recommended that you use the facilities provided by
826 the print spooler to set up queues and printcap information.
830 Samba requires either a printcap or program to deliver printcap
831 information. This printcap information has the format:
834 <para><programlisting>
835 name|alias1|alias2...:option=value:...
836 </programlisting></para>
839 For almost all printing systems, the printer 'name' must be composed
840 only of alphanumeric or underscore '_' characters. Some systems also
841 allow hyphens ('-') as well. An alias is an alternative name for the
842 printer, and an alias with a space in it is used as a 'comment'
843 about the printer. The printcap format optionally uses a \ at the end of lines
844 to extend the printcap to multiple lines.
848 Here are some examples of printcap files:
857 pr|alias printer name and alias
860 pr|My Printer printer name, alias used as comment
863 pr:sh:\ Same as pr:sh:cm= testing
868 pr:sh Same as pr:sh:cm= testing
875 Samba reads the printcap information when first started. If you make
876 changes in the printcap information, then you must do the following:
882 make sure that the print spooler is aware of these changes.
883 The LPRng system uses the 'lpc reread' command to do this.
887 make sure that the spool queues, etc., exist and have the
888 correct permissions. The LPRng system uses the 'checkpc -f'
893 You now should send a SIGHUP signal to the smbd server to have
894 it reread the printcap information.
901 <title>Job sent, no output</title>
904 This is the most frustrating part of printing. You may have sent the
905 job, verified that the job was forwarded, set up a wrapper around
906 the command to send the file, but there was no output from the printer.
910 First, check to make sure that the job REALLY is getting to the
911 right print queue. If you are using a BSD or LPRng print spooler,
912 you can temporarily stop the printing of jobs. Jobs can still be
913 submitted, but they will not be printed. Use:
916 <para><programlisting>
918 </programlisting></para>
921 Now submit a print job and then use 'lpq -Pprinter' to see if the
922 job is in the print queue. If it is not in the print queue then
923 you will have to find out why it is not being accepted for printing.
927 Next, you may want to check to see what the format of the job really
928 was. With the assistance of the system administrator you can view
929 the submitted jobs files. You may be surprised to find that these
930 are not in what you would expect to call a printable format.
931 You can use the UNIX 'file' utitily to determine what the job
935 <para><programlisting>
936 cd /var/spool/lpd/printer # spool directory of print jobs
939 </programlisting></para>
942 You should make sure that your printer supports this format OR that
943 your system administrator has installed a 'print filter' that will
944 convert the file to a format appropriate for your printer.
950 <title>Job sent, strange output</title>
953 Once you have the job printing, you can then start worrying about
954 making it print nicely.
958 The most common problem is extra pages of output: banner pages
959 OR blank pages at the end.
963 If you are getting banner pages, check and make sure that the
964 printcap option or printer option is configured for no banners.
965 If you have a printcap, this is the :sh (suppress header or banner
966 page) option. You should have the following in your printer.
969 <para><programlisting>
971 </programlisting></para>
974 If you have this option and are still getting banner pages, there
975 is a strong chance that your printer is generating them for you
976 automatically. You should make sure that banner printing is disabled
977 for the printer. This usually requires using the printer setup software
978 or procedures supplied by the printer manufacturer.
982 If you get an extra page of output, this could be due to problems
983 with your job format, or if you are generating PostScript jobs,
984 incorrect setting on your printer driver on the MicroSoft client.
985 For example, under Win95 there is a option:
988 <para><programlisting>
989 Printers|Printer Name|(Right Click)Properties|Postscript|Advanced|
990 </programlisting></para>
993 that allows you to choose if a Ctrl-D is appended to all jobs.
994 This is a very bad thing to do, as most spooling systems will
995 automatically add a ^D to the end of the job if it is detected as
996 PostScript. The multiple ^D may cause an additional page of output.
1002 <title>Raw PostScript printed</title>
1005 This is a problem that is usually caused by either the print spooling
1006 system putting information at the start of the print job that makes
1007 the printer think the job is a text file, or your printer simply
1008 does not support PostScript. You may need to enable 'Automatic
1009 Format Detection' on your printer.
1015 <title>Advanced Printing</title>
1018 Note that you can do some pretty magic things by using your
1019 imagination with the "print command" option and some shell scripts.
1020 Doing print accounting is easy by passing the %U option to a print
1021 command shell script. You could even make the print command detect
1022 the type of output and its size and send it to an appropriate
1029 <title>Real debugging</title>
1032 If the above debug tips don't help, then maybe you need to bring in
1033 the bug guns, system tracing. See Tracing.txt in this directory.