[comp.sources.misc] wpshalf - 'pshalf' for Interleaf's wps

p_e@obelix.liu.se.UUCP (P{r Emanuelsson) (10/21/87)

Hi!
This is a submission for comp.sources.misc. Maybe this will be of
some use. It's a small routine to do the same thing as the previously
posted "pshalf", but for Interleaf's wps software with Postscript
output. Since wps's Postscript output is about as far as you can get
from "minimally conforming" I had to experiment to get this to work.
Naturally, the ouput quality leaves something to be desired, but is
sufficient for proof reading. See the README file for installation
info.

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	README
#	wpshalf
# This archive created: Mon Oct 19 01:53:33 1987
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'README'
then
	echo shar: "will not over-write existing file 'README'"
else
cat << \SHAR_EOF > 'README'
This is a small and simple utility for Interleaf's wps software.
It converts two pages to one output page and works only together with
the "pl2ps" utility, version 1.4, supplied by Interleaf.
Since it's the only thing available to me I have no idea if this
(works / does not work) for something else you might have, though I
would be interested to know...

The installation is simple if you're a wps admin (which you have to
be :-> ). Usually (I think - at least here!) wps is set up to spool
its "pl" file through something like "pl2ps | lpr -Ppostscript".
Create another pseudo printer, called for example cx2, that
executes "pl2ps | wpshalf | lpr -Ppostscript".

We have been annoyed by the numerous header pages floating around the
printer. We do know who prints what and noone is going to come running
to your office with your printings anyway. If you want wpshalf to
suppress the headers, just uncomment (remove the "#" in front of) 
the line starting with "#/^headerpage|^logme/ ...".

wpshalf works by fiddling with pl2ps's scale, hopefully this will always
work, even for different printers. However, I'm no PS expert, so...
The correct distances for translations were first calculated by
scientific means. However, when that failed I chose a sowewhat more
heuristic approach...

Please forward comments, improvements, etc, to me. I know it's not perfect.

/Pell, pell@rainier.UUCP, p_e@obelix.liu.se
SHAR_EOF
chmod +x 'README'
fi
if test -f 'wpshalf'
then
	echo shar: "will not over-write existing file 'wpshalf'"
else
cat << \SHAR_EOF > 'wpshalf'
#!/bin/sh
# Inspired by pshalf written by Denise Draper	denise@cwi.nl
# This is wpshalf by Pell			pell@rainier.UUCP

cat >/tmp/psh.$$ # Must work with tempfile
awk '
BEGIN			{ firsthalf = 1 } # I would like to use "pages" here :-(
/^bop$/			{ if (!(pages % 2)) {
				if (firsthalf) {
					print "bop"
					print "7 DPIy mul 0 translate"
				} else {
					print "-7 DPIy mul 0 translate"
				}
			  } else print "bop"
			  next
			}
/^eop$/			{ if (pages % 2) {
				pages = 0
				print "eop"
			  } else {
				if (!firsthalf) print "eop"
				firsthalf = 1 - firsthalf
			  }
			  next
			}
/^\/stateInit/		{ 
print "/wpshalfInit {"
print "54 DPIx div 54 DPIy div  neg scale"
print "/PSpagelength 11 DPIy mul def   %default 8.5 x 11 inches"
print "/PSpagewidth 8.5 DPIx mul def"
print "90 rotate"
print "PSpagewidth 6.5 DPIx mul add neg"
print "  PSpagelength 0.5 DPIy mul add neg translate"
print ".5 .5 translate         %PS lattice points are between pixels"
print "} def"
print "/stateInit {"
			  next
			}
/^stateInit$/		{ print "wpshalfInit"; next }
#/^headerpage|^logme/	{ next } # remove headerpage
			{ print $0 } ' pages=`egrep -c '^bop$' /tmp/psh.$$` /tmp/psh.$$
SHAR_EOF
chmod +x 'wpshalf'
fi
exit 0
#	End of shell archive