#################################
#
# Unix Printing Interface Program
# COPYRIGHT (C) 1999-2009 RICOH COMPANY,LTD.
# All rights reserved
#
#################################

#################################
#
# LNX_TUB_B
# Beginning of the Body
#
#################################

#################################
#
# Paper Orientation (Default=Portrait)
# Delay Orientation command for 2up layout printing.
#
#################################

    portrait )
        Orientation=0
        ;;
    landscape )
        Orientation=1
        ;;
    rportrait )
        Orientation=2
        ;;
    rlandscape )
        Orientation=3
        ;;

#################################
#
# Font Size
#
#################################

    fsize* )
        fontsize=`expr $i : 'fsize\([0-9.]*\)'`
        ;;

#################################
#
# Line Spacing
#
#################################

    lpi* )
        lpi=`expr $i : 'lpi\([0-9]*\)'`
        ;;

#################################
#
# VMI Spacing
#
#################################

    vmi* )
        vmi=`expr $i : 'vmi\([0-9.]*\)'`
        ;;
    vsi* )
        vsi=`expr $i : 'vsi\([0-9.]*\)'`
        ;;

#################################
#
# HMI Spacing
#
#################################

    hmi* )
        hmi=`expr $i : 'hmi\([0-9.]*\)'`
        ;;
    hsi* )
        hsi=`expr $i : 'hsi\([0-9.]*\)'`
        ;;

#################################
#
# Pitch (character per inch)
#
#################################

    10|12 )
        pitch=$i
        ;;
    cpi* )
        pitch=`expr $i : 'cpi\([0-9.]*\)'`
        ;;
    fp* )
        pitch=`expr $i : 'fp\([0-9.]*\)'`
        ;;

#################################
#
# Character compresser
#
#################################

    compress|c|cpx )
        printf "\033&k2S" >> $pcl_tmp
        ;;

#################################
#
# 2-up Layout Print Mode
#
#################################

    2up )
        layout=1
        ;;

#################################
#
# Auto Wrap
#
#################################

    autowrap )
        printf "\033&s0C" >> $pcl_tmp
        ;;

#################################
#
# User ID
#
#################################

    userid=* )
        userid=`parse ${i}`
        if test -n "${userid}";then
            userid=`expr ${userid} : '\([A-Za-z0-9]\{0,8\}\)'`
        fi
        ;;

#################################
#
# User Code
#
#################################

    usercode=* )
        usercode=`parse ${i}`
        if test -n "${usercode}";then
            usercode=`expr ${usercode} : '\([0-9]\{0,8\}\)'`
        fi
        ;;

#################################
#
# Password
#
#################################

    password=* )
        password=`parse ${i}`
        if test -n "${password}";then
            password=`expr ${password} : '\([0-9]\{4,8\}\)'`
        fi
        ;;

#################################
#
# User Name
#
#################################

    username=* )
        username=`parse ${i}`
        if test -n "$username";then
            username=`expr $username : '\([A-Za-z0-9]\{0,16\}\)'`
        fi
        ;;

#################################
#
# File Name
#
#################################

    filename=* )
        filename=`parse ${i}`
        if test -n "$filename";then
            filename=`expr $filename : '\([A-Za-z0-9]\{0,16\}\)'`
        fi
        ;;

#################################
#
# Job Type
#
#################################

    jobtype=* )
        jobtype=`parse ${i}`
        ;;

#################################
#
# Front Cover Print Mode
#
#################################

    fcmode=* )
        fcmode=`parse ${i}`
        ;;

#################################
#
# Front Cover Input Tray
#
#################################

    fctray=* )
        fctray=`parse ${i}`
        ;;

#################################
#
# Slip Sheet Print Mode
#
#################################

    slipmode=* )
        slipmode=`parse ${i}`
        ;;

#################################
#
# Slip Sheet Input Tray
#
#################################

    sliptray=* )
        sliptray=`parse ${i}`
        ;;

#################################
#
# Paper Size
#
#################################

    paper=* )
        paper=`parse ${i}`
        ;;
    letter|letter-fb|executive|executive-fb|legal|legal-fb|11x17|11x17-fb|A3|A3-fb|A4|A4-fb|A5|A5-fb|A6|A6-fb|B4|B4-fb|B5|B5-fb|B6|B6-fb|55x85|55x85-fb|8x13|8x13-fb|825x13|825x13-fb|85x13|85x13-fb|8k|8k-fb|16k|16k-fb|com10env|com10env-fb|monenv|monenv-fb|dlenv|dlenv-fb|c6env|c6env-fb|c5env|c5env-fb )
        paper="${i}"
        ;;

#################################
#
# Input Tray Selection
#
#################################

    itray=* )
        itray=`parse ${i}`
        ;;
    auto|tray1|tray2|tray3|bypass|tray4|tray3lct|manual )
        itray="${i}"
        ;;

#################################
#
# Media Type
#
#################################

    mediatype=* )
        mediatype=`parse ${i}`
        ;;
    mtype* )
        mediatype=`expr $i : 'mtype\(.*\)'|tr "[:upper:]" "[:lower:]"`
        ;;

#################################
#
# Fit to Paper
#
#################################

    fittopaper=* )
        fittopaper=`parse ${i}`
        ;;

#################################
#
# Duplex
#
#################################

    duplex=* )
        duplex=`parse ${i}`
        ;;
    simplex )
        duplex="off"
        ;;
    duplex|vd )
        duplex="long"
        ;;
    hduplex|hd )
        duplex="short"
        ;;

#################################
#
# Output Tray Selection
#
#################################

    outbin=* )
        outbin=`parse ${i}`
        ;;
    default|finisherupper|finishershift|finisherbooklet|internal1|internal2|internalshift )
        outbin="${i}"
        ;;

#################################
#
# Collate
#
#################################

    collate=* )
        collate=`parse ${i}`
        ;;
    collate* )
        collate=`expr $i : 'collate\(.*\)'`
        ;;

#################################
#
# Staple
#
#################################

    staple=* )
        staple=`parse ${i}`
        ;;
    staple* )
        staple=`expr $i : 'staple\(.*\)'`
        ;;

#################################
#
# Punch
#
#################################

    punch=* )
        punch=`parse ${i}`
        ;;
    punch* )
        punch=`expr $i : 'punch\(.*\)'`
        ;;

#################################
#
# Resolution
#
#################################

    resolution=* )
        resolution=`parse ${i}`
        ;;
    dpi* )
        resolution=`expr $i : 'dpi\(.*\)'`
        ;;

#################################
#
# Dithering
#
#################################

    dithering=* )
        dithering=`parse ${i}`
        ;;
    dithering* )
        dithering=`expr $i : 'dithering\(.*\)'`
        ;;

#################################
#
# Image Smoothing
#
#################################

    imagesmoothing=* )
        imagesmoothing=`parse ${i}`
        ;;

#################################
#
# Print Mode
#
#################################

    printmode=* )
        printmode=`parse ${i}`
        ;;

#################################
#
# Edge to Edge Print
#
#################################

    edgetoedge=* )
        edgetoedge=`parse ${i}`
        ;;

#################################
#
# Edge Smoothing
#
#################################

    edgesmooth=* )
        edgesmooth=`parse ${i}`
        ;;

#################################
#
# Toner Saving
#
#################################

    tonersaving=* )
        tonersaving=`parse ${i}`
        ;;

    esac
done

#################################
#
# Setup default options/variables
#
#################################


case "${jobtype}" in
normal|sample|locked|hold|stored|storeprint|docsvr )
    ;;
* )
    jobtype="normal"
    ;;
esac

case "${fcmode}" in
off|blank|oneside|bothsides )
    ;;
* )
    fcmode="off"
    ;;
esac

case "${fctray}" in
tray1|tray2|tray3|bypass|tray4|tray3lct )
    ;;
* )
    fctray="tray1"
    ;;
esac

case "${itray}" in
auto|tray1|tray2|tray3|bypass|tray4|tray3lct )
    ;;
* )
    itray="auto"
    ;;
esac

case "${slipmode}" in
off|blank|print )
    ;;
* )
    slipmode="off"
    ;;
esac

case "${sliptray}" in
tray1|tray2|tray3|bypass|tray4|tray3lct )
    ;;
* )
    sliptray="tray1"
    ;;
esac

case "${paper}" in
letter|letter-fb|executive|executive-fb|legal|legal-fb|11x17|11x17-fb|A3|A3-fb|A4|A4-fb|A5|A5-fb|A6|A6-fb|B4|B4-fb|B5|B5-fb|B6|B6-fb|55x85|55x85-fb|8x13|8x13-fb|825x13|825x13-fb|85x13|85x13-fb|8k|8k-fb|16k|16k-fb|com10env|com10env-fb|monenv|monenv-fb|dlenv|dlenv-fb|c6env|c6env-fb|c5env|c5env-fb )
    ;;
* )
    paper="letter"
    ;;
esac

case "${itray}" in
auto|tray1|tray2|tray3|bypass|tray4|tray3lct|manual )
    ;;
* )
    itray="auto"
    ;;
esac

case "${mediatype}" in
auto|plain|recycled|letterhead|preprinted|prepunched|bond|labels|cardstock|transparency|thin|none|color|special|thick )
    ;;
* )
    mediatype="auto"
    ;;
esac

case "${fittopaper}" in
prompt|scale|crop )
    ;;
* )
    fittopaper="prompt"
    ;;
esac

case "${duplex}" in
off|long|short )
    ;;
* )
    duplex="off"
    ;;
esac

case "${outbin}" in
default|finisherupper|finishershift|finisherbooklet|internal1|internal2|internalshift )
    ;;
* )
    outbin="default"
    ;;
esac

case "${collate}" in
off|on )
    ;;
* )
    collate="off"
    ;;
esac

case "${staple}" in
off|lefts|rights|left|right|left2|right2|top2|cent2 )
    ;;
* )
    staple="off"
    ;;
esac

case "${punch}" in
off|usleft2|euleft2|usleft3|euleft4|neleft4|usright2|euright2|usright3|euright4|neright4|ustop2|eutop2|ustop3|eutop4|netop4|left2|left3|left4|right2|right3|right4|top2|top3|top4 )
    ;;
* )
    punch="off"
    ;;
esac

case "${resolution}" in
300|600 )
    ;;
* )
    resolution="600"
    ;;
esac

case "${dithering}" in
auto|photo|text|user )
    ;;
* )
    dithering="auto"
    ;;
esac

case "${imagesmoothing}" in
off|on|auto|90|150|200|300 )
    ;;
* )
    imagesmoothing="off"
    ;;
esac

case "${printmode}" in
off|edgesmooth|tonersaving1|tonersaving2 )
    ;;
* )
    printmode="edgesmooth"
    ;;
esac

case "${edgetoedge}" in
off|on )
    ;;
* )
    edgetoedge="off"
    ;;
esac

case "${edgesmooth}" in
off|on )
    ;;
* )
    edgesmooth="off"
    ;;
esac

case "${tonersaving}" in
off|on )
    ;;
* )
    tonersaving="off"
    ;;
esac

#################################
#
# Check some constraints here:
#
#################################

if [ -n "$staple" ];then
    if [ "$staple" != "off" ];then
        collate="on"
    fi
fi

mydate=`date +'%Y/%m/%d'`
mytime=`date +'%H:%M:%S'`
ps_timeinfo=`date +'%Y%m%d%H%M'`

if [ "$jobtype" = "docsvr" ];then
    collate="off"
    staple="off"
    punch="off"
    duplex="off"
    outbin="default"
    itray="auto"
    mediatype="auto"
    fcmode="off"
    slipmode="off"
    copies=1
fi

if [ "$jobtype" = "sample" ];then
    collate="on"
fi

if [ -z "$password" -a "$jobtype" = "locked" ];then
    jobtype="normal"
fi

if [ "$jobtype" != "normal" ];then
    Custom_Banner=0
fi

if test -z "$userid";then
    userid=`expr "$user_name" : '\([A-Za-z0-9]\{0,8\}\)'`
fi

if [ -z "$filename" ];then
    filename=' '
fi

if [ "$itray" = "bypass" ];then
    duplex="off"
    staple="off"
    punch="off"
fi

if [ "$fcmode" != "off" ];then
    collate="on"
fi

if [ "$slipmode" != "off" ];then
    mediatype="transparency"
    duplex="off"
    collate="off"
    staple="off"
    punch="off"
    copies=1
fi

if [ "$vmi" -ne 0 ];then
	ln=
fi

if [ -n "$ln" ];then
    if [ "$ln" -gt 0 ];then
        case "$paper" in
        executive )
            _ln=10.5
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=7.25
            fi
            ;;
        letter )
            _ln=11
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=8.5
            fi
            ;;
        legal )
            _ln=14
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=8.5
            fi
            ;;
        12x18 )
            _ln=18
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=12
            fi
            ;;
        11x17 )
            _ln=17
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=11
            fi
            ;;
        55x85 )
            _ln=8.5
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=5.5
            fi
            ;;
        A3 )
            _ln=16.54
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=11.69
            fi
            ;;
        A4 )
            _ln=11.69
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=8.27
            fi
            ;;
        A5 )
            _ln=8.27
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=5.83
            fi
            ;;
        A6 )
            _ln=5.83
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=4.13
            fi
            ;;
        B4 )
            _ln=14.33
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=10.12
            fi
            ;;
        B5 )
            _ln=10.12
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=7.17
            fi
            ;;
        B6 )
            _ln=7.17
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=5.04
            fi
            ;;
        825x13 )
            _ln=13
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=8.25
            fi
            ;;
        85x13 )
            _ln=13
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=8.5
            fi
            ;;
        8x13 )
            _ln=13
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=8
            fi
            ;;
        8x10 )
            _ln=10
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=8
            fi
            ;;
        825x14 )
            _ln=14
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=8.25
            fi
            ;;
        10x14 )
            _ln=14
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=10
            fi
            ;;
        10x15 )
            _ln=15
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=10
            fi
            ;;
        11x14 )
            _ln=14
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=11
            fi
            ;;
        11x15 )
            _ln=15
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=11
            fi
            ;;
        126x192 )
            _ln=19.2
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=12.6
            fi
            ;;
        126x185 )
            _ln=18.5
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=12.6
            fi
            ;;
        13x18 )
            _ln=18
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=13
            fi
            ;;
        13x192 )
            _ln=19.2
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=13
            fi
            ;;
        13x19 )
            _ln=19
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=13
            fi
            ;;
        sra3 )
            _ln=17.72
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=12.6
            fi
            ;;
        sra4 )
            _ln=12.6
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=8.9
            fi
            ;;
        com10env )
            _ln=9.5
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=4.125
            fi
            ;;
        monenv )
            _ln=7.5
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=3.875
            fi
            ;;
        dlenv )
            _ln=8.66
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=4.33
            fi
            ;;
        c6env )
            _ln=6.38
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=4.49
            fi
            ;;
        c5env )
            _ln=9.02
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=6.38
            fi
            ;;
        8k )
            _ln=15.35
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=10.51
            fi
            ;;
        16k )
            _ln=10.51
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=7.68
            fi
            ;;
        226x310 )
            _ln=12.21
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=8.9
            fi
            ;;
        310x432 )
            _ln=17.01
            if [ "$Orientation" -eq 1 -o "$Orientation" -eq 3 ];then
                _ln=12.21
            fi
            ;;
        esac
        OS_NAME=`uname -s`
        case "${OS_NAME}" in
        SunOS )
            vmi=`echo $ln|/usr/xpg4/bin/awk -v l="${_ln}" '{printf("%.2f",(l-1)*48/$1)}'`
            ;;
        Linux )
            vmi=`echo $ln|gawk -v l="${_ln}" '{printf("%.2f",(l-1)*48/$1)}'`
            ;;
        * )
            vmi=`echo $ln|awk -v l="${_ln}" '{printf("%.2f",(l-1)*48/$1)}'`
            ;;
        esac
    else
        vmi=8
    fi
fi

#################################
#
# Create myecho command based on UNIX version
# For BSD UNIX myecho="echo -e",
# For SYS V UNIX myecho="echo"
#
#################################

myecho="echo"
test X`echo -e` = X && myecho="echo -e"

##############################################################
# The order below is somehow important:
#	paper have to be 1st
##############################################################

case "$compress" in
c|cpx|compress)
    $myecho "\\033&k2S\c" >> $pcl_tmp
	;;
esac

#################################
#
# Job Type
#
#################################

case "${jobtype}" in
docsvr )
    _jobtype_pjl_1="ON"
    _jobtype_ps_0="(${password})"
    _jobtype_ps_1="storedprint"
    _jobtype_ps_3="(${filename})"
    ;;
hold )
    _jobtype_pjl_1="OFF"
    _jobtype_pjl_2="PAUSEDJOB"
    _jobtype_pjl_3="OFF"
    ;;
locked )
    _jobtype_pjl_1="OFF"
    _jobtype_pjl_2="SECUREJOB"
    _jobtype_ps_0="(${password})"
    _jobtype_ps_1="secureprint"
    ;;
normal )
    _jobtype_pjl_1="OFF"
    ;;
sample )
    _jobtype_pjl_1="OFF"
    _jobtype_pjl_2="PROOFJOB"
    _jobtype_ps_1="proofprint"
    ;;
stored )
    _jobtype_pjl_1="OFF"
    _jobtype_pjl_2="PAUSEDJOB"
    _jobtype_pjl_3="ON"
    _jobtype_pjl_4="PRIVATE"
    _jobtype_ps_2="1"
    ;;
storeprint )
    _jobtype_pjl_1="OFF"
    _jobtype_pjl_3="ON"
    _jobtype_pjl_4="PRIVATE"
    _jobtype_ps_2="2"
    ;;
esac

#################################
#
# Front Cover Print Mode
#
#################################

case "${fcmode}" in
blank )
    _fcmode_pjl_1="BLANK"
    ;;
bothsides )
    _fcmode_pjl_1="DUPLEXCOPY"
    ;;
off )
    _fcmode_pjl_1="OFF"
    ;;
oneside )
    _fcmode_pjl_1="SIMPLEXCOPY"
    ;;
esac

#################################
#
# Front Cover Input Tray
#
#################################

case "${fctray}" in
bypass )
    _fctray_pjl_1="BYPASS"
    ;;
tray1 )
    _fctray_pjl_1="TRAY1"
    ;;
tray2 )
    _fctray_pjl_1="TRAY2"
    ;;
tray3 )
    _fctray_pjl_1="TRAY3"
    ;;
tray3lct )
    _fctray_pjl_1="LCT"
    ;;
tray4 )
    _fctray_pjl_1="TRAY4"
    ;;
esac

#################################
#
# Front Cover Body Tray
#
#################################

case "${itray}" in
auto )
    _itray_pjl_1="ALL"
    _itray_pjl_2="ALL"
    ;;
bypass )
    _itray_pjl_1="BYPASS"
    _itray_pjl_2="BYPASS"
    ;;
tray1 )
    _itray_pjl_1="TRAY1"
    _itray_pjl_2="TRAY1"
    ;;
tray2 )
    _itray_pjl_1="TRAY2"
    _itray_pjl_2="TRAY2"
    ;;
tray3 )
    _itray_pjl_1="TRAY3"
    _itray_pjl_2="TRAY3"
    ;;
tray3lct )
    _itray_pjl_1="LCT"
    _itray_pjl_2="LCT"
    ;;
tray4 )
    _itray_pjl_1="TRAY4"
    _itray_pjl_2="TRAY4"
    ;;
esac

#################################
#
# Slip Sheet Print Mode
#
#################################

case "${slipmode}" in
blank )
    _slipmode_pjl_1="BLANK"
    ;;
off )
    _slipmode_pjl_1="OFF"
    ;;
print )
    _slipmode_pjl_1="COPY"
    ;;
esac

#################################
#
# Slip Sheet Input Tray
#
#################################

case "${sliptray}" in
bypass )
    _sliptray_pjl_1="BYPASS"
    ;;
tray1 )
    _sliptray_pjl_1="TRAY1"
    ;;
tray2 )
    _sliptray_pjl_1="TRAY2"
    ;;
tray3 )
    _sliptray_pjl_1="TRAY3"
    ;;
tray3lct )
    _sliptray_pjl_1="LCT"
    ;;
tray4 )
    _sliptray_pjl_1="TRAY4"
    ;;
esac

#################################
#
# Orientation
#
#################################

case "${Orientation}" in
0|2 )
    _orient_pjl_1="PORTRAIT"
    ;;
1|3 )
    _orient_pjl_1="LANDSCAPE"
    ;;
esac

#################################
#
# Paper Size
#
#################################

case "${paper}" in
11x17 )
    papersize=6
    _paper_ps_1="792 1224"
    _paper_ps_2="false"
    ;;
11x17-fb )
    _paper_ps_1="792 1224"
    _paper_ps_2="true"
    ;;
16k )
    papersize=2031
    _paper_ps_1="553 757"
    _paper_ps_2="false"
    ;;
16k-fb )
    _paper_ps_1="553 757"
    _paper_ps_2="true"
    ;;
55x85 )
    papersize=2008
    _paper_ps_1="396 612"
    _paper_ps_2="false"
    ;;
55x85-fb )
    _paper_ps_1="396 612"
    _paper_ps_2="true"
    ;;
825x13 )
    papersize=2012
    _paper_ps_1="595 935"
    _paper_ps_2="false"
    ;;
825x13-fb )
    _paper_ps_1="595 935"
    _paper_ps_2="true"
    ;;
85x13 )
    papersize=2007
    _paper_ps_1="612 936"
    _paper_ps_2="false"
    ;;
85x13-fb )
    _paper_ps_1="612 936"
    _paper_ps_2="true"
    ;;
8k )
    papersize=2030
    _paper_ps_1="757 1106"
    _paper_ps_2="false"
    ;;
8k-fb )
    _paper_ps_1="757 1106"
    _paper_ps_2="true"
    ;;
8x13 )
    papersize=2011
    _paper_ps_1="576 936"
    _paper_ps_2="false"
    ;;
8x13-fb )
    _paper_ps_1="576 936"
    _paper_ps_2="true"
    ;;
A3 )
    papersize=27
    _paper_ps_1="842 1191"
    _paper_ps_2="false"
    ;;
A3-fb )
    _paper_ps_1="842 1191"
    _paper_ps_2="true"
    ;;
A4 )
    papersize=26
    _paper_ps_1="595 842"
    _paper_ps_2="false"
    ;;
A4-fb )
    _paper_ps_1="595 842"
    _paper_ps_2="true"
    ;;
A5 )
    papersize=2000
    _paper_ps_1="420 595"
    _paper_ps_2="false"
    ;;
A5-fb )
    _paper_ps_1="420 595"
    _paper_ps_2="true"
    ;;
A6 )
    papersize=2001
    _paper_ps_1="297 420"
    _paper_ps_2="false"
    ;;
A6-fb )
    _paper_ps_1="297 420"
    _paper_ps_2="true"
    ;;
B4 )
    papersize=46
    _paper_ps_1="729 1032"
    _paper_ps_2="false"
    ;;
B4-fb )
    _paper_ps_1="729 1032"
    _paper_ps_2="true"
    ;;
B5 )
    papersize=45
    _paper_ps_1="516 729"
    _paper_ps_2="false"
    ;;
B5-fb )
    _paper_ps_1="516 729"
    _paper_ps_2="true"
    ;;
B6 )
    papersize=2020
    _paper_ps_1="363 516"
    _paper_ps_2="false"
    ;;
B6-fb )
    _paper_ps_1="363 516"
    _paper_ps_2="true"
    ;;
c5env )
    papersize=91
    _paper_ps_1="459 649"
    _paper_ps_2="false"
    ;;
c5env-fb )
    _paper_ps_1="459 649"
    _paper_ps_2="true"
    ;;
c6env )
    papersize=2022
    _paper_ps_1="323 459"
    _paper_ps_2="false"
    ;;
c6env-fb )
    _paper_ps_1="323 459"
    _paper_ps_2="true"
    ;;
com10env )
    papersize=81
    _paper_ps_1="297 684"
    _paper_ps_2="false"
    ;;
com10env-fb )
    _paper_ps_1="297 684"
    _paper_ps_2="true"
    ;;
dlenv )
    papersize=90
    _paper_ps_1="311 623"
    _paper_ps_2="false"
    ;;
dlenv-fb )
    _paper_ps_1="311 623"
    _paper_ps_2="true"
    ;;
executive )
    papersize=1
    _paper_ps_1="522 756"
    _paper_ps_2="false"
    ;;
executive-fb )
    _paper_ps_1="522 756"
    _paper_ps_2="true"
    ;;
legal )
    papersize=3
    _paper_ps_1="612 1008"
    _paper_ps_2="false"
    ;;
legal-fb )
    _paper_ps_1="612 1008"
    _paper_ps_2="true"
    ;;
letter )
    papersize=2
    _paper_ps_1="612 792"
    _paper_ps_2="false"
    ;;
letter-fb )
    _paper_ps_1="612 792"
    _paper_ps_2="true"
    ;;
monenv )
    papersize=80
    _paper_ps_1="279 540"
    _paper_ps_2="false"
    ;;
monenv-fb )
    _paper_ps_1="279 540"
    _paper_ps_2="true"
    ;;
esac

if [ "$Orientation" = 1 -o "$Orientation" = 3 ];then
    _paper_ps_1=`echo ${_paper_ps_1} | sed 's/^\(.*\) \(.*\)$/\2 \1/'`
fi

#################################
#
# Input Tray Selection
#
#################################

case "${itray}" in
auto )
    _itray_pcl_1="7"
    _itray_pjl_0="ON"
    ;;
bypass )
    _itray_pcl_1="2"
    _itray_pjl_0="OFF"
    _itray_ps_1="0"
    ;;
tray1 )
    _itray_pcl_1="8"
    _itray_pjl_0="OFF"
    _itray_ps_1="1"
    ;;
tray2 )
    _itray_pcl_1="1"
    _itray_pjl_0="OFF"
    _itray_ps_1="2"
    ;;
tray3 )
    _itray_pcl_1="4"
    _itray_pjl_0="OFF"
    _itray_ps_1="3"
    ;;
tray3lct )
    _itray_pcl_1="4"
    _itray_pjl_0="OFF"
    _itray_ps_1="3"
    ;;
tray4 )
    _itray_pcl_1="30"
    _itray_pjl_0="OFF"
    _itray_ps_1="4"
    ;;
esac

#################################
#
# Media Type
#
#################################

case "${mediatype}" in
auto )
    _mediatype_ps_1="(Auto)"
    ;;
bond )
    _mediatype_pcl_1="5WdBond"
    _mediatype_ps_1="(Bond)"
    ;;
cardstock )
    _mediatype_pcl_1="10WdCardstock"
    _mediatype_ps_1="(Cardstock)"
    ;;
color )
    _mediatype_pcl_1="6WdColor"
    _mediatype_ps_1="(Color)"
    ;;
labels )
    _mediatype_pcl_1="7WdLabels"
    _mediatype_ps_1="(Labels)"
    ;;
letterhead )
    _mediatype_pcl_1="11WdLetterhead"
    _mediatype_ps_1="(Letterhead)"
    ;;
none )
    _mediatype_ps_1="(None)"
    ;;
plain )
    _mediatype_pcl_1="6WdPlain"
    _mediatype_ps_1="(Plain)"
    ;;
preprinted )
    _mediatype_pcl_1="11WdPreprinted"
    _mediatype_ps_1="(Preprinted)"
    ;;
prepunched )
    _mediatype_pcl_1="11WdPrepunched"
    _mediatype_ps_1="(Prepunched)"
    ;;
recycled )
    _mediatype_pcl_1="9WdRecycled"
    _mediatype_ps_1="(Recycled)"
    ;;
special )
    _mediatype_pcl_1="8WdSpecial"
    _mediatype_ps_1="(Special)"
    ;;
thick )
    _mediatype_pcl_1="6WdThick"
    _mediatype_ps_1="(Thick)"
    ;;
thin )
    _mediatype_pcl_1="5WdThin"
    _mediatype_ps_1="(Thin)"
    ;;
transparency )
    _mediatype_pcl_1="13WdTransparency"
    _mediatype_ps_1="(Transparency)"
    ;;
esac

#################################
#
# Fit to Paper
#
#################################

case "${fittopaper}" in
crop )
    _fittopaper_ps_1="false"
    _fittopaper_ps_2="5"
    ;;
prompt )
    _fittopaper_ps_1="true"
    _fittopaper_ps_2="2"
    ;;
scale )
    _fittopaper_ps_1="false"
    _fittopaper_ps_2="3"
    ;;
esac

#################################
#
# Duplex
#
#################################

case "${duplex}" in
long )
    _duplex_pjl_1="ON"
    _duplex_pjl_2="LONGEDGE"
    _duplex_ps_1="true"
    _duplex_ps_2="false"
    ;;
off )
    _duplex_pjl_1="OFF"
    _duplex_ps_1="false"
    ;;
short )
    _duplex_pjl_1="ON"
    _duplex_pjl_2="SHORTEDGE"
    _duplex_ps_1="true"
    _duplex_ps_2="true"
    ;;
esac

#################################
#
# Output Tray Selection
#
#################################

case "${outbin}" in
default )
    _outbin_ps_1="null"
    ;;
finisherbooklet )
    _outbin_pjl_1="FINISHERBOOKLET"
    _outbin_ps_1="(FinBooklet)"
    ;;
finishershift )
    _outbin_pjl_1="FINISHERSHIFT"
    _outbin_ps_1="(FinShift)"
    ;;
finisherupper )
    _outbin_pjl_1="FINISHERPROOF"
    _outbin_ps_1="(FinProof)"
    ;;
internal1 )
    _outbin_pjl_1="UPPER"
    _outbin_ps_1="(Standard)"
    ;;
internal2 )
    _outbin_pjl_1="INNER"
    _outbin_ps_1="(1Bin)"
    ;;
internalshift )
    _outbin_pjl_1="UPPER"
    _outbin_ps_1="(Shift)"
    ;;
esac

#################################
#
# Collate
#
#################################

case "${collate}" in
off )
    _collate_ps_1="false"
    ;;
on )
    _collate_ps_1="true"
    ;;
esac

#################################
#
# Staple
#
#################################

case "${staple}" in
cent2 )
    _staple_pjl_1="BOOKLET"
    _staple_ps_1="8"
    ;;
left )
    _staple_pjl_1="LEFTTOP"
    _staple_ps_1="0"
    ;;
left2 )
    _staple_pjl_1="LEFT2PORT"
    _staple_ps_1="1"
    ;;
lefts )
    _staple_pjl_1="LEFTTOPSLANTPORT"
    ;;
off )
    _staple_pjl_1="OFF"
    ;;
right )
    _staple_pjl_1="RIGHTTOP"
    _staple_ps_1="6"
    ;;
right2 )
    _staple_pjl_1="RIGHT2PORT"
    _staple_ps_1="5"
    ;;
rights )
    _staple_pjl_1="RIGHTTOPSLANTPORT"
    ;;
top2 )
    _staple_pjl_1="TOP2PORT"
    _staple_ps_1="7"
    ;;
esac

#################################
#
# Punch
#
#################################

case "${punch}" in
euleft2 )
    _punch_pjl_1="LEFTPORT"
    _punch_pjl_2="JP2"
    ;;
euleft4 )
    _punch_pjl_1="LEFTPORT"
    _punch_pjl_2="EU4"
    ;;
euright2 )
    _punch_pjl_1="RIGHTPORT"
    _punch_pjl_2="JP2"
    ;;
euright4 )
    _punch_pjl_1="RIGHTPORT"
    _punch_pjl_2="EU4"
    ;;
eutop2 )
    _punch_pjl_1="TOPPORT"
    _punch_pjl_2="JP2"
    ;;
eutop4 )
    _punch_pjl_1="TOPPORT"
    _punch_pjl_2="EU4"
    ;;
neleft4 )
    _punch_pjl_1="LEFTPORT"
    _punch_pjl_2="NEU4"
    ;;
neright4 )
    _punch_pjl_1="RIGHTPORT"
    _punch_pjl_2="NEU4"
    ;;
netop4 )
    _punch_pjl_1="TOPPORT"
    _punch_pjl_2="NEU4"
    ;;
off )
    _punch_pjl_1="OFF"
    _punch_ps_1="0"
    ;;
usleft2 )
    _punch_pjl_1="LEFTPORT"
    _punch_pjl_2="US2"
    ;;
usleft3 )
    _punch_pjl_1="LEFTPORT"
    _punch_pjl_2="US3"
    ;;
usright2 )
    _punch_pjl_1="RIGHTPORT"
    _punch_pjl_2="US2"
    ;;
usright3 )
    _punch_pjl_1="RIGHTPORT"
    _punch_pjl_2="US3"
    ;;
ustop2 )
    _punch_pjl_1="TOPPORT"
    _punch_pjl_2="US2"
    ;;
ustop3 )
    _punch_pjl_1="TOPPORT"
    _punch_pjl_2="US3"
    ;;
left2 )
    _punch_ps_1="2"
    _punch_ps_2="4"
    _punch_ps_3="0"
    _punch_ps_4="2"
    ;;
left3 )
    _punch_ps_1="2"
    _punch_ps_2="4"
    _punch_ps_3="0"
    _punch_ps_4="3"
    ;;
left4 )
    _punch_ps_1="2"
    _punch_ps_2="4"
    _punch_ps_3="0"
    _punch_ps_4="4"
    ;;
right2 )
    _punch_ps_1="2"
    _punch_ps_2="4"
    _punch_ps_3="2"
    _punch_ps_4="2"
    ;;
right3 )
    _punch_ps_1="2"
    _punch_ps_2="4"
    _punch_ps_3="2"
    _punch_ps_4="3"
    ;;
right4 )
    _punch_ps_1="2"
    _punch_ps_2="4"
    _punch_ps_3="2"
    _punch_ps_4="4"
    ;;
top2 )
    _punch_ps_1="2"
    _punch_ps_2="4"
    _punch_ps_3="3"
    _punch_ps_4="2"
    ;;
top3 )
    _punch_ps_1="2"
    _punch_ps_2="4"
    _punch_ps_3="3"
    _punch_ps_4="3"
    ;;
top4 )
    _punch_ps_1="2"
    _punch_ps_2="4"
    _punch_ps_3="3"
    _punch_ps_4="4"
    ;;
esac

#################################
#
# Resolution
#
#################################

case "${resolution}" in
300 )
    _resolution_pjl_1="300"
    _resolution_pjl_2="1"
    ;;
600 )
    _resolution_pjl_1="600"
    _resolution_pjl_2="1"
    ;;
esac

#################################
#
# Dithering
#
#################################

case "${dithering}" in
auto )
    _dithering_ps_1="(auto)"
    ;;
photo )
    _dithering_ps_1="(photo)"
    ;;
text )
    _dithering_ps_1="(text)"
    ;;
user )
    _dithering_ps_1="(user)"
    ;;
esac

#################################
#
# Image Smoothing
#
#################################

case "${imagesmoothing}" in
150 )
    _imagesmoothing_ps_1="150"
    ;;
200 )
    _imagesmoothing_ps_1="200"
    ;;
300 )
    _imagesmoothing_ps_1="300"
    ;;
90 )
    _imagesmoothing_ps_1="90"
    ;;
auto )
    _imagesmoothing_ps_1="(auto)"
    ;;
off )
    _imagesmoothing_ps_1="(off)"
    ;;
on )
    _imagesmoothing_ps_1="(on)"
    ;;
esac

#################################
#
# Print Mode
#
#################################

case "${printmode}" in
edgesmooth )
    _printmode_ps_1="true"
    _printmode_ps_2="0"
    ;;
off )
    _printmode_ps_1="false"
    ;;
tonersaving1 )
    _printmode_ps_1="true"
    _printmode_ps_2="3"
    ;;
tonersaving2 )
    _printmode_ps_1="true"
    _printmode_ps_2="4"
    ;;
esac

#################################
#
# Edge to Edge Print
#
#################################

case "${edgetoedge}" in
off )
    _edgetoedge_pjl_1="NO"
    ;;
on )
    _edgetoedge_pjl_1="YES"
    ;;
esac

#################################
#
# Edge Smoothing
#
#################################

case "${edgesmooth}" in
off )
    _edgesmooth_pjl_1="OFF"
    ;;
on )
    _edgesmooth_pjl_1="ON"
    ;;
esac

#################################
#
# Toner Saving
#
#################################

case "${tonersaving}" in
off )
    _tonersaving_pjl_1="OFF"
    ;;
on )
    _tonersaving_pjl_1="ON"
    ;;
esac

#################################
#
# PostScript Files
#
#################################
# User ID, User Code, Time info
$myecho "mark (${userid}) (${usercode}) (${ps_timeinfo}) {setuserinfo} stopped cleartomark" >> $device_tmp
# Job Type
if [ "$jobtype" = "normal" ];then
    echo "" > /dev/null
elif [ "$jobtype" = "sample" -o "$jobtype" = "locked" -o "$jobtype" = "docsvr" ];then
    $myecho "mark (${userid}) (${ps_timeinfo}) ${_jobtype_ps_0} ${_jobtype_ps_3} {${_jobtype_ps_1}} stopped cleartomark" >> $device_tmp
else
    $myecho "mark { << " >> $device_tmp
    $myecho "/JobType 3 /JobInfo << " >> $device_tmp
    $myecho "/UserID (${userid})" >> $device_tmp
    $myecho "/Time (${ps_timeinfo})" >> $device_tmp
    if [ "${jobtype}" = "stored" -o "${jobtype}" = "storeprint" ];then
        $myecho "/Password (${password})" >> $device_tmp
    fi
    $myecho "/JobID (${filename})" >> $device_tmp
    $myecho ">>" >> $device_tmp
    if [ "${jobtype}" = "stored" -o "${jobtype}" = "storeprint" ];then
        $myecho "/JobAttr << /Save ${_jobtype_ps_2} /Public false >>" >> $device_tmp
    fi
    $myecho ">> /RDeviceProcSet /ProcSet findresource /SetJobType get exec" >> $device_tmp
    $myecho "} stopped cleartomark" >> $device_tmp
fi
# copies
if [ "$copies" -ne 1 ];then
    echo "%%BeginNonPPDFeature: NumCopies $copies" >> $device_tmp
    echo "$copies  /languagelevel where {pop languagelevel}{1} ifelse" >> $device_tmp
    echo "2 ge { 1 dict dup /NumCopies 4 -1 roll put setpagedevice }{ userdict /#copies 3 -1 roll put } ifelse" >> $device_tmp
    echo "%%EndNonPPDFeature" >> $device_tmp
fi
# Fit to Paper
$myecho "<</DeferredMediaSelection ${_fittopaper_ps_1}>> setpagedevice" >> $device_tmp
if [ "${mediatype}" != "none" ];then
    $myecho "<</Policies << /PageSize ${_fittopaper_ps_2} /MediaType 2 >> >> setpagedevice" >> $device_tmp
else
    $myecho "<</Policies << /PageSize ${_fittopaper_ps_2} /MediaType 1 >> >> setpagedevice" >> $device_tmp
fi
# Paper Size
$myecho "<< /PageSize [${_paper_ps_1}] /ImagingBBox null >> setpagedevice" >> $device_tmp
$myecho "${_paper_ps_2} setedgetoedge" >> $device_tmp
# Input Tray Selection
if [ "${itray}" != "auto" ];then
    $myecho "<< /MediaPosition ${_itray_ps_1} >> setpagedevice" >> $device_tmp
fi
# Print Mode
$myecho "<< /HWResolution[600 600] /PostRenderingEnhance ${_printmode_ps_1}" >> $device_tmp
if [ "${printmode}" != "off" ];then
    $myecho "/PostRenderingEnhanceDetails << /Type 34 /OutputMode ${_printmode_ps_2} >>" >> $device_tmp
fi
$myecho ">> setpagedevice" >> $device_tmp
# Duplex
$myecho "<< /Duplex ${_duplex_ps_1}" >> $device_tmp
if [ "${duplex}" != "off" ];then
    $myecho "/Tumble ${_duplex_ps_2}" >> $device_tmp
fi
$myecho ">> setpagedevice" >> $device_tmp
# Dithering
$myecho "${_dithering_ps_1} RCsethalftonetype" >> $device_tmp
# Image Smoothing
$myecho "${_imagesmoothing_ps_1} /RDeviceProcSet /ProcSet findresource /SetImageInterpolate get exec" >> $device_tmp
# Collate
$myecho "<</Collate ${_collate_ps_1}" >> $device_tmp
if [ "${collate}" = "on" ];then
    $myecho "/CollateDetails <</Type 6 /AlignSet false>>" >> $device_tmp
fi
$myecho ">>setpagedevice" >> $device_tmp
# Media Type
$myecho "<< /MediaType ${_mediatype_ps_1} >> setpagedevice" >> $device_tmp
# Output Tray Selection
$myecho "<< /OutputType ${_outbin_ps_1} >>setpagedevice" >> $device_tmp
# Staple
if [ "${staple}" = "off" ];then
    $myecho "<< /Staple 0" >> $device_tmp
fi
if [ "${staple}" != "lefts" -a "${staple}" != "off" -a "${staple}" != "rights" ];then
    $myecho "<<  /Collate true  /CollateDetails <</Type 6 /AlignSet true>>" >> $device_tmp
    $myecho "/Staple 2  /StapleDetails << /Type 14 /Angle 0 /Position ${_staple_ps_1} >>" >> $device_tmp
fi
if [ "${staple}" != "lefts" -a "${staple}" != "rights" ];then
    $myecho ">> setpagedevice" >> $device_tmp
fi
# Punch(PS)
$myecho "<< /Punch ${_punch_ps_1}" >> $device_tmp
if [ "${punch}" != "off" ];then
    $myecho "/PunchDetails << /Type ${_punch_ps_2}" >> $device_tmp
    $myecho "/Position ${_punch_ps_3}" >> $device_tmp
    $myecho "/NumHoles ${_punch_ps_4}" >> $device_tmp
    $myecho ">>" >> $device_tmp
fi
$myecho ">> setpagedevice" >> $device_tmp

#################################
#
# Text Files
#
#################################
# Front Cover Print Mode
$myecho "@PJL SET FRONTCOVERPRINT=${_fcmode_pjl_1}" >> $pjl_tmp
# Front Cover Input Tray
if [ "$fcmode" != "off" ];then
    $myecho "@PJL SET FRONTCOVERPRINTTRAY=${_fctray_pjl_1}" >> $pjl_tmp
fi
# Slip Sheet Print Mode
$myecho "@PJL SET SLIPSHEETPRINT=${_slipmode_pjl_1}" >> $pjl_tmp
# Slip Sheet Input Tray
if [ "$slipmode" != "off" ];then
    $myecho "@PJL SET SLIPSHEETPRINTTRAY=${_sliptray_pjl_1}" >> $pjl_tmp
fi
# Front Cover Body Tray
if [ "$fcmode" != "off" -o "$slipmode" != "off" ];then
    $myecho "@PJL SET DOCBODYTRAY=${_itray_pjl_1}" >> $pjl_tmp
    $myecho "@PJL SET TRAY=${_itray_pjl_2}" >> $pjl_tmp
fi
# Resolution
$myecho "@PJL SET RESOLUTION=${_resolution_pjl_1}" >> $pjl_tmp
$myecho "@PJL SET BITSPERDOT=${_resolution_pjl_2}" >> $pjl_tmp
# Toner Saving
$myecho "@PJL SET ECONOMODE=${_tonersaving_pjl_1}" >> $pjl_tmp
# Edge Smoothing
$myecho "@PJL SET SMOOTHING=${_edgesmooth_pjl_1}" >> $pjl_tmp
# Job Type
$myecho "@PJL SET DISKIMAGE=${_jobtype_pjl_1}" >> $pjl_tmp
if [ "${jobtype}" != "docsvr" -a "${jobtype}" != "normal" -a "${jobtype}" != "storeprint" ];then
    $myecho "@PJL ${_jobtype_pjl_2}" >> $pjl_tmp
fi
if [ "${jobtype}" = "hold" -o "${jobtype}" = "stored" -o "${jobtype}" = "storeprint" ];then
    $myecho "@PJL SET SAVEMODE=${_jobtype_pjl_3}" >> $pjl_tmp
fi
if [ "${jobtype}" = "stored" -o "${jobtype}" = "storeprint" ];then
    $myecho "@PJL SET ACCESSMODE=${_jobtype_pjl_4}" >> $pjl_tmp
fi
$myecho "@PJL SET USERID=\"${userid}\"" >> $pjl_tmp
if [ "${jobtype}" != "locked" -a "${jobtype}" != "normal" -a "${jobtype}" != "sample" ];then
    $myecho "@PJL SET JOBID=\"${filename}\"" >> $pjl_tmp
fi
if [ "${jobtype}" != "hold" -a "${jobtype}" != "normal" -a "${jobtype}" != "sample" ];then
    $myecho "@PJL SET JOBPASSWORD2=\"${password}\"" >> $pjl_tmp
fi
if [ "${jobtype}" = "docsvr" ];then
    $myecho "@PJL SET OWNERID=\"${username}\"" >> $pjl_tmp
fi
# User Code
$myecho "@PJL SET USERCODE=\"${usercode}\"" >> $pjl_tmp
# Orientation
$myecho "@PJL SET ORIENTATION=${_orient_pjl_1}" >> $pjl_tmp
# Duplex
$myecho "@PJL SET DUPLEX=${_duplex_pjl_1}" >> $pjl_tmp
if [ "${duplex}" != "off" ];then
    $myecho "@PJL SET BINDING=${_duplex_pjl_2}" >> $pjl_tmp
fi
# Edge to Edge Print
$myecho "@PJL SET EDGETOEDGE=${_edgetoedge_pjl_1}" >> $pjl_tmp
# Collate
$myecho "@PJL SET JOBOFFSET=OFF" >> $pjl_tmp
# Staple
$myecho "@PJL SET STAPLE=${_staple_pjl_1}" >> $pjl_tmp
# Punch(PCL)
$myecho "@PJL SET PUNCH=${_punch_pjl_1}" >> $pjl_tmp
if [ "${punch}" != "off" ];then
    $myecho "@PJL SET PUNCHHOLE=${_punch_pjl_2}" >> $pjl_tmp
fi
# Output Tray Selection
if [ "${outbin}" != "default" ];then
    $myecho "@PJL SET OUTBIN=${_outbin_pjl_1}" >> $pjl_tmp
fi
# Input Tray Selection
$myecho "@PJL SET AUTOTRAYCHANGE=${_itray_pjl_0}" >> $pjl_tmp
# copies
if [ "$collate" = "on" -a "$copies" -ne 1 ];then
    echo "@PJL SET QTY=${copies}" >> $pjl_tmp
fi

# Media Type
if [ "${mediatype}" != "auto" -a "${mediatype}" != "none" ];then
    $myecho "\\033&n${_mediatype_pcl_1}\c" >> $pcl_tmp
fi
# Input Tray Selection
$myecho "\\033&l${_itray_pcl_1}H\c" >> $pcl_tmp
# copies
if [ "$collate" = "on" ];then
    printf "\033&l1X" >> $pcl_tmp
else
    printf "\033&l%dX" $copies >> $pcl_tmp
fi

#################################
#
# Banner Page Commands
#
#################################
# Resolution
$myecho "@PJL SET RESOLUTION=${_resolution_pjl_1}" >> $banner_pjl_tmp
$myecho "@PJL SET BITSPERDOT=${_resolution_pjl_2}" >> $banner_pjl_tmp
# Toner Saving
$myecho "@PJL SET ECONOMODE=${_tonersaving_pjl_1}" >> $banner_pjl_tmp
# Edge Smoothing
$myecho "@PJL SET SMOOTHING=${_edgesmooth_pjl_1}" >> $banner_pjl_tmp
# Job Type
$myecho "@PJL SET DISKIMAGE=${_jobtype_pjl_1}" >> $banner_pjl_tmp
if [ "${jobtype}" != "docsvr" -a "${jobtype}" != "normal" -a "${jobtype}" != "storeprint" ];then
    $myecho "@PJL ${_jobtype_pjl_2}" >> $banner_pjl_tmp
fi
if [ "${jobtype}" = "hold" -o "${jobtype}" = "stored" -o "${jobtype}" = "storeprint" ];then
    $myecho "@PJL SET SAVEMODE=${_jobtype_pjl_3}" >> $banner_pjl_tmp
fi
if [ "${jobtype}" = "stored" -o "${jobtype}" = "storeprint" ];then
    $myecho "@PJL SET ACCESSMODE=${_jobtype_pjl_4}" >> $banner_pjl_tmp
fi
$myecho "@PJL SET USERID=\"${userid}\"" >> $banner_pjl_tmp
if [ "${jobtype}" != "locked" -a "${jobtype}" != "normal" -a "${jobtype}" != "sample" ];then
    $myecho "@PJL SET JOBID=\"${filename}\"" >> $banner_pjl_tmp
fi
if [ "${jobtype}" != "hold" -a "${jobtype}" != "normal" -a "${jobtype}" != "sample" ];then
    $myecho "@PJL SET JOBPASSWORD2=\"${password}\"" >> $banner_pjl_tmp
fi
if [ "${jobtype}" = "docsvr" ];then
    $myecho "@PJL SET OWNERID=\"${username}\"" >> $banner_pjl_tmp
fi
# User Code
$myecho "@PJL SET USERCODE=\"${usercode}\"" >> $banner_pjl_tmp
# Orientation
$myecho "@PJL SET ORIENTATION=${_orient_pjl_1}" >> $banner_pjl_tmp
# Edge to Edge Print
$myecho "@PJL SET EDGETOEDGE=${_edgetoedge_pjl_1}" >> $banner_pjl_tmp
# Staple
$myecho "@PJL SET STAPLE=${_staple_pjl_1}" >> $banner_pjl_tmp
# Punch(PCL)
$myecho "@PJL SET PUNCH=${_punch_pjl_1}" >> $banner_pjl_tmp
if [ "${punch}" != "off" ];then
    $myecho "@PJL SET PUNCHHOLE=${_punch_pjl_2}" >> $banner_pjl_tmp
fi
# Output Tray Selection
if [ "${outbin}" != "default" ];then
    $myecho "@PJL SET OUTBIN=${_outbin_pjl_1}" >> $banner_pjl_tmp
fi
# Input Tray Selection
$myecho "@PJL SET AUTOTRAYCHANGE=${_itray_pjl_0}" >> $banner_pjl_tmp
# Media Type
if [ "${mediatype}" != "auto" -a "${mediatype}" != "none" ];then
    $myecho "\\033&n${_mediatype_pcl_1}\c" >> $banner_pcl_tmp
fi
# Input Tray Selection
$myecho "\\033&l${_itray_pcl_1}H\c" >> $banner_pcl_tmp
# copies
printf "\033&l1X" >> $banner_pcl_tmp

#################################
#
#  Delay Pitch command for 2up printing.
#  Pitch (characters per inch)
#
#################################

case $pitch in
0 )
    pitch=10
    ;;
esac

#################################
#
# Font Size (characters per inch)
#
#################################

case $fontsize in
0 )
    ;;
* )
    printf "\033(s%.2fH" $fontsize >> $pcl_tmp
    my_lpi=`expr $fontsize \* 3 \/ 5`

    if [ $my_lpi -lt 2 ]
    then
        my_lpi=1
    elif [ $my_lpi -lt 3 ]
    then
        my_lpi=2
    elif [ $my_lpi -lt 4 ]
    then
        my_lpi=3
    elif [ $my_lpi -lt 6 ]
    then
        my_lpi=4
    elif [ $my_lpi -lt 8 ]
    then
        my_lpi=6
    elif [ $my_lpi -lt 12 ]
    then
        my_lpi=8
    elif [ $my_lpi -lt 16 ]
    then
        my_lpi=12
    elif [ $my_lpi -lt 24 ]
    then
        my_lpi=16
    else
        my_lpi=24
    fi

    printf "\033&l%dD" $my_lpi >> $pcl_tmp
    ;;
esac

#################################
#
# lpi (text lines per inch)
#
#################################

case $lpi in
0 )
    ;;
* )
    printf "\033&l%dD" $lpi >> $pcl_tmp
    ;;
esac

#################################
#
# Vertical Motion Index
#
#################################

case $vmi in
0 )
    ;;
* )
    printf "\033&l%.4fC"  $vmi >> $pcl_tmp
    ;;
esac

case $vsi in
0 )
    ;;
* )
    printf "\033&l%.4fC"  $vsi >> $pcl_tmp
    ;;
esac

#################################
#
# Horizontal Motion Index
#
#################################

case $hmi in
0 )
    ;;
* )
    printf "\033&k%.4fH"  $hmi >> $pcl_tmp
    ;;
esac

case $hsi in
0 )
    ;;
* )
    printf "\033&k%.4fH"  $hsi >> $pcl_tmp
    ;;
esac

#################################
#
#  2-up Layout (variable initialization)
#
#################################

case $layout in
1 )
    case $papersize in
    1 )                         # Executive
        width=3028
        height=2051
        ;;
    2 )                         # Letter
        width=3178
        height=2366
        ;;
    3 )                         # Legal
        width=4058
        height=2366
        ;;
    6 )                         # 11x17
        width=4971
        height=3139
        ;;
    2001 )                      # A6
        width=1628
        height=1135
        ;;
    2000 )                      # A5
        width=2359
        height=1640
        ;;
    26 )                        # A4
        width=3380
        height=2289
        ;;
    27 )                        # A3
        width=4831
        height=3359
        ;;
    2020 )                      # B6
        width=2088
        height=1422
        ;;
    45 )                        # B5
        width=2909
        height=1987
        ;;
    46 )                        # B4
        width=4174
        height=2880
        ;;
    2043 )                      # 12x18
        width=5021
        height=3210
        ;;
    2008 )                      # HalfLetter
        width=2426
        height=1549
        ;;
    2011 )                      # 8 x 13
        width=3760
        height=2227
        ;;
    2012 )                      # folio
        width=3760
        height=2302
        ;;
    2007 )                      # 8.5 x 13
        width=3760
        height=2377
        ;;
    2062 )                       # 11x14
        width=4086
        height=3185
        ;;
    2061 )                       # 8x10
        width=2899
        height=2285
        ;;
    2014 )                       # 825x14
        width=4080
        height=2360
        ;;
    2057 )                       # sra3
        width=5160
        height=3620
        ;;
    2030 )                       # 8k
        width=4480
        height=3030
        ;;
    2031 )                       # 16k
        width=3010
        height=2163
        ;;
    80 )                        # monenv
        width=2100
        height=1000
        ;;
    81 )                        # com10env
        width=2700
        height=1060
        ;;
    90 )                        # dlenv
        width=2450
        height=1090
        ;;
    91 )                        # c5env
        width=2550
        height=1790
        ;;
    2022 )                      # c6env
        width=1750
        height=1200
        ;;
    * )                         # Default (Letter)
        width=3178
        height=2366
        ;;
    esac
    ;;
*)
    ;; esac

#################################
#
# Make a Banner Page (remove thia function for E-7000 controller
# $banner_text_tmp is text file only
# $banner_ps_tmp is PCL/PJL with "\r" line return code added file
#
#################################

generate_custom_banner()
{
    printf "[*****************************************]\r\n" > $banner_text_tmp
    printf "[*                                       *]\r\n" >> $banner_text_tmp
    printf "[* User Name : %25.25s *]\r\n" $user_name >> $banner_text_tmp
    printf "[* Host : %30.30s *]\r\n" $host >> $banner_text_tmp
    printf "[*                                       *]\r\n" >> $banner_text_tmp
    printf "[*****************************************]\r\n" >> $banner_text_tmp
    printf "[*                                       *]\r\n" >> $banner_text_tmp
    if [ -n "$title" ];then
        printf "[* Title : %29.29s *]\r\n" "$title" >> $banner_text_tmp
    fi
    case `uname -s` in
    HP-UX)
        printf "[* Request Id : %24.24s *]\r\n" $request_id >> $banner_text_tmp
        ;;
    *)
        printf "[* Job Name : %26.26s *]\r\n" $print_file_name >> $banner_text_tmp
        ;;
    esac

    banner_date=`date |awk '{printf("%3s %02s, %4s",$2,$3,$6)}'`
    echo   "[* Date :                   $banner_date *]" >> $banner_text_tmp
    printf "\r[* Time : %30.30s *]\r\n" `date +'%H:%M:%S'` >> $banner_text_tmp
    printf "[*                                       *]\r\n" >> $banner_text_tmp
    printf "[*                                       *]\r\n" >> $banner_text_tmp
    printf "[* Unix Filter Version : %15.15s *]\r\n" $version >> $banner_text_tmp
    printf "[*                                       *]\r\n" >> $banner_text_tmp
    printf "[*****************************************]\r\n" >> $banner_text_tmp

#################################
#
# Make the $banner_ps_tmp file
#
#################################

    printf "\033%%-12345X" > $banner_ps_tmp
    echo "@PJL JOB NAME=\"FilterBanner\"" >> $banner_ps_tmp
    echo "@PJL SET JOBNAME=\"FilterBanner\"" >> $banner_ps_tmp
    cat $banner_pjl_tmp >> $banner_ps_tmp
    echo "@PJL ENTER LANGUAGE=PCL" >> $banner_ps_tmp
    printf "\033E" >> $banner_ps_tmp
    printf "\033&l%dA" $papersize >> $banner_ps_tmp
    printf "\033&l%dO" $Orientation >> $banner_pcl_tmp
    cat $banner_pcl_tmp >> $banner_ps_tmp
    printf "\033(8U\033(s0p%.2fh0s0b4099T" 10 >> $banner_ps_tmp
    echo >> $banner_ps_tmp
    cat $banner_text_tmp | awk '{print $0, "\r"}' >> $banner_ps_tmp
    printf "\033%%-12345X@PJL EOJ NAME=\"FilterBanner\"\n" >> $banner_ps_tmp
    printf "\033%%-12345X" >> $banner_ps_tmp
}

#################################
# LNX_TUB_E
#
# End of the Body
#################################
