SUMMARY: Reversing Page Order w/ Postscript

From: ken lewis (krl@asti.com)
Date: Wed Apr 29 1992 - 16:47:46 CDT


Well,

The standard answer was spend money and get transcript/newsprint.

NOT!

As it turned out the manufacturer's software included the following script
which worked for my needs and may work for others. Give it a try.

#!/bin/sh
# Reorganize PostScript job so that page 1 is on top of
# the pile. This is algorithm is slow, but it's easy
# and it works.
# Puts stdin onto stdout.

t1=/usr/tmp/psr1.$$
t2=/usr/tmp/psr2.$$

ec=2
trap 'rm -f $t1 $t2 ; exit $ec' 0

# Save the original file.
cat - >$t1

# Find the line numbers of every showpage.
sed -n -e '/^showpage$/ =' <$t1 >$t2

# Sort the line numbers in decreasing numerical order.
sort -rn $t2 -o $t2

# Cut each piece, from last to first, and put onto
# stdout.
exec 0<$t2
read l2;
if [ $? -ne 0 ]; then
   ec=3
   exit 0
fi
sed -n -e '1,2 p' <$t1
while : ; do
   read ll || ll=2
   l1=`expr $ll + 1`
   sed -n -e "$l1,$l2 p" <$t1
   if [ $l1 -le 3 ]; then
      break
   fi
   l2="$ll"
done

ec=0
exit 0

Finally,

Mike Raffety @ SBC/OC Services, L.P.

had this tasty news also.

        ->From miker@sbcoc.com Wed Apr 29 11:12:51 1992
        ->From: Mike Raffety <miker@sbcoc.com>
        ->X-Organization: SBC/OC Services, L.P.
        ->To: krl@asti.com
        ->Subject: Re: Reversing Page Order w/ Postscript
        ->Content-Length: 3195
        ->X-Lines: 76
        ->
        ->It's not just a matter of including a magic incantation in your
        ->PostScript ... it's rearranging the order the pages appear.
        ->
        ->I find a package called psutils very useful; the README from it
        ->follows; try archie to find a local FTP site to acquire it, or I
        ->could possibly mail it to you if you can't find it anywhere else.
        ->
        ->Please be sure to summarize back to the list; thanks.
        ->
        ->PostScript Utilities Angus Duggan 3 September 1991
        ->
        ->This shar file contains some utilities for manipulating PostScript documents.
        ->Page selection and rearrangement are supported, including arrangement into
        ->signatures for booklet printing, and page merging for 2up/4up/8up/9up printing.
        ->
        ->ENVIRONMENT
        ->
        ->These utilities have been compiled and run on Sun-3 and Sun-4 machines under
        ->SunOS 4.1.1 and 4.0.1, and on HP9000/375 machines under HPUX 7.0
        ->
        ->FILES
        ->
        ->The files contained are:
        ->
        ->-rw-r--r-- 1 ajcd 643 Jul 12 10:34 Makefile
        ->-rw-r--r-- 1 ajcd 2819 Sep 3 10:38 README
        ->-rw-r--r-- 1 ajcd 42765 Sep 3 10:07 appledict.ps.uue
        ->-rw-r--r-- 1 ajcd 3673 Jul 12 10:34 epsffit.c
        ->-rwxr-xr-x 1 ajcd 359 Jul 16 15:21 fixfmps
        ->-rwxr-xr-x 1 ajcd 1042 Jul 16 15:21 fixmacps
        ->-rwxr-xr-x 1 ajcd 1165 Jul 16 15:21 fixpspps
        ->-rwxr-xr-x 1 ajcd 4706 Sep 3 10:22 getafm
        ->-rw-r--r-- 1 ajcd 1066 Jul 12 10:34 psbook.1
        ->-rw-r--r-- 1 ajcd 1990 Jul 12 10:34 psbook.c
        ->-rwxr-xr-x 1 ajcd 2113 Jul 12 10:34 psnup
        ->-rw-r--r-- 1 ajcd 2152 Sep 5 10:20 psnup.1
        ->-rw-r--r-- 1 ajcd 1509 Jul 12 10:34 psselect.1
        ->-rw-r--r-- 1 ajcd 4621 Jul 12 10:34 psselect.c
        ->-rw-r--r-- 1 ajcd 3227 Jul 12 10:34 pstops.1
        ->-rw-r--r-- 1 ajcd 9273 Jul 12 10:34 pstops.c
        ->-rw-r--r-- 1 ajcd 5201 Sep 5 10:16 psutil.c
        ->-rw-r--r-- 1 ajcd 682 Sep 5 10:16 psutil.h
        ->-rwxr-xr-x 1 ajcd 2472 Sep 3 10:38 showchar
        ->
        ->PROGRAMS
        ->
        ->psbook rearranges pages into signatures
        ->psselect selects pages and page ranges
        ->pstops performs general page rearrangement and selection
        ->psnup uses pstops to merge multiple pages per sheet
        ->epsffit fits an EPSF file to a given bounding box
        ->
        ->psselect in modeled after Chris Torek's dviselect program, and psbook is
        ->modeled after Tom Rokicki's dvidvi program. psbook is modeled on my own
        ->dvibook program, which borrows heavily from Chris Torek's dviselect.
        ->
        ->SCRIPTS
        ->
        ->getafm (sh) outputs PostScript to retrieve AFM file from printer
        ->showchar (sh) outputs PostScript to draw a character with metric info
        ->fixfmps (perl) filter to fix framemaker documents so that psselect etc. work
        ->fixmacps (perl) filter to fix Macintosh documents with saner version of md
        ->fixpspps (perl) filter to fix PSPrint PostScript so that psselect etc. work
        ->
        ->INSTALLATION
        ->
        ->UUdecode appledict.ps.uue, edit Makefile to put in required CFLAGS (SYSV for
        ->System V machines), "make", and install files in appropriate places.
        ->
        ->BUGS
        ->
        ->The utilities don't check for PS-Adobe-?.? conformance; they assume documents
        ->conform. Utilities need an extra save/restore around whole document on a
        ->SPARCPrinter, because of bugs in the xnews server.
        ->
        ->Bug fixes and suggestions to ajcd@dcs.ed.ac.uk
        ->

Thanks to:

Travis Priest <travis@cs.odu.edu>
Tom.Murray@cs.clemson.edu (Tom Murray)
svb@cs.purdue.edu (Stephan Bechtolsheim)
poffen@sj.ate.slb.com (Russ Poffenberger)
Mike Raffety <miker@sbcoc.com>

         _
      _ |_| Kenneth R. Lewis,
   _ |_| Applied Software
  |_| 1908 Cliff Valley Way
   _ _ _ Atlanta, Georgia 30329
  |_||_||_| Voice: (404) 633-8660
   _ _ _ Fax: (404) 633-0154
  |_||_||_| Internet: krl@asti.com

I find your lack of faith......DISTURBING!!



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:41 CDT