Skip to content

November 1, 2011

Samba Network TIFF Printing

by Jeff

For over a year now, we have been using a samba shared network printer to generate TIFF files from electronic documents so that they can be imported directly in to iPerms.  The TIFF printer is simply a script that takes PostScript input from the client machine’s print driver and converts it to an iPerms compatible TIFF image.  This is primarily useful for an Army installation, but may be relevant if your site is using some other form of document archiving system that uses TIFF images.  I can say that ours has spit out over 30,000 pages.

How it works:

Users setup the printer on their system using a PS print driver.  (On Vista, I usually use the HP Color Laserjet 2500 PS driver)  When they print a document to the printer, it generate a PDF, converts the PDF to a TIFF file and removes the interim PDF.  The completed file is dropped into a share with 0600 file permissions.  I use 0600 because I set the share to only display readable files.  Thus, while everyone is printing to the same folder, they only see their files when they open the share.  Less chance of PII leakage.


  • Active Directory integrated Samba server (Leave me a comment if you want me to write this up, it’s not hard, but not simple.)
  • Ghostscript and ps2pdf packages installed.

The parts:

  • Samba server
  • Printer definition in smb.conf
  • Script to process PS jobs
  • Share for distributing the generated TIFF images
  • A cron job to clean up old documents


First, you need to copy the script below to your samba server.  I suggest placing it in /usr/sbin and naming it tiffprint.

#convert to pdf then to tiff
#$1 = spool file $2 = UID

DTSTAMP=`date +%y%j_%H%M%S`


echo Converting $1 to $FILENAME2 for $2. >> $OUTPUTPATH/pdfcreate.log

/usr/bin/ps2pdf $1 $OUTPUTPATH/$FILENAME >> $OUTPUTPATH/pdfcreate.log 2>> $OUTPUTPATH/pdfcreate.log

echo Conversion finished, removing $1. >> $OUTPUTPATH/pdfcreate.log

rm $1

echo Converting to tiff format. >> $OUTPUTPATH/pdfcreate.log

/usr/bin/gs -q -dNOPAUSE -r300 -sDEVICE=tiffg4 -dBATCH -sPAPERSIZE=legal \

echo Removing intermediate pdf. >> $OUTPUTPATH/pdfcreate.log


echo Done, setting permissions. >> $OUTPUTPATH/pdfcreate.log

chmod 600 $OUTPUTPATH/$FILENAME2 >> $OUTPUTPATH/pdfcreate.log

echo All done. >> $OUTPUTPATH/pdfcreate.log
echo "=======================================">> $OUTPUTPATH/pdfcreate.log

Create a folder for your generated documents and log file.  Modify the $OUTPUTPATH variable to match.

Add a printer definition in your smb.conf:

comment = TIFF Generator
valid users = @XX+"Domain Users"
printing = sysv
path = /var/spool/samba
printable = yes
print command = /usr/sbin/tiffprint %s %U
lpq command = #
lprm command = #
lppause command = #
lpresume command = #
queuepause command = #
queueresume command = #
use client driver = yes

Create a share in your smb.conf for users to retrieve their documents:

comment = Printed TIFFs
valid users = @XX+"Domain Users"
path = /pdfwriter
hide unreadable = yes
public = no
writeable = no

Add a cron job to clean up the generated TIFF files every so often. I do it hourly for files over 24 hours old.

find /pdfwriter/ -name "*.tiff" -mtime +1 -exec rm -f '{}' \;

I use something similar to this document for the users to set themselves up to use this.

That should pretty much cover it.  This is my first attempt at a comprehensive “how to”, so please post any suggestions in the comments.  I’ll do my best to update the page as changes come in.

Read more from Linux, Projects

Leave a Reply