[Samba] PDF Print command

Charles Marcus CharlesM at Media-Brokers.com
Tue Mar 26 05:28:07 GMT 2002


I am very interested in setting up something like this for our network, and had a couple of questions:

> From: samba-admin at lists.samba.org 
> [mailto:samba-admin at lists.samba.org]On
> Behalf Of Martyn Ranyard
> 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.

I like this.  The first time I tried to set this up we had major problems with filenames of documents created in M$ - they all started with 'Microsoft Word blah blah'...

<snip>

> 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.

Couldn't you have just named it .MagicScript so no one could see it?  Or did you try that?

Also, you could have just placed a copy of the script in another location, and set the cron job to check for the existence of the script, and if it was gone, recopy it.  That way you still have the immediate functionality of the script - think I'll try that...

<snip>

> 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.)

Hmmmm... since I'm not a programmer, my ignorance is gonna be readily apparent here, but do you not delete the file once the PDF has been created?  These things would pile up rather quickly if not.

Also, what happens if one with the same name already exists?

Thanks!  This looks much better than the other method I was trying to use.

> #!/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





More information about the samba mailing list