home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / local / bin / rtf2pdf.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2003-04-04  |  2.3 KB  |  101 lines

  1. #!/bin/sh
  2.  
  3. ########################################################################
  4. #
  5. #  Convert an rtf document to pdf format using 'Ted' and 'GhostScript'.
  6. #
  7. #  Usage    rtf2pdf.sh --paper paper something.rtf something.pdf
  8. #  Or        rtf2pdf.sh something.rtf something.pdf
  9. #
  10. #  Valid values for paper are a4, a5, a6, letter, legal and executive
  11. #
  12. #  This is an example. Refer to http://www.nllgg.nl/Ted/index.html for the
  13. #  'Ted' documentation.
  14. #
  15. #  If you want 'Ted' to use X11 configurable resources, use
  16. #  Ted ++printToFilePaper ... In conjuction with X11 resources, the 
  17. #  standard X11 command line arguments to set resources can be practical. E.G:
  18. #  Ted -xrm Ted.usePostScriptFilters:1 -xrm Ted.usePostScriptIndexedImages:1 
  19. #    ++printToFilePaper .....
  20. #
  21. #  The file /usr/share/ghostscript/version/doc/Ps2pdf.htm documents 
  22. #  many settings for ghostscript that influence the generation of pdf.
  23. #  The actual meaning of the parameters is explained in Adobe technical 
  24. #  note #5151: "Acobat Distiller Parameters". With some effort, note #5151 
  25. #  can be found using the search facility on www.adobe.com.
  26. #
  27. #  To disable jpeg compression of 8 bit per component images:
  28. #      -dAutoFilterColorImages=false -dEncodeColorImages=false
  29. #  or
  30. #      -dAutoFilterColorImages=false -sColorImageFilter=FlateEncode
  31. #  to enable: (default)
  32. #      -dAutoFilterColorImages=true
  33. #
  34. #  To produce uncompressed pdf:
  35. #      -dCompressPages=false
  36. #  To produce compressed pdf: (default)
  37. #      -dCompressPages=true
  38. #
  39. #  Depending on your temper, you could also have a look at the pdfopt script
  40. #
  41. ########################################################################
  42.  
  43. PAPER=
  44.  
  45. case $# in
  46.     2)
  47.     ;;
  48.     4)
  49.     case $1 in
  50.         --paper)
  51.         ;;
  52.         *)
  53.         echo $0: '$1='$1 'Expected --paper'
  54.         exit 1
  55.         ;;
  56.     esac
  57.  
  58.     case $2 in
  59.         a4|a5|a6|letter|legal|executive)
  60.         PAPER=$2
  61.         ;;
  62.         *)
  63.         echo $0: '$2='$2 'Expected a4|a5|a6|letter|legal|executive'
  64.         exit 1
  65.         ;;
  66.     esac
  67.     shift; shift;
  68.     ;;
  69.     *)
  70.     echo $0: '$#='$#
  71.     exit 1
  72.     ;;
  73. esac
  74.  
  75. case $PAPER in
  76.     ?*)
  77.     Ted --printToFilePaper $1 /tmp/$$.ps $PAPER
  78.  
  79.     gs -q    -dNOPAUSE                \
  80.         -sDEVICE=pdfwrite            \
  81.         -sPAPERSIZE=$PAPER            \
  82.         -sOutputFile=$2                \
  83.         /tmp/$$.ps                \
  84.         -c quit
  85.  
  86.     rm /tmp/$$.ps
  87.     ;;
  88.     *)
  89.     Ted --printToFile $1 /tmp/$$.ps
  90.  
  91.     gs -q    -dNOPAUSE                \
  92.         -sDEVICE=pdfwrite            \
  93.         -sOutputFile=$2                \
  94.         /tmp/$$.ps                \
  95.         -c quit
  96.  
  97.     rm /tmp/$$.ps
  98.     ;;
  99. esac
  100.  
  101.