home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / ps / psdraft.zoo / psdraft
Text File  |  1990-11-22  |  3KB  |  128 lines

  1. =--==--===--====--=====--======--=======--======--=====--====--===--==--=
  2. #!/bin/sh
  3. # This is a shell archive.  Remove anything before this line, then
  4. # unpack it by saving it in a file and typing "sh file".  (Files
  5. # unpacked will be owned by you and have default permissions.)
  6. #
  7. # This archive contains:
  8. # psdraft
  9.  
  10. echo x - psdraft
  11. sed -e 's/^X//' > "psdraft" << '//E*O*F psdraft//'
  12. X#! /bin/sh
  13. X#
  14. X# Put the word "DRAFT" (or a specified word) on each page of a postscript
  15. X# document.
  16. X#
  17. X# Usage:
  18. X#     psdraft -s draftstring file ...
  19. X#
  20. X#
  21. X# Author: Spencer W. Thomas
  22. X#      Computer Science Dept.
  23. X#      University of Utah
  24. X#      thomas@cs.utah.edu
  25. X#
  26. X# Augmented to do grey string, choose font by:
  27. X#        James H. Cloos, Jr.
  28. X# currently @    Milard Filmore College
  29. X#        State University of New York @ Buffalo
  30. X#        cloos@ACSU.Buffalo.EDU ; cloos@ub.UUCP
  31. X#
  32. X
  33. X#
  34. X# Insert header after first line that does not begin %% or %!
  35. X#
  36. X
  37. Xtrap "rm -f /tmp/psd$$.*" 0 1 2 15
  38. X
  39. Xdraftstring=DRAFT
  40. Xgreylevel=.85
  41. Xdogrey=DRAFTO
  42. Xfont=Helvetica-Bold
  43. Xdodrafto=DRAFTO
  44. Xdodraftg=
  45. X
  46. Xwhile getopts s:g:f: cc
  47. Xdo
  48. X    case $cc in
  49. X    s) draftstring=$OPTARG;;
  50. X    g) greylevel=$OPTARG
  51. X        dodrafto=
  52. X        dodraftg=DRAFTG ;;
  53. X    f) font=$OPTARG;;
  54. X    \?) echo "Usage: psdraft [-s draftstring] files ..."
  55. X        exit 2;;
  56. X    esac
  57. Xdone
  58. X
  59. Xshift `expr $OPTIND - 1`
  60. X
  61. X# Create sed script file
  62. X
  63. Xsed -e "s/(DRAFT)/($draftstring)/" \
  64. X-e "s/(GREYLEVEL)/$greylevel/" \
  65. X-e "s/ DODRAFTG / $dodraftg /" \
  66. X-e "s/ DODRAFTO / $dodrafto /" \
  67. X-e "s*/FONT*/$font*" <<'EOF' >/tmp/psd$$.sed
  68. X1,/^[^%]/{ 
  69. Xs/^%/%/
  70. Xs/^$//
  71. Xt skip
  72. Xi\
  73. X% Prelude to show a draft string on every page.\
  74. X(DRAFT)\
  75. X/DRAFTDICT 10 dict def\
  76. XDRAFTDICT begin\
  77. X/DRAFTSTRING exch def\
  78. X/bd /FONT findfont def\
  79. X/od bd maxlength 1 add dict def\
  80. Xbd {exch dup /FID ne {exch od 3 1 roll put} {pop pop} ifelse} forall\
  81. Xod /FontName /Outline0 put od /PaintType 2 put od /StrokeWidth 0 put\
  82. X/Outline0 od definefont pop\
  83. X/DRAFTO { gsave\
  84. X     initmatrix\
  85. X    /Outline0 findfont setfont\
  86. X    DRAFTSTRING dup stringwidth pop 8.875 exch div dup 72 mul dup scale\
  87. X    52.3 rotate 2.5 exch div -.35 translate\
  88. X    0 0 moveto show\
  89. X    grestore } def\
  90. X/DRAFTG { gsave\
  91. X     initmatrix\
  92. X    /FONT findfont setfont (GREYLEVEL) setgray\
  93. X    DRAFTSTRING dup stringwidth pop 8.875 exch div dup 72 mul dup scale\
  94. X    52.3 rotate 2.5 exch div -.35 translate\
  95. X    0 0 moveto show\
  96. X    grestore } def\
  97. X/oldshow /showpage load def\
  98. X/oldcopy /copypage load def\
  99. Xend\
  100. X/showpage { DRAFTDICT begin DODRAFTO oldshow DODRAFTG end } def\
  101. X/copypage { DRAFTDICT begin DODRAFTO oldcopy DODRAFTG end } def\
  102. X% End of draft prelude
  103. X: skip
  104. X}
  105. XEOF
  106. X
  107. Xcat $* | sed -f /tmp/psd$$.sed 
  108. //E*O*F psdraft//
  109.  
  110. echo Possible errors detected by \'wc\' [hopefully none]:
  111. temp=/tmp/shar$$
  112. trap "rm -f $temp; exit" 0 1 2 3 15
  113. cat > $temp <<\!!!
  114.       96     353    2169 psdraft
  115. !!!
  116. wc  psdraft | sed 's=[^ ]*/==' | diff -b $temp -
  117. exit 0
  118. -==--==---==----==-----==------==-------==------==-----==----==---==--==-
  119. Enjoy,
  120.  
  121. -JimC
  122. --
  123. James H. Cloos, Jr.        Phone:  +1 716 673-1250
  124. cloos@ACSU.Buffalo.EDU        Snail:  PersonalZipCode:  14048-0772, USA
  125. cloos@ub.UUCP            Quote:  <>
  126.  
  127.  
  128.