pdf2ps 827 B

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