[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: PCL only printer



On Thu, Feb 19, 2004 at 02:20:28PM -0800, Paul Yeatman wrote:
> Hi, I recently inherited an HP Deskjet 932C printer.  Apparently this
> only uses the PCL printer language.  As I need to be able to print
> postscript for this to be of much use to me, I've been struggling to
> make this happen.

I love my 932C.  Works great.  Cartridges are a little expensive, like all
HP inkjets, but it prints well.

<much ado about ifhp deleted>

Well, ifhp is smart enough to use ghostscript in order to get from
PostScript to PCL when it has to, but I don't think it can do what you want
directly.  It has to be aware that it should be producing the color
superset of PCL 3 that the 932C speaks, and I'm not sure it can.  I beat on
it for a while, then gave up and wrote a shell script to support the 932C.
I reproduce it below.

*****
/etc/printcap:
*****

# /etc/printcap
#   for rei

# the simplest solutions are the best... no apsfilter, no magicfilter,
# just ifhp and one, count 'em, ONE shell script for talking to the
# deskjets.

# whyinhell do people mess with all the other crap?

lp|laser|pro630|LaserWriter:
    :ifhp=model=apple,letter,status@
    :filter=/usr/lib/ifhp/ifhp
    :lp=jetdirect2%9100
    :mx#0
    :sh
    :rg=printers

dj932c|DeskJet_932C_Color:
    :lp=/dev/usb/lp0
    :if=/usr/local/bin/deskjetfilter 932
    :mx#0
    :sh
    :rg=printers

dj1120c|DeskJet_1120C_Color:
    :lp=jetdirect1%9100
    :if=/usr/local/bin/deskjetfilter 1120
    :mx#0
    :sh
    :rg=printers

# below here are special-purpose printers

pdf|pdfwriter|PDF_Writer
    :lp=/dev/null
    :if=/usr/local/bin/pdffilter
    :mx#0
    :sh
    :rg=printers

# end of /etc/printcap

# $Id: printcap,v 1.8 2004/02/24 06:34:18 root Exp root $

*****
/usr/local/bin/deskjetfilter
*****

#!/bin/bash
# deskjetfilter - take in postscript, output PCL via GhostScript/HPIJS

# Marc Wilson (msw@cox.net)

# uncomment the following line to enable entirely too much output...
#DEBUG=yes

GS='/usr/bin/gs'
HPIJS='/usr/bin/hpijs'
# I'd like to run them both at 600 dpi, but the 1120C weirds out
# so set it for the 932C specifically down below...
# GSOPTS='-q -dNOPAUSE -dSAFER -sBATCH -r600x600'
GSOPTS='-q -dNOPAUSE -dSAFER -sBATCH'
IJSOPTS1='-sDEVICE=ijs -sIjsServer=hpijs -dIjsUseOutputFD -sDeviceManufacturer="HEWLETT-PACKARD"'
IJSOPTS2='-sDeviceModel="DESKJET 1120"'
LOGGER='/usr/bin/logger'
ENSCRIPT='/usr/bin/enscript'
ENSCRIPTOPTS='-Bh -M letter -p -'
FACILITY="lpr.debug"

TEMPORARY=`mktemp /tmp/deskjet_XXXXXXXX`

if [ ! -x "$GS" ] || [ ! -x "$HPIJS" ]; then exit 1 ; fi

case "$1" in
    932)
        if [ "$DEBUG" ]; then $LOGGER -p $FACILITY "deskjetfilter: Specified printer is 932C" ; fi
        # 932C is a PITA, you get crap unless you push it into Photo mode
        IJSOPTS2='-sDeviceModel="DESKJET 932" -sIjsParams="Quality:Quality=2,Quality:ColorMode=2,Quality:MediaType=2"'
        PAPER="-sPAPERSIZE=letter"
        GSOPTS="$GSOPTS -r600x600"
        ;;
    1120)
	    if [ "$DEBUG" ]; then $LOGGER -p $FACILITY "deskjetfilter: Specified printer is 1120C" ; fi
        # 1120C seems to do quite well  at a lower quality setting
        IJSOPTS2='-sDeviceModel="DESKJET 1120"'
        # 1120C can do letter, but that's what the 932C is here for, after all
        PAPER="-sPAPERSIZE=11x17"
        ;;
    *)
	    if [ "$DEBUG" ]; then $LOGGER -p $FACILITY "deskjetfilter: Printer type was not specified" ; fi
        exit 1
        ;;
esac

# save the input stream

cat > $TEMPORARY

# let's make sure of what this job is BEFORE we try to print it, shall we?

if (file $TEMPORARY | grep PostScript >/dev/null 2>&1); then

	# ok, it's PS, use ghostscript to print it

    if [ "$DEBUG" ]; then 
    	$LOGGER -p $FACILITY "deskjetfilter: Input stream is PostScript"
	    $LOGGER -p $FACILITY "deskjetfilter: $GS $IJSOPTS1 $IJSOPTS2 $GSOPTS $PAPER -sOutputFile=- $TEMPORARY"
    fi

    # stupid quoting behavior of bash seems to require using eval...

	eval "$GS $IJSOPTS1 $IJSOPTS2 $GSOPTS $PAPER -sOutputFile=- $TEMPORARY"
    rm $TEMPORARY

elif (file $TEMPORARY | grep text >/dev/null 2>&1); then

    # not PS, file(1) thinks it's text so go with that
	# this should probably go through GS/HPIJS as well...

    if [ "$DEBUG" ]; then 
	    $LOGGER -p $FACILITY "deskjetfilter: Input stream is ASCII text"
    fi

    $ENSCRIPT $ENSCRIPTOPTS $TEMPORARY
    rm $TEMPORARY

else

	# it's not PostScript, and it's not text, so fail out

    if [ "$DEBUG" ]; then $LOGGER -p $FACILITY deskjetfilter: ERROR: Unrecognizable input to filter ; fi
    rm $TEMPORARY
	exit 1

fi

Yes, it's a hack.  I'm certainly no great shakes at shell scripting... in
my defense, all I can say is that it works.  This is more or less set up to
print pictures... letter size for my 932C and tabloid size for my 1120C.  I
don't print text with them... that's what real PostScript laser printers
are for.

> According to 'man gs', I should be able to run something like 'gs
> -sDEVICE=hpijs file.ps' to have file.ps print directly to the printer for
> which "hpijs" is a driver.

Forget it.  The ghostscript documentation doesn't match the way hpijs works
now.  Let me qualify that by saying that I'm specifically talking about gs
7.07 and hpijs 1.5 from unstable.  The hpijs web site is your friend.

-- 
 Marc Wilson |     Pascal: A programming language named after a man who
 msw@cox.net |     would turn over in his grave if he knew about it.
             |     -- Datamation, January 15, 1984



Reply to: