ps2pdf 646 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/rc
  2. rfork e
  3. fn usage {
  4. echo 'usage: ps2pdf [gs-options] [input.ps] [output.pdf]' >[1=2]
  5. exit usage
  6. }
  7. compat=(-'dCompatibilityLevel=1.2')
  8. opt=()
  9. while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 - --){
  10. if(~ $1 '-dCompatibilityLevel='*)
  11. compat=()
  12. opt=($opt $1)
  13. shift
  14. }
  15. if(~ $1 --)
  16. shift
  17. switch($#*){
  18. case 0
  19. fin='-'
  20. fout='-'
  21. case 1
  22. fin=$1
  23. fout='-'
  24. case 2
  25. fin=$1
  26. fout=$2
  27. case *
  28. usage
  29. }
  30. # We have to include the options twice because -I only takes effect
  31. # if it appears before other options.
  32. gscmd=( gs $opt -dSAFER -dNOPAUSE -dBATCH -q -s'DEVICE=pdfwrite' \
  33. $opt $compat \
  34. -s'OutputFile='$fout -c .setpdfwrite -f $fin)
  35. exec $gscmd