ps2pdf 680 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. if(~ $fin -)
  31. fin=/fd/0
  32. if(~ $fout -)
  33. fout=/fd/1
  34. # We have to include the options twice because -I only takes effect
  35. # if it appears before other options.
  36. exec gs $opt -dSAFER -dNOPAUSE -dBATCH -q -s'DEVICE=pdfwrite' \
  37. $opt $compat \
  38. -s'OutputFile='$fout -c .setpdfwrite -f $fin