home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 August - Disc 1 / PCNET_CD_2006_08_1.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / bin / ps2epsi < prev    next >
Encoding:
Text File  |  2005-07-31  |  1.8 KB  |  81 lines

  1. #!/bin/sh
  2. # $Id: ps2epsi,v 1.10 2004/08/04 00:55:46 giles Exp $
  3.  
  4. # This definition is changed on install to match the
  5. # executable name set in the makefile
  6. GS_EXECUTABLE=gs
  7.  
  8. tmpfile=/tmp/ps2epsi$$
  9.  
  10. export outfile
  11.  
  12. if [ $# -lt 1 -o $# -gt 2 ]; then
  13.     echo "Usage: `basename $0` file.ps [file.epsi]" 1>&2
  14.     exit 1
  15. fi
  16.  
  17. infile=$1;
  18.  
  19. if [ $# -eq 1 ]
  20. then
  21.     case "${infile}" in
  22.       *.ps)        base=`basename "${infile}" .ps` ;;
  23.       *.cps)    base=`basename "${infile}" .cps` ;;
  24.       *.eps)    base=`basename "${infile}" .eps` ;;
  25.       *.epsf)    base=`basename "${infile}" .epsf` ;;
  26.       *)        base=`basename "${infile}"` ;;
  27.     esac
  28.     outfile=${base}.epsi
  29. else
  30.     outfile=$2
  31. fi
  32.  
  33. ls -l "${infile}" |
  34. awk 'F==1    {
  35.         cd="%%CreationDate: " $6 " " $7 " " $8;
  36.         t="%%Title: " $9;
  37.         f="%%For:" U " " $3;
  38.         c="%%Creator: Ghostscript ps2epsi from " $9;
  39.         next;
  40.         }
  41.     /^%!/    {next;}
  42.     /^%%Title:/    {t=$0; next;}
  43.     /^%%Creator:/    {c=$0; next;}
  44.     /^%%CreationDate:/    {cd=$0; next;}
  45.     /^%%For:/    {f=$0; next;}
  46.     !/^%/    {
  47.         print "/ps2edict 30 dict def";
  48.         print "ps2edict begin";
  49.         print "/epsititle (" t "\\n) def";
  50.         print "/epsicreator (" c "\\n) def";
  51.         print "/epsicrdt (" cd "\\n) def";
  52.         print "/epsifor (" f "\\n) def";
  53.         print "end";
  54.         exit(0);
  55.         }
  56.     ' U="$USERNAME$LOGNAME"  F=1 - F=2 "${infile}" >$tmpfile
  57.  
  58. $GS_EXECUTABLE -q -dNOPAUSE -dSAFER -dDELAYSAFER -r72 -sDEVICE=bit -sOutputFile=/dev/null $tmpfile ps2epsi.ps $tmpfile <"${infile}" 1>&2
  59. rm -f $tmpfile
  60.  
  61. (
  62. cat << BEGINEPS
  63. save countdictstack mark newpath /showpage {} def /setpagedevice {pop} def
  64. %%EndProlog
  65. %%Page 1 1
  66. BEGINEPS
  67.  
  68. cat "${infile}" |
  69. sed -e '/^%%BeginPreview:/,/^%%EndPreview[^!-~]*$/d' -e '/^%!PS-Adobe/d'\
  70.     -e '/^%%[A-Za-z][A-Za-z]*[^!-~]*$/d' -e '/^%%[A-Za-z][A-Za-z]*: /d'
  71.  
  72. cat << ENDEPS
  73. %%Trailer
  74. cleartomark countdictstack exch sub { end } repeat restore
  75. %%EOF
  76. ENDEPS
  77.  
  78. ) >> "${outfile}"
  79.  
  80. exit 0
  81.