#! /usr/local/bin/perl -P ######################################################## # fixfm4ps: fix rotten Framemaker PS files for including # in a PostScript document. It runs fixbb first. # # Usage: # fixfm4ps oldfile.ps <--- reads from oldfile.ps, writes stdout # fixfm4ps > newfile.ps <--- reads stdin, writes stdout # fixfm4ps oldfile.ps newfile.ps <--- reads oldfile.ps writes newfile.ps # ######################################################## print STDERR "Running fixbb on file $ARGV[0]...\n"; system "fixbb $ARGV[0] > /dev/null"; print STDERR "Fixing frame 4 specific problems...\n"; if(@ARGV > 1) { open(STDOUT, "> $ARGV[1]"); } open(INFILE, "< $ARGV[0]"); $count = 0; while() { if($count > 0 || $_ =~ /\/PageSize/) { $count++; } if($count == 1) { print "{}\n"; } if($count > 3) { $count = 0; } if($count == 0) { print; } } close(INFILE);