#!/bin/sh
# $Id: psprint,v 1.8 2000/07/08 04:29:25 nari Exp $

if [ $# -lt 1 ]; then
	echo "$0: Print Postscript file to ESC/Page printer"
	echo ""
	echo "Usage:$0 [option] -/file"
	echo "option"
	echo "  -300 		300dpi"
	echo "  -600		600dpi"
	echo "  -both"
	echo "  -flip"
	echo "  -s a4/b4/a3	papersize"
	echo "  -c num		number of copies"
	exit 1;
fi

GS="/usr/local/bin/gs"
ERT="/usr/local/bin/ert"
LPR="/usr/bin/lpr"

SIZE=a4
DEV=epag
RES=300
EARG="-lang ESC/Page"
FILES=""
DEBUG=0
XOFF=0
YOFF=0

ARG="-q -dNOPAUSE -dSAFER -dBATCH"

while [ $# -gt 0 ]
do
	case $1 in
	-300) RES=300; EARG="$EARG RS=QK";;
	-600) RES=600; EARG="$EARG RS=FN";;
	-both) ARG="$ARG -dDuplex";;
	-flip) ARG="$ARG -dDuplex -dTumble";;
	-s) shift; SIZE=$1;;
	-c) shift;EARG="$EARG COPIES=$1";;
	-d) DEBUG=1;;
	-)  FILES="$FILES $1";;
	-*) echo "unknown option $1"; exit 1;;
	*)  FILES="$FILES $1";;
	esac
	shift
done ;
ARG="$ARG -sPAPERSIZE=$SIZE -sOutputFile=- -sDEVICE=$DEV"
ARG="$ARG -dEpagOffX=$XOFF -dEpagOffY=$YOFF -r$RES $FILES"

if [ $DEBUG -gt 0 ];then
	echo "$GS $ARG | $ERT $EARG | $LPR -Praw"
else
	$GS $ARG | $ERT $EARG | $LPR -Praw
fi



