Everyone
knows that PDF creation under linux is handled, for free, by a utility
called
GhostScript. Creating
PDFs under Windows requires either the costly Adobe Acrobat program, or
someother PDF creation software. Since I wasn't real keen on the idea of
buying a license for Acrobat for every person in my organization that
needed to make PDF files, I set about the task of searching for a way to
utilize ghostscript from Windows. One of the links I found was an
article on
Linux Gazette
written by
John Bright,
detailing how to set up a PDF Service with Samba. Unfortunately for me,
the article wasn't written with Windows 2000 in mind, so I had to do
things a little differently from the article. Regardless, tthe article
is top notch and perfect if you're client PCs are Windows 9x, or
NT.
Environment
Windows 2000 SP1 client PCs
RedHat 7.0 server (up to date with current patches)
Samba 2.2.0
Basis
Everyting I did was based on an article on
Linux Gazette written by
John Bright. The article
should be able to be found
here.
Assumptions
Samba is configured properly, all the Windows PCs have
access to the Samba shares and a working ghostscript is installed on the
linux server.
Details
After reading the article, I set to the task of configuring
Samba. Creating the printer share in my smb.conf file was easy, as was
creating the script that did all the work. You'll need a directory on
the samba server that will be used for the output and will be
accessible by everyone. Assuming the directory will be called
/shr/pdfdropbox, just
# mkdir /shr/pdfdropbox
# chown nobody
/shr/pdfdropbox
# chmod u+rwx /shr/pdfdropbox
For the lazy who haven't read the
very vine
article, here's what the script looks like:
#!/bin/bash
#Convert postscript file into a PDF
document
# (c) John Bright, 2001,
jbright@winfordeng.com
DATE=`date +%b%d-%H%M%S`
OUTDIR=/shr/pdfdropbox
/usr/bin/ps2pdf $1 $OUTDIR/$DATE.temp
mv $OUTDIR/$DATE.temp $OUTDIR/$DATE.pdf
rm $1
Of course, you can use whatever directory you want instead of
/shr/pdfdropbox.
I set up my system so that Windows will autmagically load the correct
driver for the printer when adding the printer.
The article
details how to do this wonderfully, for Win 9x and NT. For Windows 2000,
it's a little more difficult to find the right driver. In fact, the
original PostScript driver I chose, an HP LaserJet 2200 Series PS,
directly from the printer's driver CD, was bad, so I had to find
another. The other problem was finding the right .INF file to utilize
the
make_printerdef utility in
samba. I ended up using the driver for an "HP LaserJet 2100 Series PS"
printer, which came with Windows. The
make_printerdef is
a lovely tool, and does its job well. Please read the article, there's
wonderful instructions on how to use it. Unfortunately, since I could
never find the correct .INF file to set things up correctly, I had to
abandon the tool. I did use it enough to find out what it does, though.
So I managed to replicate its job manually.
You'll need a file called
/etc/samba/printers.def,
which specifies the printer names and the driver files associated with
each printer. I had first used a driver for a standard laser printer,
then decided to add a color laser, just to see if I make color PDFs (I
can). My printers.def file contains the following:
HP LaserJet 2100 Series PS:HP2100_7.PPD:hp2100_7.ppd:::RAW:hp2100_7.ppd
HP Color LaserJet 8500 PS:HP_CLJ85.PPD:hp_clj85.ppd:::RAW:hp_clj85.ppd
You'll also need a
/etc/samba/printdrivers
directory containg the correct drivers, mine contains:
hp2100_7.ppd
hp_clj85.ppd
I found both drivers under
C:\WINNT\system32\spool\drivers\w32x86\3, YMMV.
The
Nitty Gritty
Here are the relevant sections of my smb.conf file, pertaining to the
PDF Service. Modify to suit your needs:
[pdfoutput]
path = /shr/pdfdropbox
force user = nobody
read only = No
guest ok = Yes
[pdf]
path = /tmp
guest ok = Yes
printable = Yes
print command =
/usr/bin/printpdf %s
lpq command =
lprm command =
printer driver = "HP
LaserJet 2100 Series PS"
printer driver location =
\\%h\printer$
[ColorPDF]
path=/tmp
guest ok = Yes
printable = Yes
print command =
/usr/bin/printpdf %s
lpq command =
lprm command =
printer driver = "HP Color
LaserJet 8500 PS"
printer driver location =
\\%h\printer$
[printer$]
path =
/etc/samba/printdrivers
guest ok = Yes
Once configured, all you need to do to enable printing PDF files on the
Windows clients is add the shared PDF printer as a network printer
using the Windows Add Printer dialog. Easy.