[TriLUG] HOWTO: Create PDFs using Samba but not CUPS

Brian Henning brian at strutmasters.com
Mon Sep 26 13:43:12 EDT 2005


Hi Folks!
   Here's the conclusion to "samba printing.. ugh".

Building off the previously referenced website..  You'll need the 
following shell script in a handy location with 755 permissions (or make 
sure the samba user [typically 'nobody'] has the right access rights to it):

-- begin script quote --
#!/bin/sh

# Simple script to convert a specified postscript file into a PDF document
# and place it in a location that is shared by the Samba server.
#
# Arguments:
#   1st - The name of the spool file
#
# John Bright, 2001, jbright at winfordeng.com

# 26-Sep-2005 - Brian Henning
# TODO: We really need to  find a way to link PDFs with their respective
# Sales Orders.  This is way not idiot-proof enough.

# We will create the pdf into a temporary file based upon the current
# date and time.  After we are finished, we'll rename it to a file with
# the same date, but ending in .pdf.  We do this because if a user tries
# to open a PDF that is still being written, they will get a message
# that it is corrupt, when it is actually just not done yet.

DATE=`date +%b%d-%H%M%S`

# Directory in which to place the output
# Be sure this directory exists and is writable by the user that Samba
# is running as (for example, the nobody user)
OUTDIR=/home/public

ps2pdf $1 $OUTDIR/$DATE.temp
mv $OUTDIR/$DATE.temp $OUTDIR/$DATE.pdf
rm $1

-- end script quote --

For the rest of this HOWTO, we assume this script is named 
/usr/share/pdfconvert

Then, you'll need to adjust your smb.conf (typically found in 
/etc/samba/smb.conf).

Under [global], you'll need to tell Samba not to use CUPS for printing, 
and use LPRNG instead.  This is done with a line:
	printing = lprng

Then you'll need a share for the actual printer.  À la:

[pdffer]
	postscript = yes
	printable = yes
	print command = /usr/share/pdfconvert %s
	writeable = yes
	path = /tmp
	create mask = 0744
	comment = Prints to a PDF file
	public = yes

Some of those lines may not be absolutes; i.e. "writeable" may not be 
necessary, and "create mask" may only need to be "700".  This is what 
worked for me, and includes some results of shots-in-dark before I found 
the real answer.

Restart samba (or wait 60 seconds for it to reload its config).

Map the printer in Windows.  Windows will complain about not knowing 
what kind of printer it's connecting to.  Choose any PS printer; I chose 
an HP LaserJet 4000 PS.  Be sure to choose a PS driver and not a PCL 
driver.  Beyond that, it doesn't particularly matter; Windows uses the 
same core PS engine for all its built-in PS drivers.

That should do it.  Windows may advise you "Access denied, unable to 
connect" when you open Printers and Faxes, or when you double-click for 
the queue manager.  Ignore the warning.  It will work.

The pdfconvert script, as you can see, will create a pdf file in its 
OUTDIR location, named with the date and time of creation.  Tailor to 
suit your needs.

HTH, YMMV, IANAL, MIPS, SCUBA, etc. etc. etc.

heh.
Cheers,
~Brian


-- 
----------------
Brian A. Henning
strutmasters.com
336.597.2397x238
----------------



More information about the TriLUG mailing list