Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!ctrsol!sdsu!decwrl!nsc!taux01!cyosta From: cyosta@taux01.UUCP ( Yossie Silverman ) Newsgroups: comp.lang.postscript Subject: how to print multiple pages on one page Message-ID: <2148@taux01.UUCP> Date: 12 Jul 89 08:23:49 GMT Reply-To: cyosta%taux01@nsc.nsc.COM ( Yossie Silverman ) Organization: National Semiconductor (IC) Ltd, Israel Lines: 47 I once wrote a program to generate an "load-average" plot for a UNIX system. This program now runs on many machines, each one producing a single page plot. We run the program with the 'rsh' interface from one computer catching the output from each into the same file which is then sent to the LaserWriter for output. The problem was that we were generating 70+ pager per run, which was wasteful and unmanagable. Since we are getting even more computers (work stations) in the near future, we had to find a solution. The soltution was to cram 9 plots into a single page. The problem with this was we wanted to do it without changing the C program that generates the postscript data. The way I did it was to override a few of the PostScript operators with my own procedures. I based this on the fact that I had exactely one 'clippath' call at the start of a single page output and either 'showpage' or 'erasepage initgraphics' at the end. The following code will do what is needed. The only thing to make note of is that 'showpage' should be called an extra 8 times at the end of the postscript in order to flush the last page (anyone have a better idea? Something that could be set up at the start to trap the 'end-of-job' condition?). - Yossie --- % place this code segment before the collection of output pages. % place a file with eight 'showpage's at the end. /Initgraphics {initgraphics} bind def /initgraphics {} def /Erasepage {erasepage} bind def /erasepage {Clippath pathbbox 1 setgray fill} def /Showpage {showpage} bind def /showpage { Which 1 add 9 mod dup /Which exch def 0 eq {Showpage} if } def /Clippath {clippath} bind def /clippath { Initgraphics 1 3 div dup scale Clippath pathbbox 2 index sub 3 div dup 5 1 roll 2 Which 3 mod sub mul exch 3 index sub 3 div dup 6 1 roll 2 Which 3 idiv sub mul exch translate translate 2 copy newpath 0 0 moveto 0 exch lineto exch lineto 0 lineto 0 0 lineto clip } def /Which 0 def -- Yossie Silverman What did the Caspian sea? National Semiconductor Ltd. (Israel) cyosta%taux01@nsc.nsc.COM or RPR1YOS@TECHNION.BITNET NSA LSD FBI KGB PCP CIA MOSAD NUCLEAR MI5 SPY ASSASSINATE SDI -- OOCLAY ITAY