1
0

pdfgsijs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/rc
  2. # usage: pdfgsijs pdffile
  3. gs -dSAFER -dNOPAUSE -dBATCH -q -s'DEVICE=pswrite' -d'LanguageLevel=2' -s'OutputFile=/tmp/pdf2ps.ps' $1
  4. MODEL=`{echo $LPCLASS | sed 's/(.*\+)?gsijs!([^+]*)(\+.*)?/\2/'}
  5. NUMBER=`{echo $LPCLASS | sed 's/(.*\+)?gsijs!([^+]*)\+(.*)?/\3/'}
  6. GSTMPFILE=/tmp/pdf^$pid
  7. switch($NUMBER) {
  8. case 2100
  9. GSOPT=(-q -sDEVICE'='ijs -sIjsServer'='hpijs -sDeviceManufacturer'='HP '-sDeviceModel='"$MODEL^' '^$NUMBER" -r600 -sOutputFile'='^$GSTMPFILE -sPAPERSIZE'='a4 -dIjsUseOutputFD -dSAFER -dNOPAUSE -dBATCH)
  10. case 2500
  11. GSOPT=(-q -sDEVICE'='ijs -sIjsServer'='hpijs -sDeviceManufacturer'='HP '-sDeviceModel='"$MODEL^' '^$NUMBER" -r600 -sOutputFile'='^$GSTMPFILE -dDuplex'='true -sPAPERSIZE'='a4 -dIjsUseOutputFD -dSAFER -dNOPAUSE -DBATCH)
  12. }
  13. if(~ $OLIST '')
  14. gs $GSOPT /tmp/pdf2ps.ps
  15. if not {
  16. PGLIST=`{echo $OLIST | sed 's/-o//;s/,/ /g;s/ / /g' | tr -cd '0-9 -'}
  17. GSPGLIST=()
  18. for(i in $PGLIST){
  19. switch($i){
  20. case -*
  21. GSPGLIST=($GSPGLIST `{seq 1 `{echo $i|tr -d '-'}})
  22. case *-
  23. # BUG assume 100 >= number of pages
  24. GSPGLIST=($GSPGLIST `{seq `{echo $i|tr -d '-'} 100})
  25. case *-*
  26. GSPGLIST=($GSPGLIST `{seq `{echo $i|tr '-' ' '}})
  27. case *
  28. GSPGLIST=($GSPGLIST $i)
  29. }
  30. }
  31. GSPGLIST=$"GSPGLIST
  32. echo '
  33. /Page null def
  34. /Page# 0 def
  35. /PDFSave null def
  36. /DSCPageCount 0 def
  37. /DoPDFPage {dup /Page# exch store pdfgetpage pdfshowpage} def
  38. GS_PDF_ProcSet begin
  39. pdfdict begin
  40. ('^$1^') (r) file pdfopen begin
  41. /npage pdfpagecount def
  42. ['^$GSPGLIST^']
  43. {
  44. dup dup
  45. 1 ge exch npage le and
  46. { DoPDFPage }
  47. { pop }
  48. ifelse
  49. } forall
  50. ' | gs $GSOPT - >/dev/null >[2=1]
  51. }
  52. cat $GSTMPFILE
  53. rm -f $GSTMPFILE
  54. rm -f /tmp/pdf2ps.ps
  55. exit ''