#!/bin/sh
usage() {
cat <<EOF
#
#	8lpi2fax [options] text-file fax-file
#
#	Use faxjet2 to convert a text file to a fax file with
#	8 lines per inch (88 lines/page for letter paper).
#
#	Options:
#	-l		Low resolution fax output
#	-P letter	Use letter size paper for 88 lines/page
#	-P a4		Use letter size paper for 93 lines/page
#	-P legal	Use letter size paper for 112 lines/page
#
EOF
}

#
#	Process the options
#
Paper=letter
Res=

set -- `getopt ?lP: $*`
if [ $? != 0 ]; then usage; exit 2; fi

for i in $*
do
	case $i in
	-l)		Res="-l"; shift;;
	-P)		Paper="$2"; shift; shift;;
	--)		shift; break;;
	-?)		usage; exit 0;;
	esac
done
if [ $# != 2 ]; then usage; exit 2; fi

PCL=
PCL="$PCL\033&l0L"	# No perforation skip
PCL="$PCL\033&l0E"	# No top margin
PCL="$PCL\033&l8D"	# 8 LPI
PCL="$PCL\033(s16.66H"	# 16.66 CPI (line printer font)
(echo "$PCL\c"; cat $1) | faxjet2 -P$Paper $Res -T2 -o $2
