From brf@cbnewsi.att.com Sun Apr  4 20:27:30 1993
Newsgroups: comp.sources.postscript
From: brf@cbnewsi.att.com
Subject: v01i051: lpsim - A simple raw ASCII -> PostScript converter, Part01/01
Followup-To: comp.sources.d
Summary: Yet another raw ASCII to PostScript converter.
Reply-To: brf@cbnewsi.att.com
Organization: Dept. of Computer Science, Brown University
Date: Mon, 5 Apr 1993 01:11:32 GMT

Submitted-by: brf@cbnewsi.att.com
Posting-number: Volume 01, Issue 51
Archive-name: lpsim/part01
Environment: PostScript
Keywords: ascii

Here are PostScript sources for:
    lpsim.ps    - A simple line printer simulator - 3 versions.
    lpsim.make  - Shell script "make" file for lpsim.ps.
                               - B. R. Fowler (brf@mrspock.att.com)

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# Contents:  lpsim.make lpsim.ps
# Wrapped by jgm@vegas on Sun Apr  4 20:06:42 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
echo If this archive is complete, you will see the following message:
echo '          "shar: End of archive."'
if test -f 'lpsim.make' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'lpsim.make'\"
else
  echo shar: Extracting \"'lpsim.make'\" \(1531 characters\)
  sed "s/^X//" >'lpsim.make' <<'END_OF_FILE'
X# lpsim.make - Greps out the useful subsets of lpsim.ps for different types of
X#	       printer simulator.
X#
X#	       Usage: lpsim.make <type selector letter>
X#	       Where <type selector letter> is one of:
X#			L - Landscape - 66 lines by 132 cols
X#				(Output goes to: landscape.ps)
X#			P - Portrate - 66 lines by 80 cols
X#				(Output goes to: portrait.ps)
X#			S - Small print - 90 lines by 100 cols
X#				(Output goes to: smallprt.ps)
X#
X# Check that required source file is there
Xif test ! -f lpsim.ps -o ! -r lpsim.ps
Xthen
X	echo "$0: ERROR - Required source file lpsim.ps not accessable"
X	exit 1
Xfi
X# Analyze the argument if any and set up output file name
Xcase $1 in
X#	L - Landscape
X	L)
X		OF=landscape.ps
X	;;
X#	P - Portrate
X	P)
X		OF=portrait.ps
X	;;
X#	S - Small print
X	S)
X		OF=smallprt.ps
X	;;
X#	display valid type selector letters for unrecognized input
X	?*)
X		echo "$0: Invalid type selector letter <$1>. Valid ones are:"
X		echo "$0:   L - Landscape - 66 lines by 132 cols"
X		echo "$0:   P - Portrate - 66 lines by 80 cols"
X		echo "$0:   S - Small print - 90 lines by 100 cols"
X		echo "$0: Please try again..."
X		exit 0
X	;;
X#	<null> - provide some guidance
X	*)
X		echo "$0: Usage: $0 <type selector letter>"
X		exit 0
X	;;
Xesac
X# See if output file already exists
Xif test -s $OF
Xthen
X	/usr/bin/echo -n "File $OF already exists. Replace it? [n]: "
X	read CMD
X	if test "x$CMD" != "xy" -a "x$CMD" != "xY"
X	then
X		echo "Nothing written"
X		exit 1
X	fi
Xfi
X# Grep out the requested result
Xgrep -v :$1: lpsim.ps >$OF
Xecho "$0: $OF written"
END_OF_FILE
  if test 1531 -ne `wc -c <'lpsim.make'`; then
    echo shar: \"'lpsim.make'\" unpacked with wrong size!
  fi
  chmod +x 'lpsim.make'
  # end of 'lpsim.make'
fi
if test -f 'lpsim.ps' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'lpsim.ps'\"
else
  echo shar: Extracting \"'lpsim.ps'\" \(3750 characters\)
  sed "s/^X//" >'lpsim.ps' <<'END_OF_FILE'
X DON'T try to run this file as-is.  You must first extract a version.	 :L:S:P:
X This is three PostScript programs in one.  Run one of the following	 :L:S:P:
X to get the flavor you want: (lpsim.make will do it for you)		 :L:S:P:
X	$ grep -v :L: lpsim.ps >landscape.ps				 :L:S:P:
X	$ grep -v :P: lpsim.ps >portrait.ps				 :L:S:P:
X	$ grep -v :S: lpsim.ps >smallprt.ps				 :L:S:P:
X									 :L:S:P:
X%!PS
X%%Title:Line Printer Simulator, version 2 (5/92)
X%%Creator:brf@mrspock.att.com (Bruce Fowler)
X%%BoundingBox:0 0 612 792 
X%%Pages:?
X%%EndComments
X%
X% Postscript line printer simulator.  Cat this onto front of file to be
X% printed.  Replaces tabs with blanks (x8, or as specified by /tabsiz).
X% Backspaces cause overprinting.  Line with only ^L causes form feed.
X% Leaves margins, for punching holes.  For 8-1/2 x 11 paper.
X% Prints 66 lines in landscape mode, 9 point type with 8 point spacing.	   :P:S:
X% Prints 66 lines by 80 columns of 12 point type with 11 point spacing.	   :L:S:
X% Prints 90 lines by 100 columns of 9 point type with 8 point spacing.	   :L:P:
X%
X16 dict begin				% Set up some local storage
X/toppg 556 def				% Top of page			   :P:S:
X/toppg 759 def				% Top of page			   :L:S:
X/toppg 756 def				% Top of page			   :L:P:
X/botpg 33 def				% Last line goes here		   :P:S:
X/botpg 33 def				% Last line goes here		   :L:S:
X/botpg 36 def				% Last line goes here		   :L:P:
X/lmargin 36 def				% Left margin (0.5")		   :P:S:
X/lmargin 54 def				% Left margin (0.75")		   :L:S:
X/lmargin 36 def				% Left margin (0.5")		   :L:P:
X/vinc -8 def				% Step to next line		   :P:S:
X/vinc -11 def				% Step to next line		   :L:S:
X/vinc -8 def				% Step to next line		   :L:P:
X/tabsiz 8 def				% Number of spaces per tab stop
X/curline 512 string def			% Storage for current line
X/dobksp { %def				% Move left for backspaces
X	(\b)				% For backspace search
X	{ % loop			% Prints string from top of stack
X		search {		% Back up for backspaces
X			show blankwd neg 0 rmoveto
X			currentpoint pop lmargin lt {
X				lmargin vp moveto	% Don't go off page
X			} if
X		}{ show exit } ifelse	% Show and exit when none found
X	} loop
X} bind def
X/dotab { %def				% Move right to next tab stop
X	currentpoint pop lmargin sub	% Current horizontal position
X	dup blankwd 2 div add tabwd div
X	floor 1 add			% Which tab stop is next
X	tabwd mul exch sub 0 rmoveto	% Position there
X} bind def
X/doprint { %def				% File printing proc
X	/blankwd ( ) stringwidth pop def	% Width of blank
X	/tabwd blankwd tabsiz mul def	% Width of tab stop
X	/vp toppg def			% Start at top of page
X	{				% Read to end of file
X		infil curline readline {
X			dup (\014) eq {		% New page if ^L
X				pop		% Dump the line
X				vp toppg ne {	% Go to top of page
X					showpage			  %:L:
X					gsave showpage grestore		  %:P:S:
X					/vp toppg def
X				} if
X			}{
X				lmargin vp moveto	% Position for output
X				(\t)		% For tab search
X				{ % loop	% Looks in string from readline
X					search
X					{ dobksp dotab }{ dobksp exit } ifelse
X				} loop
X				/vp vp vinc add def	% Move to next line
X				vp botpg le {	% New page if off the end
X					showpage			  %:L:
X					gsave showpage grestore		  %:P:S:
X					/vp toppg def
X				} if
X			} ifelse
X		}{ exit } ifelse	% Exit loop after last line read
X	} loop
X	vp toppg ne {showpage} if	% Make sure last page is printed
X	end				% Pop local dict and quit
X} bind def
X% Initialize and start the action	
X/infil (%stdin) (r) file def		% Source of input to print
X/Courier findfont 9 scalefont setfont	% Scaled Courier		   :P:S:
X/Courier-Bold findfont [11.25 0 0 12 0 0] makefont setfont	% Courier  :L:S:
X/Courier-Bold findfont 9 scalefont setfont	% Scaled Courier	   :L:P:
X[ 0 1 -1 0 612 0 ] concat		% Fit to landscape orientation	   :P:S:
X% Invoke printing proc.  Data follows
Xdoprint
END_OF_FILE
  if test 3750 -ne `wc -c <'lpsim.ps'`; then
    echo shar: \"'lpsim.ps'\" unpacked with wrong size!
  fi
  # end of 'lpsim.ps'
fi
echo shar: End of archive.
exit 0



