Filtering ^D and PCL headers in samba print jobs under Solaris

Michael James michael.james at
Wed Jun 30 09:17:32 GMT 1999

This is my way of filtering ^D and PCL headers
 out of samba jobs on a solaris 7 system.

It assumes that all your printers are capable of postscript,
 and that you are using PS drivers on any printers are not PCL capable.

1) Add a declaration of pcl capability to the relevant printers:

lpadmin -p hp8000 -I 'simple,postscript,pcl'

Choose which printers you do this to carefully,
 Using the Apple Printer Utility you can turn on pcl
 when talking LPD to modern Apple Laserwriters,
 but if thou speakest appletalk, even to an HP
 thou mayst speak only pure postscript!

2) Have samba declare that all its jobs are type pcl.
Add "-T pcl t the samba print command.
This changes it to:

lp -c -d %p -T pcl %s; rm %s

3) Add a filter to solaris so pcl jobs
 can still print on postscript printers:

cat <<EOF > /etc/lp/fd/pcl2ps.fd

# cat pcl2ps.fd 
# pcl2ps.fd filter description
# Converts samba jobs to clean postscript
#  ( if the printer can't handle PCL )
# michael.james at 21/6/99

Input types: pcl
Output types: postscript
Printer types: any
Printers: any
Filter type: fast
Command: /opt/samba/bin/pcl2ps


lpfilter -f pcs2ps -F /etc/lp/fd/pcl2ps.fd

And that's it.

The /opt/samba/bin/pcl2ps script is a bit of perl
 that scans the first 10 lines looking for a postscript header.
If it finds one it strips anything in front of it including ^D
 and anything after %%EOF
If it can't find postscript headers it prints (in postscript)
 "Your job couldn't be printed on this printer"

This way postscript printers only see clean postscript
 and pcl printers get the job unfiltered.

My draconian filter is OK because it only touches samba jobs.
Local unix text jobs are going through a different filter path.
For example if you like pretty borders on your unix printouts
 set up the system's simple to postscript filter to your taste
 and remove type simple from your printer definition.

vi /etc/lp/printers/hp8000/configuration

If you are interested I'll mail you
 the 2 screens of perl that constitute pcl2ps.


PS: If anyone else is interested
 pcl2ps would be improved
 by a more informative error message
 giving user source and jobname...

Michael James       _/      _/      _/ _/     _/  v +61 2 6279 8318
Network Programmer _/_/     _/_/    _/ _/     _/
Coombs Computing  _/  _/    _/ _/   _/ _/     _/  f +61 2 6257 1893
 Australian      _/    _/   _/   _/ _/ _/     _/
  National      _/_/_/_/_/  _/    _/_/ _/     _/    michael.james
   University  _/        _/ _/      _/  _/_/_/_/

More information about the samba mailing list