#! /bin/sh
#
# Forge Postscript Banners looking like ones people know and love
#
#   Copyright 2008 Free Software Foundation, Inc.
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.

Job=${1:-'Unknown Job Number'}
User=${2:-spooler}
Postuser=${3:-$2}
Size=${4:-'Unknown size'}
Time=${5:-0}
Pri=${6:-150}
Title=${SPOOLHDR:-'<No title>'}

cat <<\%
/banner {
	/saveobj save def
	erasepage initgraphics

	/#copies 1 def
	/inch {72 mul} bind def
	/pagebbox [clippath pathbbox newpath] def

	/font /Helvetica def
	/size 20 def
	/height pagebbox 3 get def
	/width pagebbox 2 get .09 mul def

	.92 setgray
	pagebbox 0 get pagebbox 1 get moveto
	width 0 rlineto 0 height rlineto width neg 0 rlineto closepath eofill
	pagebbox 2 get pagebbox 1 get moveto
	width neg 0 rlineto 0 height rlineto width 0 rlineto closepath eofill
	0 setgray

	font findfont size scalefont setfont
	/linesp size size .15 mul add neg def
	/tab (Destination) stringwidth pop 1.5 mul def
	/nextline {0 0 moveto show tab 0 moveto show 0 linesp translate} def

	pagebbox 0 get 1.5 width mul add pagebbox 3 get 2.0 width mul sub translate
	(Title:) nextline
	(Originator:) nextline
	(Job-Number:) nextline
	(Priority:) nextline
	(Size:) nextline
	(Printed on:) nextline
	showpage
	saveobj restore
} bind def
%
echo "(`date '+%a %d %h 19%y %H:%M:%S'`)"
echo "($Size bytes)"
echo "($Pri)"
echo "($Job)"
if [ "$User" = "$Postuser" ]
then	echo "($User)"
else	echo "($User on behalf of $Postuser)"
fi
echo "($Title)"
echo banner
