#!/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; print "%!PS-" print "% This file has been run through pshalf; it should not be run" print "% through any other PostScript post-processors." PREPRO } /^%%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--" PROLOG 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 } ' $@