[techtalk] Ghostscript

Almut Behrens almut_behrens at yahoo.com
Tue Jul 10 21:38:55 EST 2001


On Tue, Jul 10, 2001 at 12:50:29PM -0400, Stephanie Maks wrote:
> 
> Our printer is an HP with no postscript, just PCL5.  I've started
> experimenting with Ghostscript and have been very pleased with the success
> of being able to print from a Macintosh client onto the linux server, by
> manualy copying the .ps file and running ghostscript to convert it.
> 
> I've read in a few places (Printing HOWTO, etc) that you can set up a custom
> filter so that print jobs automaticaly go through ghostscript, but have not
> found any information on how to actually do that step.
> 
> I've got printcap configured with lp as the main printer using normal
> filters, and I'd like to set up an lp1 which would use a 'ghostscript'
> filter, but going to the same /dev.
> 
> Can anyone let me know how to do this, or point me to where I would find
> some documentation?

There are at least a dozen different printing system (CUPS,
magicfilter, etc.) and printing setup/installation tools (e.g.
printtool on RH) -- but before you've figured out which one to use,
you might just as well set it up manually, if your requirements
aren't too complex. Here's what you would need to do:

(1) add an entry to /etc/printcap

lp1|postscript|PostScript via ghostscript:\
        :lp=/dev/lp0:\
        :sd=/var/spool/lpd/lp1:\
        :if=/var/spool/lpd/lp1/ps2pcl:\
        :mx#0:\
        :sh:

You may need to change the device to the one you are using...
  lp : printer device
  sd : spool directory
  if : input filter (the script below)
  (see man printcap(5) for details and other available options)

(note: the printcap file format is a bit picky about whitespace
in the wrong place -- be especially careful not to have some
garbage after the "\"s)


(2) create the gs filter script /var/spool/lpd/lp1/ps2pcl

#!/bin/sh
gs -sDEVICE=ljet4 -q -dNOPAUSE -sOutputFile=- - 2>/dev/null

Substitute the device driver you need for your printer.
"gs -h" prints a list of options and available devices.
The essential thing is that the gs command works as a pipe,
i.e. reads from stdin and outputs to stdout -- that's what
the dashes in "-sOutputFile=- -" are for. The other options
are basically the ones you would use to print a postscript
file from the commandline.


(3) create the spool directory 

mkdir /var/spool/lpd/lp1
chown root.deamon /var/spool/lpd/lp1
chmod 775 /var/spool/lpd/lp1

(not 100% sure about the ownerships and permissions -- just make
it resemble the spool directory that's already working...)


(4) restart lpd

/etc/rc.d/init.d/lpd restart


Hope I haven't forgotten anything important. The details may need some
fine tuning. Simply report back if you don't get it working :)

- Almut





More information about the Techtalk mailing list