1
0

pdf2ps 894 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/rc
  2. # pdf2ps [-e] [gs-options] [input.pdf [output.ps]] - generate (e)ps from pdf
  3. rfork e
  4. fn usage {
  5. echo 'usage: pdf2ps [-e] [gs-options] [input.pdf [output.ps]]' >[1=2]
  6. exit usage
  7. }
  8. outdev=pswrite
  9. fin=/fd/0
  10. fout=/fd/1
  11. lang=(-'dLanguageLevel=2')
  12. opt=()
  13. while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 - --){
  14. if(~ $1 '-dLanguageLevel='*)
  15. lang=()
  16. if not if(~ '-?' $1)
  17. usage
  18. if(~ $1 -e)
  19. outdev=epswrite
  20. if not
  21. opt=($opt $1)
  22. shift
  23. }
  24. if(~ $1 --)
  25. shift
  26. switch($#*){
  27. case 0
  28. ;
  29. case 1
  30. fin=$1
  31. case 2
  32. fin=$1
  33. fout=$2
  34. case *
  35. usage
  36. }
  37. if(~ $fin -)
  38. fin=/fd/0
  39. if(~ $fout -)
  40. fout=/fd/1
  41. # Doing an inital `save' helps keep fonts from being flushed between
  42. # pages. We have to include the options twice because -I only takes
  43. # effect if it appears before other options.
  44. exec gs $opt -dSAFER -dNOPAUSE -dBATCH -q -s'DEVICE='$outdev $opt $lang \
  45. -s'OutputFile=-' -c save pop -f $fin >$fout