Code:
#!/usr/bin/sh
# $Source: /hpux/shared/supp/usr/src/cmd/lp/model/PCL5,v $
# @(#) $Header: PCL5,v 76.2.1.4 98/04/27 19:20:27 ssa Exp $
# Printer Command Language level V model, including support for
# language switching.
#
# This model has been modified to be used as a filter to provide
# LaserJet options to a remote printer. Output will be sent to lp unless
# fonts were downloaded and the remote queue converts LF to CR/LF.
#
# Usage: pcl5lp [options] [files]
reverse="" # Use this line if page reversing IS NOT desired
#reverse="yes" # Use this line if page reversing IS desired
# The defualt language for this model file is PCL. If you desire to
# set the default to PostScript insert a '#' before the first line
# below and remove the leading '#' from the second line.
default_mode="PCL"
#default_mode="PostScript"
list_options()
{
echo "\033E\c"
case "$pagemode" in
def);;
ubin) echo "\033&l1H\c";;
lbin) echo "\033&l4H\c";;
esac
echo "\033&k2G\033(s3B\c"
echo "\033(s14H\c"
echo "\t\t\033&d0DAvailable Options for Model Script\n"
echo "\033&d@SYNOPSIS:\033(s0B\c"
echo "\t$(basename $0) -o<option> -o<option> ... <print file name>\n"
echo "\033(s3BDESCRIPTION:\033(s0B"
echo "\033&l7.6C\033(s14.3H\c"
#============================================================================
echo "*******************************************************************************************************************"
echo " \033(s3BOPTIONS RECOGNIZED: ( all may be preceded by a "-" )\033(s0B "
echo "*******************************************************************************************************************"
echo "* \033(s3BHorizontal/Vertical Pitch Selection:\033(s0B * \033(s3BOutput filtering:\033(s0B (Default Cooked) *"
echo "* 10 10 characters/inch (cpi) * r | raw raw mode for plotting mode etc. *"
echo "* 12 12 cpi * n | nroff set up to properly print output from nroff *"
echo "* c compressed print pitch * pr set up to properly print output from pr *"
echo "* e expanded print pitch * rev output pages in reverse order *"
echo "* fp# set primary font pitch to # cpi * a | ascii print PostScript file as text *"
echo "* sfp# set secondary font pitch to # cpi *************************************************************"
echo "* ( may be floating point ) * \033(s3BPrint Spacing Selection:\033(s0B *"
echo "* ( e.g. 16.66 = compressed ) * psp set primary font to proportional spacing *"
echo "* hsi# set horizontal spacing increment to # * spsp set secondary font to proportional spacing *"
echo "* ( #/120's inch ) * fsp set primary font to fixed spacing *"
echo "* ( e.g. hsi10 is the same as 12 cpi ) * sfsp set secondary font to fixed spacing *"
echo "* ( See your printer reference manual ) *************************************************************"
echo "* lpi# print at lines per inch (default is 6 lpi) * \033(s3BResolution Control:\033(s0B *"
echo "* vsi# set vertical spacing increment to # * dpi# set resolution to # *"
echo "* ( #/48's inch ) * ( Supported values for # are : ) *"
echo "* ( e.g. vsi4 is the same as 12 lpi ) * ( 300 or 3 sets printer to 300dpi ) *"
echo "* ( See your printer reference manual ) * ( 600 or 6 sets printer to 600dpi ) *"
echo "*******************************************************************************************************************"
echo "* \033(s3BFont Selection:\033(s0B *"
echo "* cs# set primary character set to # i | italics set primary style to italic *"
echo "* scs# set secondary character set to # si | sitalics set secondary style to italic *"
echo "* ( See your printer reference manual ) upright set primary style to upright *"
echo "* ( for possible character sets, ) supright set secondary style to upright *"
echo "* ( e.g. cs8U sets Roman 8 character set ) slant set primary style to slant *"
echo "* r8 Roman 8 character set sslant set secondary style to slant *"
echo "* k8 Kana 8 character set type# set primary typeface to # *"
echo "* height# set primary height to # stype# set secondary typeface to # *"
echo "* sheight# set secondary height to # weight# set primary font weight to # *"
echo "* style# set primary style to # sweight# set secondary font weight to # *"
echo "* sstyle# set secondary style to # ( <0 = light, 0 = medium , ) *"
echo "* ( possible values for style # ) ( >0 = bold, typical range ) *"
echo "* ( 0 = upright, 1 = italic, 2 = slant ) ( is -7 to +7 ; See your ) *"
echo "* b | bold set font stroke weight to bold (# = 1 ) ( printer reference manual ) *"
echo "*******************************************************************************************************************"
echo "* \033(s3BPage Length Selection:\033(s0B * \033(s3BMargin Selection:\033(s0B *"
echo "* lnnn set absolute length of page to nnn lines * *"
echo "* ( default is 66 ) * lm# set left margin in column # *"
echo "* tlnnn set text length of page to nnn lines * rm# set right margin in column # *"
echo "* ( default is 60 in portrait mode, ) * ( left most column = 0 ) *"
echo "* ( 45 in landscape mode ) * *"
echo "*******************************************************************************************************************"
echo "* \033(s3BPaper Control:\033(s0B \033(s3BPaper Control for Banner Page:\033(s0B *"
echo "* (Default single sided feed from paper cassette) *"
echo "* m | man set up for manual sheet feed ubb | ubbin feed banner page from upper cassette *"
echo "* d | double do automatic double sided printing lbb | lbbin feed banner page from lower cassette *"
echo "* * If your printer is not capable of duplex *"
echo "* printing, use 'md' or 'mdouble' option. \033(s3BPaper Control for Size:\033(s0B *"
echo "* md | mdouble do manual double sided printing letter set printer for letter size *"
echo "* ub | ubin feed paper from upper cassette legal set printer for legal size *"
echo "* lb | lbin feed paper from lower cassette A3 set printer for A3 size *"
echo "* obin# | -obin# | bin# send output to HCO bin number '#' A4 set printer for A4 size *"
echo "* nb do not output banner page B4 set printer for B4 size *"
echo "* yb do output banner page ledger set printer for 11x17 size *"
echo "* mtype'typename' print on this 'typename' of media *"
echo "*******************************************************************************************************************"
echo "* \033(s3BDividing page:\033(s0B (Default normal) * \033(s3BPage Orientation:\033(s0B (Default portrait) *"
echo "* half | 2 double page with half size printing * *"
echo "* quarter | 4 four times page with quarter size printing * port | portrait portrait mode orientation *"
echo "* * Use of these options will negate the effects of * land | landscape landscape mode orientation *"
echo "* the other options except for 'rev', 'portrait', * *"
echo "* 'landscape', 'm', 'man', 'nb', 'd' or 'double'. * *"
echo "*******************************************************************************************************************"
echo "* \033(s3BOptions for Language Switching:\033(s0B *"
echo "* *"
echo "* hpgl2 set the printer to hpgl2-mode and reset it after printing (Orientation in landscape mode) *"
echo "* hpgl2_p set the printer to hpgl2-mode, and reset it after printing (Orientation in portrait mode) *"
echo "*******************************************************************************************************************"
echo "* \033(s3BColor Options:\033(s0B *"
echo "* *"
echo "* Note: The following options are only valid in PCL mode and only for paper sizes \"letter\" and \"A4\". *"
echo "* *"
echo "* black set page text color to black (default) *"
echo "* red set page text color to red *"
echo "* green set page text color to green *"
echo "* yellow set page text color to yellow *"
echo "* blue set page text color to blue *"
echo "* magenta set page text color to magenta *"
echo "* cyan set page text color to cyan *"
echo "* mono force color PCL graphics to be printed in greyscale mode (default is color mode) *"
echo "* trans apply a glossy finish to PCL color transparencies (default is matte/paper finish) *"
echo "*******************************************************************************************************************"
echo "* \033(s3BJob Handling:\033(s0B *"
echo "* mopy collate multiple copies *"
echo "* staple staple jobs *"
echo "*******************************************************************************************************************"
#===========================================================================#
echo "\f\c"
echo "\033(s10H\c" # set up primary pitch to 10
}
# USER CAUTION: This model may be linked to other models and should
# not be modified directly. If any changes are desired, including the
# enhancements described below, you should first make a copy of this
# model under a new name. Changes can then be made to the copy and the
# copy used as the model for the desired printer.
tmpFile=${TMPDIR:-/var/tmp}/lj$$tmp
tmpStdIn=$tmpFile.stdin
tmpStdOut=$tmpFile.data
PATH="/usr/bin:/usr/lbin:/usr/sbin:/sbin"
export PATH
# Save the arguments to the script
user=$(whoami)
title=""
copies=1
options=""
NoPrint=""
while [ $# -gt 0 ]; do
case "$1" in
-d ) LPDEST=$2; shift;;
-d*) LPDEST=${1#-d};;
-t*) title=${1#-t};;
-noprint) NoPrint=true;;
-n*) copies=${1#-t};;
-o) options="$options $2"; shift;;
-o*) options="$options ${1#-o}";;
-*) echo Illegal option $1 >&2; exit 1;;
*) break;;
esac
shift
done
if [ -z "$NoPrint" ]; then
RemoteQueue=""
if [ -n "$LPDEST" ]; then
Remote=$(lpstat -v$LPDEST 2>/dev/null|grep remote|cut -d: -f2)
RemoteHost=$(echo $Remote|cut -d" " -f3)
RemoteQueue=$(echo $Remote|cut -d" " -f1)
fi
else
tmpStdOut=""
fi
# Definitions of functions used within this script
# PCL banner
do_banner()
{
echo "\033&k2G\c"
# Print the standard header
echo "\033&l0O\c" # always in portrait mode
echo "\033(8U\033(s1p60v1s0b16901T\n $user\033(s14v0S"
user1=`pwget -n $user | line | cut -d: -f5`
if [ -n "$user1" ]
then
echo "\n\t\t\t\t\t\t\t\tUser: $user1\n"
else
echo "\n\t\t\t\t\t\t\t\tUser: (No User Info in /etc/passwd)\n"
fi
echo "\t\t\t\t\t\t\t\tOptions: $options\n"
if [ -n "$title" ]
then
echo "\t\t\t\t\t\t\t\tTitle: $title"
else
echo ""
fi
date1=`date`
echo " $date1\t\t\t\t Model Language Default is $default_mode"
if [ -n "$bad_options" ]
then
echo "\n\n\n\n\n\n\n\n\n\n\n\nUnknown options ignored: $bad_options"
fi
# draw box for message
echo "\033&l0E\c"
echo "\033&a2000v0H\033*c4h300v0P\033*c5616h4v0P\c"
echo "\033&a2300v0H\033*c5616h4v0P\c"
echo "\033&a2000v5616H\033*c4h300v0P\c"
# shade the area for message
echo "\033&l0e8C\033&a2000v0H\c"
echo "\033*c5616h300v10g2P\c"
echo "\033(s17v0S"
echo "\033&a2200v15L\c"
echo "For details on options, print a file and specify \"-ooptions\""
# draw box
echo "\033&l0E\c"
echo "\033&a120v0H\033*c4h1680v0P\033*c5616h4v0P\c"
echo "\033&a1800v0H\033*c5616h4v0P\c"
echo "\033&a120v5616H\033*c4h1680v0P\c"
# shade the area
echo "\033&l0e8C\033&a0v0H\c"
echo "\033*c5616h1800v10g2P\c"
echo "\033&a4600v35L\c"
echo " Options Summary"
# echo "\033&k9.3H\c" # use compressed font
echo "\033&a4620v4L\c"
echo " ________________\n\n"
echo "\033(s14v0P\c"
echo "\033&a0H\c"
echo "\033&a1L\c"
echo "* * * * * * * * * * * * * * * * \033(s3BPCL MODE\033(s0B * * * * * * * * * * * * * * * *\n"
echo "Horizontal/Vertical Pitch: 10, 12, c, e, fp#, sfp#, hsi#, lpi#, vsi#"
echo "Page Orientation/Dividing: port, land, half, quarter"
echo "Output Filtering: raw, nroff, pr, rev, ascii"
echo "Print Spacing: psp, spsp, fsp, sfsp"
echo "Page Length/Margin: lnnn, tlnnn, lm#, rm#"
echo "Language: hpgl2, hpgl2_p"
echo "Paper Control: man, double, mdouble, ubin, lbin, ubbin, lbbin, nb, yb,"
echo " P, legal, A3, A4, B4, ledger(11x17), letter"
echo "Font: cs#, scs#, r8, k8, bold, height#, sheight#, italics#,"
echo " sitalics#, style#, sstyle#, upright, supright, slant,"
echo " sslant, type#, stype#, weight#, sweight#"
echo "Color Options: black, red, green, yellow, blue, magenta, cyan, mono, trans\n"
echo "* * * * * * * * * * * * * * \033(s3BPOSTSCRIPT MODE\033(s0B * * * * * * * * * * * * * *\n"
echo "Paper Control: man, double, ubin, lbin, ubbin, lbbin, yb, nb, P, legal,"
echo " A3, A4, B4, ledger(11x17), letter"
echo "Language: pcl, hpgl2, hpgl2_p"
# draw box
echo "\033&a4390v0H\033*c4h3138v0P\033*c5600h4v0P\c"
echo "\033&a7528v0H\033*c5600h4v0P\c"
echo "\033&a4390v5600H\033*c4h3138v0P\c"
# shade the area
echo "\033&l0e8C\033&a4390v0H\c"
echo "\033*c5600h3138v10g2P\c"
echo "\f\c"
}
# Redirect stdout to a file for now
exec >$tmpStdOut
# Set up printer default modes -- Assume PCL mode on entry
echo "\033E\c" # Reset Printer
echo "\033)0B\c" # Secondary character set line draw
echo "\033&k2G\c" # Set line termination mode.
echo "\033*r1U\c" # Default to black and white palette
echo "\033*v1S\c" # Default to black text
echo "\033&b0M\c" # Default to color graphics mode
echo "\033&b0F\c" # Default to matte finish
# Initialize option variables to default values
length="def"
pitch="def"
spitch="def"
hsi="def"
spacing="def"
sspacing="def"
lpi="def"
vsi="def"
charset="def"
scharset="def"
height="def"
sheight="def"
style="def"
sstyle="def"
typeface="def"
stypeface="def"
weight="def"
sweight="def"
pagelen="def"
tpagelen="def"
lmargin="def"
rmargin="def"
outputmode="cooked"
banner=""
orientation="def"
pagemode="def"
outb="def"
mtype="def"
bannerpagemode="def"
duplex="def"
nroff=""
italics=""
modeset="false"
dividing=""
ascii=""
bad_options=""
page_start=""
page_end=""
format="PCL"
paper="def"
resolution=""
printoptions=""
file_type=""
# Variables for Color Options
textcolor="def"
monochrome="def"
glossfinish="def"
printer_collate=""
staple_job=""
des_cs="def"
font_download=""
# Determine which options have been invoked
for i in $options
do
case "$i" in
-hpgl2 | hpgl2)
format="PCL"
file_type="hpgll"
outputmode="raw";;
-hpgl2_p | hpgl2_p)
format="PCL"
file_type="hpglp"
outputmode="raw";;
a | -a | ascii | -ascii) # print ASCII file
ascii="yes";;
-10 | 10) # font pitch set to 10.00 cpi
pitch="10";;
-12 | 12) # font pitch set to 12.00 cpi
pitch="12";;
-c | c) # font pitch set to compressed print
pitch="c";;
-e | e) # font pitch set to expanded print
pitch="e";;
# set primary font pitch to value following fp
-fp[0-9]* | fp[0-9]* | -fp.[0-9]* | fp.[0-9]*)
pitch="`echo "$i" | sed 's/^[-]*fp//'`";;
# set secondary font pitch to value following sfp
-sfp[0-9]* | sfp[0-9]* | -sfp.[0-9]* | sfp.[0-9]*)
spitch="`echo "$i" | sed 's/^[-]*sfp//'`";;
# set horizontal spacing increment to #/120 in.
-hsi[0-9]* | hsi[0-9]*)
hsi="`echo "$i" | sed 's/^[-]*hsi//'`";;
-psp | psp) # set primary font to proportional spacing
spacing=prop;;
-spsp | spsp) # set secondary font to proportional spacing
sspacing=prop;;
-fsp | fsp) # set primary font to fixed spacing
spacing=fixed;;
-sfsp | sfsp) # set secondary font to fixed spacing
sspacing=fixed;;
# set lines per inch to value following lpi
-lpi[0-9]* | lpi[0-9]*)
lpi="`echo "$i" | sed 's/^[-]*lpi//'`";;
# set vertical spacing increment to #/48 inch
-vsi[0-9]* | vsi[0-9]*)
vsi="`echo "$i" | sed 's/^[-]*vsi//'`";;
# set primary character set to value following cs
-cs[0-9]* | cs[0-9]*)
charset="`echo "$i" | sed 's/^[-]*cs//'`";;
# set secondary character set to value following scs
-scs[0-9]* | scs[0-9]*)
scharset="`echo "$i" | sed 's/^[-]*scs//'`";;
-r8 | r8) # primary character set is Roman8
charset="8U";;
-k8 | k8) # primary character set is Kana8
charset="8K";;
# set height to value after height
-height[0-9]* | height[0-9]*)
height="`echo "$i" | sed 's/^[-]*height//'`";;
# set sheight to value after sheight
-sheight[0-9]* | sheight[0-9]*)
sheight="`echo "$i" | sed 's/^[-]*sheight//'`";;
# set font style accordingly
-style[0-2] | style[0-2])
style="`echo "$i" | sed 's/^[-]*style//'`";;
-sstyle[0-2] | sstyle[0-2])
sstyle="`echo "$i" | sed 's/^[-]*sstyle//'`";;
-i | i | -italics | italics)
style=italic;;
-si | si | -sitalics | sitalics)
sstyle=italic;;
-upright | upright)
style=upright;;
-supright | supright)
sstyle=upright;;
-slant | slant)
style=slant;;
-sslant | sslant)
sstyle=slant;;
# set primary typeface to value after type
-type[0-9]* | type[0-9]*)
typeface="`echo "$i" | sed 's/^[-]*type//'`";;
# set secondary typeface to value after stype
-stype[0-9]* | stype[0-9]*)
stypeface="`echo "$i" | sed 's/^[-]*stype//'`";;
# set primary font weight to +- #
-weight[0-9]* | weight[0-9]* | -weight-[0-9]* | weight-[0-9]*)
weight="`echo "$i" | sed 's/^[-]*weight//'`";;
# set secondary font weight to +- #
-sweight[0-9]* | sweight[0-9]* | -sweight-[0-9]* | sweight-[0-9]*)
sweight="`echo "$i" | sed 's/^[-]*sweight//'`";;
# set font weight to bold
-b | b | -bold | bold)
weight=1
sweight=1;;
#set absolute length of page to the value following l
-l[0-9]* | l[0-9]*)
pagelen="`echo "$i" | sed 's/^[-]*l//'`";;
#set text length of page to the value following tl
-tl[0-9]* | tl[0-9]*)
tpagelen="`echo "$i" | sed 's/^[-]*tl//'`";;
# set left margin in column given by value after lm
-lm[0-9]* | lm[0-9]*)
lmargin="`echo "$i" | sed 's/^[-]*lm//'`";;
# set right margin in column given by value after rm
-rm[0-9]* | rm[0-9]*)
rmargin="`echo "$i" | sed 's/^[-]*rm//'`";;
# raw mode for binary output to printer
-r | r | -raw | raw)
modeset="true"
outputmode="raw";;
nb | -nb) # Do not output banner page
banner="";;
yb | -yb) # Do output banner page
banner="yes";;
-rev | rev) # output pages in reverse order
reverse="yes";;
-port | port | -portrait | portrait) # select portrait orientation
orientation="portrait";;
-land | land | -landscape | landscape) # select landscape orientation
orientation="landscape";;
-d | d | -double | double) # set up for automatic double sided copy
duplex="yes";;
-md | md | -mdouble | mdouble) # set up for manual double sided copy
modeset="true"
outputmode="mdouble";;
-m | m | -man | man) # set up printer for manual sheet feed
pagemode="man";;
-ub | ub | -ubin | ubin) # set up printer to feed from upper cassette
pagemode="ubin";;
-lb | lb | -lbin | lbin) # set up printer to feed from lower cassette
pagemode="lbin";;
-ubb | ubb | -ubbin | ubbin) # set up printer to feed banner page from upper cassette
bannerpagemode="ubbin";;
-lbb | lbb | -lbbin | lbbin) # set up printer to feed banner page from lower cassette
bannerpagemode="lbbin";;
# set up printer to properly print output from nroff
-n | n | -nroff | nroff)
nroff="-n"
length="-l66";;
-pr | pr) # set up printer to properly print output from pr
nroff="-p"
length="";;
# dividing page, double page with half size printing
-half | half | -2 | 2)
dividing="-h";;
# dividing page, four times page with quarter size
-quarter | quarter | -4 | 4)
dividing="-q";;
-dpi[03-6]* | dpi[03-6]*)
resolution="`echo "$i" | sed 's/^[-]*dpi//'`";;
-legal | legal)
paper="legal";;
-letter | letter)
paper="letter";;
-A4 | A4)
paper="A4";;
-B4 | B4)
paper="B4";;
-A3 | A3)
paper="A3";;
-ledger | ledger)
paper="ledger";;
-options | options)
banner="yes"
print_options="yes";;
-black | black)
textcolor="black";;
-red | red)
textcolor="red";;
-green | green)
textcolor="green";;
-yellow | yellow)
textcolor="yellow";;
-blue | blue)
textcolor="blue";;
-magenta | magenta)
textcolor="magenta";;
-cyan | cyan)
textcolor="cyan";;
-mono | mono)
monochrome="yes";;
-trans | trans)
glossfinish="yes";;
# 'staple' option overrides bin selection
obin* | -obin* | bin*)
if [ -z "$staple_job" ] ; then
outb=`echo "$i" | sed 's/^[-]*[o]*bin//'`
fi
;;
# media type
mtype* | -omtype* )
mtype="`echo "$i" | sed 's/^mtype//'`"
;;
staple)
staple_job="yes"
outb="5"
;;
# printer collation
mopy)
printer_collate="yes"
;;
* )
bad_options="$bad_options $i";;
esac
done
# Assume that the rest of the arguments are files
files="${*:--}"
# print the banner if "no banner" not specified and reversing is not specified
if [ -n "$banner" -a -z "$reverse" ]
then
if [ "$outb" = "def" ]
then
case "$bannerpagemode" in
def);;
ubbin) echo "\033&l1H\c";;
lbbin) echo "\033&l4H\c";;
esac
else
echo "\033&l${outb}G"
fi
do_banner
if [ "$print_options" = "yes" ]
then
list_options
fi
echo "\033E\c" # Reset Printer
echo "\033)0B\c" # Secondary character set line draw
echo "\033&k2G\c" # Set line termination mode.
fi
# If raw mode turn off output processing
if [ "$outputmode" = "raw" ]
then
case "$format" in
PS) ;;
*) echo "\033&k0G\c";; # Reset line termination mode
esac
#Cancel any text color options set - they don't apply in raw mode
textcolor="def"
fi
# download font if dividing is "half" or "quarter"
if [ -n "$dividing" -a "$format" = "PCL" ]
then
pitch="def"
spitch="def"
hsi="def"
spacing="def"
sspacing="def"
lpi="def"
vsi="def"
charset="def"
scharset="def"
style="def"
sstyle="def"
typeface="def"
stypeface="def"
weight="def"
sweight="def"
pagelen="def"
tpagelen="def"
lmargin="def"
rmargin="def"
nroff=""
italics=""
length="def"
outputmode="divide"
case "$orientation" in
portrait | def)
orientation="portrait"
case "$dividing" in
-h);;
-q) fontdl /usr/lib/lp/fonts/lp4p
font_download=true;;
esac;;
landscape)
case "$dividing" in
-h) fontdl /usr/lib/lp/fonts/lp2l
font_download=true;;
-q) fontdl -l /usr/lib/lp/fonts/lp4l
font_download=true;;
esac;;
esac
fi
# Print the spooled files
i=1
while [ $i -le $copies ]
do
for file in $files
do
if [ "$file" = "-" ]
then
cat - >$tmpStdIn
file=$tmpStdIn
fi
if [ -z "$ascii" ]
then
ftype=`/usr/bin/file $file | cut -d: -f2`
else
format="PCL"
outputmode="cooked"
fi
if [ "$format" = "PCL" ]
then
# OUTPUT bin selection
case "$outb" in
def);;
*) echo "\033&l${outb}G" ;;
esac
# media type
case "$mtype" in
def);;
*) count=`echo "$mtype" | wc -c`
echo "\033&n${count}Wd${mtype}\c";;
esac
case "$orientation" in
def);;
portrait) echo "\033&l0O\c";;
landscape) echo "\033&l1O\c"
length="-l45";;
esac
case "$vsi" in
def);;
*) echo "\033&l${vsi}C\c";;
esac
case "$lpi" in
def);;
*) echo "\033&l${lpi}D\c";;
esac
case "$pagelen" in
def) if [ "$length" = "def" ]
then
length="-l60"
fi
#
# POSSIBLE LASERJET ENHANCEMENT:
# To set the default output on the laserjet printer to be 66 lines
# per page and 80 characters per line with a 4 character left
# margin and a 2 line top margin remove the leading '#' from the
# following 7 lines.
# if [ "$vsi" = "def" -a "$lpi" = "def" -a "$orientation" != "landscape" -a "$nroff" = "" -a "$dividing" = "" ]
# then
# echo "\033&l66p2e7.6c66F\c"
# echo "\033&a4L\c"
# echo "\033&k11H\c"
# length="-l66"
# fi
# If you are using A4 size paper (297 x 210 mm) and desire 70 lines per
# page instead of 66 along with the other characteristics described
# above replace the three occurrences of '66' in the above lines with
# '70' and remove the leading '#' as described.
;;
*) echo "\033&l${pagelen}P\c"
length="-l$pagelen";;
esac
case "$tpagelen" in
def);;
*) echo "\033&l${tpagelen}F\c"
length="-l$tpagelen";;
esac
case "$charset" in
def);;
*) echo "\033(${charset}\c";;
esac
case "$scharset" in
def);;
*) echo "\033)${scharset}\c";;
esac
case "$spacing" in
def);;
prop) echo "\033(s1P\c";;
fixed) echo "\033(s0P\c";;
esac
case "$sspacing" in
def);;
prop) echo "\033)s1P\c";;
fixed) echo "\033)s0P\c";;
esac
case "$pitch" in
def);;
c) echo "\033(s16.66H\c";;
e) echo "\033(s9H\c";;
*) echo "\033(s${pitch}H\c";;
esac
case "$spitch" in
def);;
*) echo "\033)s${spitch}H\c";;
esac
case "$hsi" in
def);;
*) echo "\033&k${hsi}H\c";;
esac
case "$height" in
def);;
*) echo "\033(s${height}V\c";;
esac
case "$sheight" in
def);;
*) echo "\033)s${sheight}V\c";;
esac
case "$style" in
def);;
italic) echo "\033(s1S\c"
italics="-i";;
upright) echo "\033(s0S\c";;
slant) echo "\033(s2S\c";;
*) echo "\033(s${style}S\c";;
esac
case "$sstyle" in
def);;
italic) echo "\033)s1S\c";;
slant) echo "\033)s2S\c";;
upright) echo "\033)s0S\c";;
*) echo "\033)s${sstyle}S\c";;
esac
case "$weight" in
def);;
*) echo "\033(s${weight}B\c";;
esac
case "$sweight" in
def);;
*) echo "\033)s${sweight}B\c";;
esac
case "$typeface" in
def);;
*) echo "\033(s${typeface}T\c";;
esac
case "$stypeface" in
def);;
*) echo "\033)s${stypeface}T\c";;
esac
case "$lmargin" in
def);;
*) echo "\033&a${lmargin}L\c";;
esac
case "$rmargin" in
def);;
*) echo "\033&a${rmargin}M\c";;
esac
case "$pagemode" in
def);;
man) echo "\033&l2H\c";;
ubin) echo "\033&l1H\c";;
lbin) echo "\033&l4H\c";;
esac
case "$duplex" in
def);;
*) echo "\033&l1S\c";;
esac
case "$paper" in
def);;
ledger) echo "\033&l6A\c";;
A3) echo "\033&l27A\c";;
B4) echo "\033&l46A\c";;
A4) echo "\033&l26A\c";;
letter) echo "\033&l2A\c";;
legal) echo "\033&l3A\c";;
esac
case "$textcolor" in
def);;
black) echo "\033*r1U\033*v1S\c";;
red) echo "\033*r3U\033*v1S\c";;
green) echo "\033*r3U\033*v2S\c";;
yellow) echo "\033*r3U\033*v3S\c";;
blue) echo "\033*r3U\033*v4S\c";;
magenta) echo "\033*r3U\033*v5S\c";;
cyan) echo "\033*r3U\033*v6S\c";;
esac
case "$monochrome" in
def);;
yes) echo "\033&b1M\c";;
esac
case "$glossfinish" in
def);;
yes) echo "\033&b1F\c";;
esac
fi
case "$outputmode" in
raw)
case "$file_type" in
hpgll)
echo "\033&l1O\033%1B\c";;
hpglp)
echo "\033&l0O\033%1B\c";;
*) ;;
esac
cat "$file" 2>/var/tmp/sh$$
if [ -s /var/tmp/sh$$ ]
then
cat /var/tmp/sh$$ >&2
fi
if [ -n "$file_type" ]
then
echo "\033%1A\c"
fi
rm -f /var/tmp/sh$$ 2>/dev/null;;
cooked) echo "\r\c"
echo "\033&k2G\c"
if [ -n "$reverse" ]
then
lprpp $italics $length $nroff < "$file" 2>&1 | reverse $length
else
lprpp $italics $length $nroff < "$file" 2>&1
fi
;;
mdouble)
if [ -n "$reverse" ]
then
lprpp $italics $length $nroff -o < "$file" 2>&1 | reverse $length
else
lprpp $italics $length $nroff -o < "$file" 2>&1
fi
echo "\033&l2H\c"
lprpp $italics $length $nroff -e < "$file" 2>&1;;
divide)
echo "\033&k2G\c"
case "$orientation" in
portrait)
divpage -p "$dividing" "$file" 2>&1;;
landscape)
divpage -l "$dividing" "$file" 2>&1;;
esac;;
esac
case "$format" in
PS) echo "\004\c";;
*)
echo "\033E\c" # Reset Printer
echo "\033)0B\c" # Secondary character set line draw
echo "\033&k2G\c";; # Set line termination mode.
esac
done
i=`expr $i + 1`
done
# Delete the temp file created for reading stdin
test -f $tmpStdIn && rm -f $tmpStdIn
# Reset printer
echo "\033E\c" # Reset Printer
echo "\033)0B\c" # Secondary character set line draw
echo "\033&k2G\c" # Set line termination mode.
echo "\033*r1U\c" # Default to black and white palette
echo "\033*v1S\c" # Default to black text
echo "\033&b0M\c" # Default to color graphics mode
echo "\033&b0F\c" # Default to matte finish
# print the banner if "no banner" not specified and reversing IS specified
if [ -n "$banner" -a -n "$reverse" ]
then
if [ "$print_options" = "yes" ]
then
list_options
fi
if [ "$outb" = "def" ]
then
case "$bannerpagemode" in
def);;
ubbin) echo "\033&l1H\c";;
lbbin) echo "\033&l4H\c";;
esac
else
echo "\033&l${outb}G"
fi
do_banner
echo "\033E\c" # Reset Printer
echo "\033)0B\c" # Secondary character set line draw
echo "\033&k2G\c" # Set line termination mode.
fi
# Now we have the formatted file, send it to the printer unless noprint
# First, close the redirection, and point stdout to stderr
if [ -z "$NoPrint" ]; then
exec >&2
# If font was downloaded and remote queue has LF in it, we must FTP
# since the LF->CR/LF conversion will corrpupt the font
if [ -n "$font_download" -a -n "$(echo $RemoteQueue | grep -i LF)" ]; then
echo "Using FTP to $RemoteHost..."
echo "
bin
put $tmpStdOut
quit" | ftp $RemoteHost
ret=$?
echo "" # ftp login prompt leaves cursor at end of line
else
lp -d$LPDEST $tmpStdOut
ret=$?
fi
rm -f $tmpStdOut
else
ret=0
fi
exit $ret