[Samba] HOWTO Create a PDF Writer in samba

Martyn Ranyard ranyardm at lineone.net
Mon Jul 29 10:33:29 GMT 2002

Hi all,

   Thought I'd post this to the list as I found a better way of doing 
it.  Nice to have for posterity.
   Please include it in the source of samba if you wish - I hereby license 
it under GPL

1. install ghostscript (most distributions include it anyway)
2. put the following in the file /usr/sbin/pdfprint and make it executable 
by whatever your guest user for samba is :

#convert to pdf $1 = spool file $2 = uid $3 = gid $4 = machinename $5 = ip
FILENAME=pdf-$2-`date +%d%m%H%M%S`.pdf
echo converting $1 to $FILENAME for $2 of machine $4... >> 
/usr/bin/ps2pdf $1 $OUTPUTPATH/$FILENAME >> $OUTPUTPATH/pdfcreate.log 2>> 
echo conversion finished, removing $1 >> $OUTPUTPATH/pdfcreate.log
rm $1
echo done, setting permissions and notifing user >> $OUTPUTPATH/pdfcreate.log
chown $2:$3 /mnt/raid/topdf/$FILENAME >> $OUTPUTPATH/pdfcreate.log
chmod 700 /mnt/raid/topdf/$FILENAME >> $OUTPUTPATH/pdfcreate.log
echo your new PDF is called $FILENAME. | smbclient -M $4 -I $5
echo All done. >> $OUTPUTPATH/pdfcreate.log
echo >> $OUTPUTPATH/pdfcreate.log

of course the permissions and file format can be altered depending on your 
system, but make sure that as these files are created by the guest user, 
that the directories referenced (spool dir and OUTPUTPATH) are writable by 
nobody (or whatever your guest user is).

3. edit your smb.conf file and add something like the following :

         path = /var/spool/samba
         guest ok = yes
         browseable = yes
         printable = yes
         read only = no
         force group = root
         force user = root
         force create mode = 0777
         print command = /usr/sbin/pdfprint %s %U %G %m %I

Yet again, the permissions I have arrived at via trial-and-error and are 
more than a little insecure :)

4. restart samba

root at linuxsambaserver:~# killall -HUP smbd ; killall -HUP nmbd

NB this apparently is not the way to do it on anything other than Linux!

5. Assign a postscript printer to the pdfwriter printer - Apple Color 
LaserWriter 12/600 works well for me on NT4, but Adobe do a free (small F) 
printer driver, which also works well.

6. Print.  You should get a message (NT/2K/XP/9x with winpopup) informing 
you of the name of your file.

Hope this helps someone.

Martyn Ranyard
Free Software Advocate

jabber - joran at amessage.de
icq    - 122500800
irc    - Joran on oftc
msn    - ranyardm at hotmail.com
e      - ranyardm at lineone.net

More information about the samba mailing list