#!/usr/bin/sh
#
#  Bash file to convert the  .ps  output from  Intergraph  VERTICAL
#  ustation into a  .pdf  file.
#
#  Receive just one command line argument = the input  .ps  filename
#  Make up the output  .pdf  filename
#
#  First use sed to edit the input  .ps  file to:
#
#    - Change the  scale  from   0.240000 0.240000   to   0.250 0.255
#
#    - Increase the "pen width"  by one step  -  note the required order
#
#  Then use Ghostscript to make the  .ps  to  .pdf  conversion.
#
#    - For horozontal plots use  /Orientation 3
#    - For  vertical  plots use  /Orientation 0
#


infile="$1";

if [ $# -eq 1 ]
then
        case "${infile}" in
          -)            outfile=- ;;
          *.eps)        base=`basename "${infile}" .eps`; outfile="${base}.pdf" ;;
          *.ps)         base=`basename "${infile}" .ps`;  outfile="${base}.pdf" ;;
          *)            base=`basename "${infile}"`;      outfile="${base}.pdf" ;;
        esac
else
        outfile="$2"
fi


cp  $infile  temp_file_1.ps


sed  -e  s/"0.240000 0.240000 scale"/"0.250 0.255 scale"/   \
     -e  s/"5 w"/"6 w"/                                     \
     -e  s/"4 w"/"5 w"/                                     \
     -e  s/"3 w"/"4 w"/                                     \
     temp_file_1.ps  >  temp_file_2.ps


diff  temp_file_1.ps  temp_file_2.ps

rm   temp_file_1.ps


gs  -sDEVICE=pdfwrite  -sOutputFile="temp_file_2.pdf"  -dNOPAUSE  -c "<</Orientation 0>>  setpagedevice"  -f "temp_file_2.ps"  -c quit

mv  temp_file_2.pdf  $outfile

rm   temp_file_2.ps




