home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 2: PC / frozenfish_august_1995.bin / bbs / d07xx / d0797.lha / PSUtils / psnup < prev    next >
Text File  |  1993-01-10  |  2KB  |  72 lines

  1. #!/bin/sh
  2. # psnup: put multiple pages onto one physical sheet of paper.
  3. # usage:
  4. #       psnup [-w<dim>] [-h<dim>] [-l] [-2|-4|-8|-9] [file...]
  5. #               -w<dim> sets the paper width
  6. #               -h<dim> sets the paper height
  7. #               -l      is used if the pages are in landscape orientation
  8.  
  9. io= landscape=0 nup=1 width=-w21cm height=-h29.7cm
  10.  
  11. while test $# != 0
  12. do      case "$1" in
  13.         -w*)    width=$1 ;;
  14.         -h*)    height=$1 ;;
  15.         -l)     landscape=1 ;;
  16.         -2)     nup=2 ;;
  17.         -4)     nup=4 ;;
  18.         -8)     nup=8 ;;
  19.         -9)     nup=9 ;;
  20.         *)      io="$io $1"
  21.         esac
  22.         shift
  23. done
  24.  
  25. scale= offset=
  26. case "$nup" in
  27. 2)      scale=@0.707
  28.         if [ $landscape = 0 ]
  29.         then offset="(1w,0) (1w,0.5h)"
  30.         else offset="(0,0.5h) (0,0)"
  31.         fi
  32.         landscape=`expr 1 - $landscape` ;;
  33. 4)      scale=@0.5
  34.         if [ $landscape = 0 ]
  35.         then offset="(0,0.5h) (0.5w,0.5h) (0,0) (0.5w,0)"
  36.         else offset="(0.5w,0) (0.5w,0.5h) (1w,0) (1w,0.5h)"
  37.         fi ;;
  38. 8)      scale=@0.3536
  39.         if [ $landscape = 0 ]
  40.         then offset="(0.5w,0) (0.5w,0.25h) (0.5w,0.5h) (0.5w,0.75h)\
  41.                      (1w,0) (1w,0.25h) (1w,0.5h) (1w,0.75h)"
  42.         else offset="(0,0.75h) (0.5w,0.75h) (0,0.5h) (0.5w,0.5h)\
  43.                      (0,0.25h) (0.5w,0.25h) (0,0.25h) (0.5w,0.25h)"
  44.         fi
  45.         landscape=`expr 1 - $landscape` ;;
  46. 9)      scale=@0.3333
  47.         if [ $landscape = 0 ]
  48.         then offset="(0,0.666h) (0.333w,0.666h) (0.666w,0.666h)\
  49.                      (0,0.333h) (0.333w,0.333h) (0.666w,0.333h)\
  50.                      (0,0) (0.333w,0) (0.666w,0)"
  51.         else offset="(0.333w,0) (0.333w,0.333h) (0.333w,0.666h)\
  52.                      (0.666w,0) (0.666w,0.333h) (0.666w,0.666h)\
  53.                      (1w,0) (1w,0.333h) (1w,0.666h)"
  54.         fi ;;
  55. esac
  56.  
  57. if [ $landscape = 0 ]
  58. then rotate=
  59. else rotate=L
  60. fi
  61.  
  62. options= sep= page=0
  63.  
  64. set -- ${offset:-""}
  65. while [ $page -lt $nup ]
  66. do      options="$options${options:++}$page$rotate$scale$1"
  67.         page=`expr $page + 1`
  68.         shift
  69. done
  70.  
  71. pstops $width $height "$nup:$options" $io
  72.