[comp.lang.postscript] awk scripts was: PostScript page reverser?

pkr@media01.UUCP (Peter Kriens) (11/02/90)

The problem was that many collaters work different. For these 
problems, Postscript gives you all the information to do the
reverseal. C programs that handle this, tend to become 
dirty and difficult to maintain. We are currently using many
small AWK filters to handle these probems. The requested
reverse program took 15 minutes to build & test and we made
filters for automatic page fitting, scaling, splitting a file
into multiple pages (if it does not fit on 1 page) etc.

I show the reverse program, and I am very interested in how
other people solve these problems. If there are already
many awk scripts build, are people willing to share those? I
know about pshalf which puts 2 A4 on one. Please send them
to me and I will put them into one file and repost them

Peter Kriens
Mediasystemen
hp4nl!media01!pkr
pkr@media01.uucp

------ cut here
# PS REVERSE
# print a postscript in reverse sequence
# ALGORITHM: read until a %%Page: comment, output 
# text between pages to temporary files, sequentially numbered.
# When a %%Trailer is found, output temp files in revers
# order to stdout. After all is done, it deletes 
# the temp files. Temp files start with pag*.tmp
# 
# o     = output file name, when "" output is stdout
# list  = list with temp files.
# p     = page number (starts at 1)
# i     = walks backward through temp files
# x     = line of temp file
#
# %%Page        close prev output (if present), open new, save name
# %%Trailer     output temp files in reverse order
# //            catch all, copy complete input to output or temp file
# END           delete all temp files
#
/%%Page:/       { if (o != "") { close(o);} o = "pag" p ".tmp";list[++p]=o;}
/%%Trailer/     { if (o != "") { close(o);} o = ""; 
                  for ( i=p; i > 0; i--)
                    { while ( getline x < list[i] > 0 ) print x; } }
//              { if (o != "") print > o ; else  print }
END             { system( "del pag*.tmp" ); }