2 #------------------------------------------------------------------------------
3 # ps2eps, written by S.Fourmanoit, 2005
5 # Script that uses psutils and ghostscript to generate
6 # a sequence of compliant encapsulated postscript files
7 # out of a single postscript input.
9 # It was written as a filter for ansi2ps output, and its
10 # really not a generry usage converter.
14 # command_with_some_ansi_escaped_output | ansi2ps | ps2eps [prefix]
16 # Where prefix is the file prefix used for outputting.
18 # If nothing is specified, it is defaulted to /tmp/out
20 #------------------------------------------------------------------------------
26 # Get the output prefix
31 # Get the number of page
33 PAGES
=$
(sed -n '/^%%Pages: /{s/.*\([0-9]\+\)$/\1/;p}' $IN)
34 echo "Outputting $PAGES encapsulated postscripts."
36 for I
in $
(seq -w 1 $PAGES); do
38 echo -n "Extracting page ${I}..."
39 psselect
-p${I} ${IN} ${FILE}.ps
&> /dev
/null
41 echo -n "Computing bounding box..."
42 BBOX
=$
(gs
-q -sDEVICE=bbox
-dBATCH ${FILE}.ps
2>&1 |
sed -n '/^%%/{1p}')
44 echo -n "Finalizing eps creation..."
45 sed '/%%BoundingBox/{s/.*/'"${BBOX}"'/};s/showpage//g' ${FILE}.ps \
48 echo "${FILE}.eps created."