*BSD News Article 96104


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!metro!metro!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!disgorge.news.demon.net!demon!dispatch.news.demon.net!demon!slugvine.demon.co.uk!slugvine.demon.co.uk!jas
From: jas@slugvine.demon.co.uk (John Stark)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: HELP: Printing PS files on non_ps printer
Date: Fri, 23 May 1997 23:38:53 GMT
Organization: Home
Message-ID: <EAnr0t.I8@slugvine.demon.co.uk>
References: <338456BC.502E@foto.infi.net>
NNTP-Posting-Host: slugvine.demon.co.uk
X-NNTP-Posting-Host: slugvine.demon.co.uk [158.152.194.59]
Lines: 46
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:41562

In article <338456BC.502E@foto.infi.net>,
Tom Misiak  <misiak@foto.infi.net> wrote:
>	I have a HP540 deskjet printer (none ps) and was
>wondering how I could set up my printcap file to allow me
>to print ps files with it.  I'm not very literate with FreeBSD.
>Any help would be greatly appreciated...

You need to:
1. Install GhostScript (package ghostscript-4.03)
2. Install a filter script that detects whether a print job is PostScript
   and uses GhostScript if it is, but not if it isn't
3. Set up /etc/printcap to use this script
Refer to the following examples:

/etc/printcap
-------------
lp|hp|Deskjet 660C:\
	:lp=/dev/lpt0:sd=/var/spool/lpd:if=/usr/local/libexec/hpif:\
	:lf=/var/log/lpd-errs:sh:

/usr/local/libexec/hpif
-----------------------
#!/bin/sh
#  ifhp - Print Ghostscript-simulated PostScript on a DesJet 500
#  Installed in /usr/local/libexec/hpif

#  Treat LF as CR+LF:
printf "\033&k2G" || exit 2

#  Read first two characters of the file
read first_line
first_two_chars=`expr "$first_line" : '\(..\)'`

if [ "$first_two_chars" = "%!" ]; then
    #  It's PostScript; use Ghostscript to scan-convert and print it
    /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=cdj550 -sOutputFile=- - \
        && exit 0
else
    #  Plain text or HP/PCL, so just print it directly; print a form
    #  at the end to eject the last page.
    echo $first_line && cat && printf "\f" && exit 2
fi
exit 2
-- 
John Stark (at home), Cambridge, UK   |   mailto:jas@slugvine.demon.co.uk
Tel. Cambridge (01223) 573555         |   http://www.slugvine.demon.co.uk