#!/usr/bin/perl # Usage: perl flip.pl inputfile.ps > outputfile.ps # Very first attempt at flipping postscript pages. Useful for transparencies if # you want to write on the opposite side to the printer ink. # Iain Murray Nov 2003 -- www.iainmuray.net # # Disclaimer, I know very little about postscript. Do let me know how this # "should" be done. This doesn't work on many documents. Sometimes it does after # if you run through ps2ps first. while (<>) { if ((/^%%(HiRes|Page|)BoundingBox:/) && !(/\(atend\)/)) { # Fix up bounding box so it still covers everything # after flipping in the line y=0. chomp; ($bb,$x1,$y1,$x2,$y2) = split(" ",$_); print $bb.' -'.$x2.' '.$y1.' -'.$x1.' '.$y2."\n"; } else { print; } # Assume I can safely put a global flip after every page start. # Big assumption. # TODO sometimes works better if goes after EndPageSetup # Placing of this command really needs to be much more intelligent. if (/^%%Page:/) { print "-1.000 1.000 scale\n"; } }