From: larsen@OES.ORST.EDU (Scott Larsen)
Newsgroups: comp.sys.hp
Subject: Re: Printing PCL Files and awesome ljet3si interface script
Summary: grow your own!
Date: 11 Nov 92 15:33:09 GMT
Article-I.D.: news.BxK5vG.7xx
Organization: Oregon Extension Service, Oregon State University, Corvallis, Or.

In article <7SS8MBG@math.fu-berlin.de> chatzi@metw3.met.fu-berlin.de (Andreas Chatziantoniou) writes:
>I need some informations how to print PCL-files on a HP LaserJet 3 si which is
>connected to an HP 9000/835 with HP-UX 8.0 .
>The printer is installed with the PCL4 modelfile. I tried to print the file
>using the raw Option ( lp -dlaser3si -oraw filename.pcl) which produced one
>page with 1/2 inch of the picture I want to print and a lot of blank pages
>afterwards. The PCL-file was produced from a PostScript Picture which was
>converted to HP-PCL using GhostScript.
>It is possible to print the PostScript picture on this printer but it takes 
>about 20 minutes. As these pictures (satelite pictures) should be available 
>as soon as possible, 20 minutes are just to long. If I print this PCL-picture 
>from a PC it works just fine and takes about 1 1/2 minutes. 
>
>Any hint would be appreciated.
>Thank you in advance.
>Andreas

Well, I looked over _ALL_ the HP supplied model files and decided that all
of them sucked. :)  Seriously, none could do what we wanted in relation to
PCL graphics, HPGL2 graphics, postscript, duplex printing, and job seperation,
so I wrote one myself for our Laserjet III si.

Please note that this interface model will handle si's with the Postscript
ROMs, switching it from PCL to Postscript and back as needed.  Also, it takes
advantage of the duplex printing hardware, if installed.

We also have a script referenced by the variable $mdchpglpenfix, which 
makes HPGL lines thinner and more readable when plotting large drawings
to a small paper size (8.5x11).

Send along vie email or News any questions, comments, or desires to see any 
of the other interfaces we've developed (we have quite a few PCL/Postscript 
printers that we have configured in a similar fashion).


Scott Larsen
larsen@oes.orst.edu                      UUCP: hplabs!hp-pcd!orstcs!larsen
--------------------------------------------------------------------------
"I assumed you needed help.  I see I am in error."
		- Spock




#! /bin/sh
#
# lp interface for HP LaserJet III SI Postscript/HPGL2/PCL5 printer
#
# Version:	2.0
# Modified:	92/06/16 -- slarsen
#
#
# The postscript and HPGL2 plot file detection method uses the "file" 
# command, and relies heavily on a modifed /etc/magic file.  These lines
# must be present in the /etc/magic file for this script to work properly:
#
#	0	string	%!PS-Adobe-	postscript file
#	0	string	%!		postscript file
#	0	string	E&l3O%-1B	MDC LJIII HPGL2 file
#
#
# This script also uses a HPGL pen fix filter to patch up MDC HPGL plots.
# This is defined as variable $mdchpglpenfix below...
#
#                  ************  NOTE  **********
#                  ************  NOTE  **********
#
# We are assuming that all non-postscript or non-HPGL print jobs
# need a line termination setting (old -ocrlf option).  We hope this
# assumption doesn't fail with WordPerfect and 123.  They should send
# reset commands, so we should be ok.


#=======================================================================#
# OPTIONS RECOGNIZED: ( all may be preceded by a "-" )			#
#    ( Starred (*) items are defaults )                                 #
#                                                                       #
#        pcl                    force PCL mode on.  All data coming in  #
#                               is taken as PCL data                    #
#        duplex                 print 2 sides per page                  #
#-----------------------------------------------------------------------#
#                                                                       #
#           These options apply only when using duplex printing         #
#                                                                       #
#                                                                       #
#        shortbind              short edge binding.  (clipboard binding)#
#                               also landscape quick reference guides.  #
#      * longbind               long edge binding.  (book binding)      #
#=======================================================================#


log=/usr/spool/lp/log
mdchpglpenfix=/usr/local/lib/printers/filters/mdc_hpgl_pwfix

echo "$*" >>$log
echo "\tstart: `date`" >>$log
exec 2>>$log        		# catch errors, since printer won't print them

# Save all arguements...
printer=`basename $0`
reqid=$1
user=$2
title=$3
copies=$4

# Set up interface

if [ -t 1 ]
then
    stty raw 9600 -parenb cs8 ixon -istrip clocal <&1 2>/dev/null
else
    slp -r 2>/dev/null
fi


# Handle disable and cancel traps.

trap "echo 'Terminated: $reqid' >> $log; trap 15; kill -15 0; exit 0" 15


# Initialize the option variables...

pcl="no"
duplex="no"
pcltumble="1"
postscripttumble="false"


# Find out what options were used 

for i in $5
do
    case "$i" in
	-pcl|pcl)			# Force PCL mode
            pcl="yes";;
	-duplex|duplex)			# Print two sides
	    duplex="yes";;
	-shortbind|shortbind)		# Bind on short edge
	    pcltumble="2"
	    postscripttumble="true";;
	-longbind|longbind)		# Bind on long edge
	    pcltumble="1"
	    postscripttumble="false";;
    esac
done


# The remaining arguments are files

shift;shift;shift;shift;shift
files="$*"


# Print the spooled files

i=1
while [ $i -le $copies ]
do
    for file in $files
    do
	ftype=`/usr/bin/file $file`
	echo $ftype | grep postscript > /dev/null
	ft=$?
	if [ $ft = 0 -a "$pcl" = "no" ]	# It's a postscript file
	then
						# Tell printer to switch from
						# PCL5 to postscript
	    echo "\tprinting postscript file" >>$log
	    echo "\033%-12345X@PJL ENTER LANGUAGE = POSTSCRIPT"

	    if [ $duplex = "yes" ]		# Print both sides
	    then
		echo "statusdict begin true setduplexmode end"
		echo "statusdict begin $postscripttumble settumble end"
	    fi

	    cat "$file"				# send the file to the printer
	    echo "\004\c"	 		# send Postscript EOJ

						# Tell printer to switch back
						# into LJIII mode.
	    echo "\033%-12345X@PJL ENTER LANGUAGE = PCL"

	else					# It's a LJIII file

						# Force PCL5 mode ON and
						# toggle job offset
	    echo "\033%-12345X@PJL ENTER LANGUAGE = PCL"
	    echo "\033&l1T\c"

	    if [ $duplex = "yes" ]		# Print both sides
	    then
		echo "\033&l$pcltumble\c"	# set up the binding edge
		echo "S\c"			# UGLY!
	    fi

	    echo $ftype | grep 'MDC LJIII HPGL2 file' > /dev/null
	    ft2=$?
	    if [ $ft2 = 0 -a "$pcl" = "no" ]	# It's a MDC HPGL file
	    then
		echo "\tprinting mdc plot file" >>$log
						# adjust the pen widths
		cat "$file" | $mdchpglpenfix
	    else
		echo "\tprinting regular file" >>$log
		echo "\033&k2G\c"		# map LF -> CRLF
		cat "$file"			# Just send the file...
	    fi
	fi

	echo "\033E\c"				# PCL Reset.  This has the
						# added bonus of flushing jobs
						# that do not have a form feed.

    done
    i=`expr $i + 1`
done

echo "\tdone:  `date`" >>$log

# Insure all buffers are flushed to printer
if [ -t 1 ]
then
    stty raw 9600 -parenb cs8 ixon -istrip clocal <&1 2>/dev/null
fi

exit 0
Newsgroups: comp.sys.hp,comp.unix.admin