[Samba] PDF printer using ps2pdf ?

Thomas Bork tombork at web.de
Wed Oct 30 20:19:01 GMT 2002

Hallo Tim Allen,

you wrote:

>> Is it possible to set up a printer in samba
>> that will use ps2pdf converter to create pdf documents when printing
>> on it ? Best Regards
>> Steph
> Yes. Take a look at Sambafax:
> http://wwwhomes.uni-bielefeld.de/ingalo/software/sambafax.html
> for the general idea. Obviously it's for a slightly different purpose
> but could easily be adapted.
> A slight problem with such schemes is deciding what to call the PDF
> file and where to put it. A dedicated directory off of your home is
> one possibility. Or you could email the PDF back to yourself.
> But what you might really want is Redmon:
> http://www.cs.wisc.edu/~ghost/redmon/
> which allows you to set up Ghostscript on your local machine as a PS
> or PDF writer. Last time I tried it, it had a minor bug in that it
> would only write the PDF file to a local drive, not a network drive.

and another one:

# /usr/local/bin/samba-print-pdf - print to a pdf-file
# Creation:     23.07.2002  Buchan Milne
# Last Update:  21.10.2002  tb
# Arguments:
# $1 = file (usually passed with %s from samba)
# $2 = unix prefix to where to place the file (~%u should work)
# $3 = windows prefix to the same location (\\%L\%u should work)
# $4 = user/computer to send a notification to (%u or %m)
# $5 = IP address of client (%I)
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

INFILE=$(basename $INPUT)

#make a temp file to use for the output of the PDF
> $2/$BASEFILE-$4-$$

if [ $? -ne 0 ]
    # Generate a failure message to send to the user:
     MESSAGE=$(echo "Can't create temp file $2/$BASEFILE-$4-$$,
    WIN_OUTPUT="$3\\`basename $OUTPUT`"

    # create the PDF:
    $PS2PDF $OPTIONS $INPUT $OUTPUT.pdf >/dev/null 2>&1

    # Generate a message to send to the user, and deal with the
original file:
    MESSAGE=$(echo "Your pdf-file has been created as $WIN_OUTPUT.pdf")

    if [ "$KEEP_PS" = "1" ]
        mv $INPUT $OUTPUT.ps
        MESSAGE=$(echo "$MESSAGE and your postscript file as
        rm -f $INPUT

    chmod $PERMS $OUTPUT.ps $OUTPUT.pdf

    #Remove empty file from mktemp:
    rm -f $OUTPUT

# Send notification to user
echo $MESSAGE|smbclient -U "eisfair pdf-service" -M "$4" -I "$5" 1>

In smb.conf:

   comment = pdf-service on %h
   browseable = yes
   printable = yes
   path = /tmp
   print command = ( /usr/local/bin/samba-print-pdf %s ~%u \\\\%L\\%u
%m %I ) &
   public = yes
   create mode = 0700


More information about the samba mailing list