] From:	HENRY::IN%"BILLW%sushi.stanford.edu%sri-kl.ARPA%relay.cs.net@rca.com"  9-MAR-1987 07:22 B To:	Info-PostScript <glacier!info-postscript@SCORE.STANFORD.EDU>, * Subj:	Quick "text-to-PS" PostScript header    E This is a file which will allow a PostScript printer to behave like a G line printer for text files.  It is designed to be as short as possible > while maintaining great flexibility.  It works by reading fromE "currentfile", and may simply be PREpended to the beginning of a text   file and shipped to the printer. Unix(tm) example:   ( 	prompt: cat printfile.ps textfile | lpr  A There are a number of default parameters for page setup which may B easily be given alternate definitions by either prepending a shortD text file or by downloading some permanenent definitions outside the? server loop of your PostScript printer (NOTE:  if you are using E TranScript(tm), make sure the included file starts with "%!").  These A include: top, left, and bottom margins, default font, point size, C leading, the capability for a header line and/or page numbering (as D well as specification of a default font and pointsize for the header> fields).  These are redefined by simply prepending lines like:  3 /header (printfile.ps Tue Apr 22 16:30:05 1986) def  /pagenumber false def  /fontname /Palatino-Roman def  /pointsize 12 def   G I have tried to avoid complexity where possible, but it might be of use E to define a special dictionary for these parameters if they are to be   declared outside the serverloop.  @ NOTE:  this file MUST end with the line containing only the wordG "printfile".  Everything after this line in the file will be considered G part of the DATA and will be printed on the page (include blank lines).   B BUGS:  This is a very simple program.  It does not deal with tabs,E in-line font changes, or a host of other troublesome things.  You may 9 add whatever features you like to it.  Please mail me any  improvements you make.  G Enough.  Herein follow two copies of the code, one fully commented, and B one with all unnecessary comments and whitespace stripped out (for compactness)  7 ---------------------- cut once -----------------------  %!-Adobe-1.0 %%Title: printfile.ps 1 %%Creator: Glenn Reid, Adobe Systems Incorporated ( %%CreationDate: Tue Apr 22 15:35:53 1986
 %%Pages: 0@ %% Copyright (c) 1986 Glenn Reid and Adobe Systems Incorporated.@ %% Use it, distribute it (with this message), but don't sell it. %%@ %% This program will take miscellaneous text concatenated at its? %% end and print it in some default font.  It is designed to be A %% minimal in its functionality, but flexible enough to be easily  %% adapted to other uses.    /in.	{72 mul}	def / /line	512	string def	% for input line buffering 0 /buff	10	string def	% for page number conversion   %% CHANGE THESE IF YOU LIKE   B %% If any of these parameters are defined ahead of this file, then> %% those values will be used.  A typical way to use this is to= %% allow an application to redefine some of the parameters by @ %% inserting definitions ahead of this file in the print stream.' %% Examples of redefinitions look like:  %%  $ %%     /fontname /Palatino-Roman def %%     /pointsize /13 def   %%     /header (document.ps) def %%     /pagenumber false def %%     /leftmargin 36 def  %%  A %% Any number (including 0) of these parameters may be defined to : %% be different from the defaults.  The defaults are quiteA %% reasonable for general use, and will print in 11-point Courier ? %% with a 12-point Courier-Bold header (only prints a header of A %% /header string is defined by the user).  Margins top, left and , %% bottom are: .75 in.,  .75 in., and .5 in. %%  3 %%  Otherwise, the following defaults will be used:    /leftmargin where not ,     { /leftmargin .75 in. def } {pop} ifelse /bottom where not '     { /bottom .5 in. def } {pop} ifelse  /startX where not +     { /startX leftmargin def } {pop} ifelse  /startY where not '     { /startY 10 in. def } {pop} ifelse  /fontname where not +     { /fontname /Courier def } {pop} ifelse  /pointsize where not&     { /pointsize 11 def } {pop} ifelse /leading where not1     { /leading pointsize 2 add def } {pop} ifelse  /headerfontname where not 6     { /headerfontname /Courier-Bold def } {pop} ifelse /headerpointsize where not,     { /headerpointsize 12 def } {pop} ifelse /headerfont 5     headerfontname findfont headerpointsize scalefont  def  /page where not       { /page 1 def } {pop} ifelse /pagenumber where not )     { /pagenumber true def } {pop} ifelse   : % This routine will print a header at the top of each page /printheader {	     gsave  	currentdict /header known { 	    36 10.5 in. moveto  	    headerfont setfont  	    header show 	} if 
 	pagenumber {  	    8 in. 10.5 in. moveto 	    headerfont setfont  	    page buff cvs show  	    /page page 1 add def  	} if      grestore     startX startY moveto
 } bind def   /crlf { @     leftmargin currentpoint exch pop	% replace X with leftmargin     leading sub      dup bottom le $     { pop pop showpage printheader }     { moveto } ifelse 
 } bind def   /printfile {.     line readline		% read a line from the file)     {				% 'if' procedure body (+boolean)  	{			% 'while' procedure body . 	    show crlf		% show what's left by readline' 	    currentfile cvlit	% use as operand + 	    line readline	% and read the next line 4 	    not {exit} if	% exit if no more input to be had 	} loop			% end of while-proc      } if-     showpage			% when input file is exhausted  } bind def			% /printfile   - fontname findfont pointsize scalefont setfont    printheader		% execute header 3 currentfile cvlit	% uses rest of this file as input   B % everything following 'PrintFile' is treated as data, through EOF	 printfile 8 ---------------------- cut twice -----------------------! %! Adobe PasteUp Version 2.0 (35)  /in.{72  mul}def/line 512  string def/buff 10 string def/leftmargin where  not{/leftmargin  .75  in.  def}{pop}ifelse/bottom where  not{/bottom  .5 in.  def}{pop}ifelse/startX where  not{/startX 
 leftmargin def}{pop}ifelse/startY where  not{/startY  10 in.  def}{pop}ifelse/fontname where  not{/fontname/Courier  def}{pop}ifelse/pointsize  where  not{/pointsize 11 def}{pop}ifelse/leading  where  not{/leading	 pointsize  2  add  def}{pop}ifelse/headerfontname where   not{/headerfontname/Courier-Bold def}{pop}ifelse/headerpointsize  where  not{/headerpointsize 12 def}{pop}ifelse/headerfont headerfontname findfont headerpointsize 	 scalefont  def/page where 	 not{/page  1  def}{pop}ifelse/pagenumber where  not{/pagenumber  true! def}{pop}ifelse/printheader{gsave  currentdict/header known{36 10.5 in.  moveto
 headerfont setfont  header show}if  pagenumber{8 in.  10.5 in.  moveto
 headerfont setfont  page buff cvs 	 show/page  page 1  add  def}if grestore startX startY moveto}bind  def/crlf{leftmargin  currentpoint exch pop  leading  sub  dup  bottom le{pop pop  showpage printheader}{moveto}ifelse}bind  def/printfile{line readline{{show crlf currentfile  cvlit  line readline not{exit}if}loop}if 
 showpage}bind  def  fontname findfont	 pointsize 	 scalefont  setfont  printheader  currentfile  cvlit 	 printfile 