[Samba] PDF Print command

Adam Ellis AdamE at AccelGrp.com
Tue Mar 26 05:26:12 GMT 2002


Martyn,

I tried running a server-level pdf printer and ran into some of the same
issues you have dealt with.  Ultimately I decided to stick with a
client-side implementation by installing Ghostscript and RedMon
(http://www.cs.wisc.edu/~ghost/redmon/) on the client system.  Has been
working great for me since.

AE

-----Original Message-----
From: Martyn Ranyard [mailto:ranyardm at lineone.net]
Sent: Tuesday, March 26, 2002 5:49 AM
To: Dirk Allaert
Cc: 'samba at lists.samba.org'
Subject: Re: [Samba] PDF Print command



I took a slightly different approach to Wouter...

1. I created a TOPDF share on the server.
2. I created a little script see end.
3. I inserted the script into the crontab, so it would check every minute 
to see if there were any new files to create as pdfs.
4. I used the Adobe Postscript Driver rather than the Apple Laserwriter, as 
I wanted colour, and wasn't sure of the Color Laserwriter's authenticity of 
postscript.

The user prints to "Generic Postscript Printer", which is set up as "Print 
to File", when asked for a filename, specifies the TOPDF share and a 
filename.  The crontab runs the script and creates a file with the filename 
of the original with the extension PDF.

Why : because I would prefer to let the user choose the name of the PDF as 
there is less chance of overwriting.  The email option also causes problems 
if you use the same filename and Eudora, as Eudora doesn't handle multiple 
files with the same name very gracefully (I am NOT starting a flamewar on 
email clients!)

Other bits : I tried to use a magic script to do the processing, but as the 
clients needed to create files in the ToPDF directory, the magic script got 
erased. Grrr.  Ideally there would be a generic plugin to execute a script 
every time a file is created or modified on the share, but this would (as I 
understand) be a VFS object and I myself would like to see it implementable 
on a filesystem basis, rather than a samba basis.  Anyone volunteering - I 
thought not.

So, there is an unavoidable delay with my system, but it works and gives 
more control to the user, so without any more delay, here's the script 
(remember to put it in crontab every minute - it checks if it has already 
processed the files before processing them again so it shouldn't be too 
processor intensive.)

#!/bin/bash
# script to process ps files and create pdfs
# written by martyn ranyard and donated under the GPL, available from 
www.gnu.org
for fname in `ls /mnt/raid/topdf/* | grep -iv "\.pdf" `; do  #list all 
files that don't contain .pdf
   if [ ! -f `echo $fname | sed -e 's/\..*/\.pdf/' ` ]; then  #if a pdf 
doesn't already exist...
     /usr/bin/ps2pdf $fname `echo $fname | sed -e 's/\..*/\.pdf/' 
`  #create one.
     chmod 777 `echo $fname | sed -e 's/\..*/\.pdf/' ` > /dev/null 2> 
/dev/null  #let anybody access them
   fi
done
#END of script

As I recall, the main line in the ps2pdf script is :
exec gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outfile 
$OPTIONS -c save pop -f $infile

so very similar to Wouter's command, but ps2pdf comes with most ghostscript 
distributions.

Martyn

At 11:23 AM 3/26/02 +0100, Dirk Allaert wrote:
>If you want to set up a pdf printer with samba, you can also read this 
>article:
>http://www.linuxgazette.com/issue72/bright.html
>
>Wouter Verhelst wrote:
>>Since everyone now starts asking me privately how I set up that PDF 
>>Printer, I suppose I'd better post that here instead of privately 
>>replying to everyone interested ;-)
>>Unfortunately, I don't have the exact script anymore. However, the 
>>procedure is fairly simple: All you need is Samba (obviously), GNU 
>>Ghostscript and a way to get the resulting PDF file to the user; I used 
>>the 'mime-construct' Perl program for that purpose, but there are other 
>>ways too, of course.
>>The required ghostscript call is as follows:
>>gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.ps
>>You can write a script that takes the path&filename of input.ps and the 
>>username as its input (see the '%s' and '%u' Samba substitutions to get 
>>these) and that gets the result to the user in some way. As said, I used 
>>mime-construct to send the PDF as a MIME-attachement to the user, but 
>>this has its drawbacks in that your mailserver administrator may not like 
>>someone printing a 30Meg .pdf; you may want to look into putting this in 
>>the users' homedirectory or something likewise.
>>Then, everything else you need to do is to set up a printer share with 
>>the parameter 'print command' set to the name of your script, and install 
>>a PostScript printer driver on the users' computer to print to your PDF 
>>service (Any postscript printer should do; I used an Apple Laserwriter 
>>which worked flawlessly).
>>Still, I'd like to know whether someone knows a way to achieve something 
>>similar for a disk share ;-)
>>Regards,
>>Wouter
>
>
>
>--
>To unsubscribe from this list go to the following URL and read the
>instructions:  http://lists.samba.org/mailman/listinfo/samba

--------------
Martyn Ranyard

I am not a member of the samba team,
and anything that I say may not be as
accurate as a response from one of the
team.  I reply to save those more
qualified time, which can more usefully
be spent developing SAMBA further.


-- 
To unsubscribe from this list go to the following URL and read the
instructions:  http://lists.samba.org/mailman/listinfo/samba




More information about the samba mailing list