Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!julius.cs.uiuc.edu!news.cs.indiana.edu!rutgers!gatech!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!media01!pkr From: pkr@media01.UUCP (Peter Kriens) Newsgroups: comp.lang.postscript Subject: Re: one-up to two-up transformation? Message-ID: <1584@media01.UUCP> Date: 6 Dec 90 11:01:04 GMT References: <16485.9011291724@s4.sys.uea.ac.uk> Reply-To: pkr@media01.UUCP (Peter Kriens) Organization: Mediasystemen, Netherlands Lines: 60 This awk script was posted some time ago. It works wonderfull. It prints two A4 pages from a conforming postscript file on one A4. ---------------- cut here ------------------------------- #!/bin/sh # # pshalf # # Make Postscript output two pages to a page (rotated, approx 1/2 size). # # reads stdin or files, writes stdout. Takes miminally conforming PostScript # input and produces minimally conforming PostScript output. # # Caveat: the output has mungled around with the showpage operator, which # means that it cannot be used as input to any other program that must # capture the showpage operator (for example psdraft, or pshalf itself). # # Written by Denise Draper denise@cwi.nl # awk ' BEGIN { firsthalf = 1; outpages = 0 } /^%%Pages:/ { next } /^%%PageFonts:/ { next } /^%%Page:/ { if( firsthalf ) { if( outpages != 0 ) print "HfDict begin ep end" outpages = outpages + 1 print "%%Page: ? " outpages print "HfDict begin bp end" } else { print "HfDict begin hp end" } firsthalf = 1 - firsthalf next } /^%%EndProlog/ { print "% --Pshalf, by Denise Draper--" print "/HfDict 20 dict def HfDict begin gsave/T matrix currentmatrix matrix" print "defaultmatrix matrix invertmatrix matrix concatmatrix def initgraphics" print "clippath pathbbox/y2 exch def/x2 exch def/y1 exch def/x1 exch def/X x2" print "x1 sub def/Y y2 y1 sub def 90 rotate y1 x1 sub x2 neg translate X Y" print "div Y X 2 mul div scale matrix currentmatrix/O1D exch def X 0" print "translate matrix currentmatrix/O2D exch def grestore/nclip{initclip" print "newpath x1 y1 moveto x1 y2 lineto x2 y2 lineto x2 y1 lineto closepath" print "clip newpath}def/bp{gsave O1D setmatrix nclip T concat}def/hp{" print "grestore gsave O2D setmatrix nclip T concat}def/ep{showpage grestore}" print "bind def end/showpage/newpath load def" print "% --End Pshalf--" print "%%Pages: (atend)" print "%%EndProlog" next } /^%%Trailer/ { if( outpages != 0 ) print "HfDict begin ep end" print "%%Trailer" print "%%Pages: " outpages next } { print $0 } ' $@ Brought to you by Super Global Mega Corp .com