pdf2ps 895 B

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