*BSD News Article 79243


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!solace!news.stealth.net!www.nntp.primenet.com!nntp.primenet.com!arclight.uoregon.edu!dispatch.news.demon.net!demon!slugvine.demon.co.uk!jas
From: jas@slugvine.demon.co.uk (John Stark)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Print Filter
Date: Wed, 25 Sep 1996 21:54:13 GMT
Organization: Home
Lines: 61
Message-ID: <DyB66D.KF@slugvine.demon.co.uk>
References: <32489D82.2D81@gbtech.net>
X-NNTP-Posting-Host: slugvine.demon.co.uk

In article <32489D82.2D81@gbtech.net>, Donny Clark  <clark@gbtech.net> wrote:
>Does anyone know where I can locate a print filter for a Hewlett Packard
>Deskjet 682C printer?

Instructions are included in the FreeBSD handbook, but basically you install
the GhostScript package, which produces PCL from PostScript and use a script
to decide whether it's needed or not.  Versions 2.6.2 and 3.something are
on the CD-ROM but I downloaded version 4.01 from the FreeBSD ftp site.
This works with Netscape and other programs that produce PostScript.  For
other types of output you need a different filter.

Install the following script in /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

Include something like the following in /etc/printcap:

  # HP DeskJet 660C with GhostScript filter
  lp|HP DeskJet 660C:\
          :lp=/dev/lpt0:sd=/var/spool/lpd:lf=/var/log/lpd-errs:\
          :sh:mx=0:pw=80:if=/usr/local/libexec/hpif:

Test it by printing one of the example files that comes with GhostScript and
a plain ASCII text file.  Both should produce good output.

  lpr /usr/local/share/ghostscript/4.01/examples/tiger.ps
  lpr ~/.cshrc
-- 
John Stark (at home), Cambridge, UK   |   mailto:jas@slugvine.demon.co.uk
Tel. Cambridge (01223) 573555         |   http://www.slugvine.demon.co.uk