#!/bin/csh -f # Copyright 1991-1993 # Eric A. Brewer # This program fixes the postscript output produced by FrameMaker 4 # so that it can be included in latex. # one argument: file to fix # optional second argument: output file # With one argument, the input file is overwritten # If output file is outfile.ps, generate eps file with bounding box # If output file is outfile.epsi, generate bounding box and device independant preview set base = ${1:r} set input = ${base}.ps if (($#argv < 1) || !(-f $input)) then echo "Usage: fixfm4 infile.ps [outfile.{ps,epsi}]" exit(1) else if ($#argv < 2) then set output = $input else set output = ${2:q} endif onintr cleanup set tmp = "tmp-fixfm-$$" perl -p -e 's/\{1 dict dup[^\}]*setpagedevice/\{/;' \ -e 's/0 0 moveto paperwidth 0 .*//;' \ -e 's/0 paperheight lineto 0 0 lineto.*//;' $input > $tmp.ps echo -n 'Computing bounding box...' ps2epsi $tmp.ps $tmp.epsi >& /dev/null echo ' done' if (${output:e} == "epsi") then # Preserve epsi file as output mv $tmp.epsi $output else # Extract BoundingBox and insert in ps file set bb = `fgrep '%%BoundingBox' $tmp.epsi | head -1` # perl does not work here sed -e "s/%%BoundingBox.*/$bb/" $tmp.ps > $output endif /bin/rm -f $tmp.ps $tmp.epsi exit 0 cleanup: /bin/rm -f $tmp.ps $tmp.epsi exit 2