[TriLUG] HOWTO: Create PDFs using Samba but not CUPS
srhoffman at gmail.com
Mon Feb 27 10:17:47 EST 2006
Here's the relevant line from samba: print command = /usr/bin/printpdf %s
Then in my printpdf I have a section like this:
msgBody="Your PDF, blah blah"
echo $msgBody | mutt -s "PDF Generated!" -a $OUTDIR/$filename
So the %U in the smb.conf file takes the logon credentials the user logged
on to their workstation with and passes to shares when it attempts to
connect. I take that an append our domain to it to create an email address.
I didn't copy the entire script as it's grown substantially with ldap calls
etc to verify that the user exists (we have guests come onsite that print to
it as user "owner" or "dell user" etc and that was hosing things). There's
also logic in there to take files over 10MB and dump them to the users
personal folder share preventing others from getting access then does
On 2/27/06, David McDowell <turnpike420 at gmail.com> wrote:
> I got this working, but I think I may need to take it a step further.
> First, here's all my settings (the line items of importance anyway).
> workgroup = DOMAIN
> server string = HOST1
> hosts allow = 192.168.0. 127.
> printing = lprng
> guest account = nobody
> security = share
> path = /pdfdropbox
> browseable = yes
> writeable = yes
> guest ok = yes
> force user = nobody
> ; Set up our PDF-creation print service
> path = /tmp
> postscript = yes
> printable = yes
> guest ok = yes
> print command = /usr/bin/printpdf %s
> writable = yes
> public = yes
> ; There is no need to support listing or removing print jobs,
> ; since the server begins to process them as soon as they arrive.
> ; So, we set the lpq (list queued jobs) and lprm (remove jobs in queue)
> ; commands to be empty.
> lpq command =
> lprm command =
> My /use/bin/printpdf:
> # 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
> # 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)
> ps2pdf $1 $OUTDIR/$DATE.temp
> mv $OUTDIR/$DATE.temp $OUTDIR/$DATE.pdf
> rm $1
> OK. So, here's my dilema. We have about 20-30 employees who may
> possibly use this feature on a semi/very regular basis. If SMB has
> the printer as public and is using the nobody user for the output
> ownership, are there any suggestions to how I can get my W2K3 AD
> usernames collected by SMB and have them become part of the name in
> the output PDF file as well? Currently I get a file called
> "Feb27-084822.pdf" for example. It would be nice if it was called
> "<username>_Feb27-084822.pdf" instead.
> I know it "could/should" be possible for me to link this SMB up with
> auth to my AD. I have version: samba-3.0.10-1.4E.2 on CentOS 4.2. But
> even then, IF I could get that working, where to go from there to get
> that AD username to the bash script for output into the filename??
> Inevitably users will leave prints behind just like they do on paper
> printers. I have that covered by forcing username coversheets. Here,
> I need the username to act as a coversheet of sorts. Also, I just
> don't give my users credit enough to not complain that they can't tell
> which is there print vs. somebody else's. *cry*
> David McD
> On 9/26/05, Brian Henning <brian at strutmasters.com> wrote:
> > 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
> > -- begin script quote --
> > #!/bin/sh
> > # Simple script to convert a specified postscript file into a PDF
> > # 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
> > ----------------
> > --
> > TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> > TriLUG Organizational FAQ : http://trilug.org/faq/
> > TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
More information about the TriLUG