Path: utzoo!attcan!uunet!snorkelwacker!bloom-beacon!athena.mit.edu!mjwargo From: mjwargo@athena.mit.edu (Michael J Wargo) Newsgroups: comp.lang.postscript Subject: More on DRAFT: gray obscures underlying text Message-ID: <1990Sep28.001025.13971@athena.mit.edu> Date: 28 Sep 90 00:10:25 GMT Sender: daemon@athena.mit.edu (Mr Background) Reply-To: mjwargo@athena.mit.edu (Michael J Wargo) Followup-To: comp.lang.postscript Organization: Massachusetts Institute of Technology Lines: 172 Thanks to everyone who responded to my request for a way to get "DRAFT" printed across the page along with the original text. Can you tell there's a *but* coming? Well, I chose to use the following script. I'm including the complete source since I only *think* I know where the problem occurs (way near the end!). Also, it may be just what other people are looking for :-). If you do a couple of "next page"s now, I'll show you what I think the problem is. BTW, Thanks to Tom for sending the original, and all the other folks for their ideas. I chose this particular solution since it will accept input from a pipe and, as a result, I could hack a printcap entry to include it. ************** BEGIN SCRIPT (with mail header) **************** Subject: Re: adding DRAFT to output To: mjwargo@ATHENA.MIT.EDU Date: Tue, 25 Sep 90 14:26:45 EDT From: bloom-beacon!think!rutgers!dvnspc1.dev.unisys.com!tom (Tom Albrecht) Organization: Unisys Corporation, Devon, PA X-Mailer: ELM [version 2.2 PL0] Message-Id: <9009251426.AA06496@dvnspc1.DEV.UNISYS.COM> Newsgroups: comp.lang.postscript In-Reply-To: <1990Sep24.213512.23889@athena.mit.edu> Organization: Unisys Corporation, Devon Engineering Offices Cc: Here is a solution that I acquired and hacked a bit. #! /bin/sh # # Put the word "DRAFT" (or a specified word) on each page of a postscript # document. # # Usage: # cat ps.file ... | draft.ps [type] [text] | lp -dps # # where type: -0 = solid outline block letters (default) # -1 = gray solid block letters # -2 = dashed outline block letters # # Author: Spencer W. Thomas # Computer Science Dept. # University of Utah # (Now spencer@crim.eecs.umich.edu) # modified by cplai for printcap use, added cover page # modified by Tom Albrecht (tom@dvnspc1.Dev.Unisys.COM) for gray # and dashed outline lettering # # Insert header after first line that does not begin %% or %! # trap "rm -f /tmp/psd$$.*" 0 1 2 15 # edit string for different printer names printerstr=psd filterstr=`basename $0` draftstring=DRAFT drafttype=DRAFT while [ "x$1" != "x" ] ; do if [ "x$1" = "x-0" ] ; then drafttype=DRAFT elif [ "x$1" = "x-1" ] ; then drafttype=DRAFTGRAY elif [ "x$1" = "x-2" ] ; then drafttype=DRAFTGRAYOL else draftstring=$* break fi shift done loginstr=UNKNOWN hoststr=UNKNOWN # Create sed script file sed -e "s/(DRAFT)/($draftstring)/" \ -e "s/DRAFTTYPE/$drafttype/" <<'EOF' >/tmp/psd$$.sed 1,/^[^%]/{ s/^%/%/ s/^$// t skip i\ % Prelude to show a draft string on every page.\ (DRAFT)\ /DRAFTDICT 12 dict def\ DRAFTDICT begin\ /DRAFTSTRING exch def\ /bd /Helvetica-Bold findfont def\ /od bd maxlength 1 add dict def\ bd {exch dup /FID ne {exch od 3 1 roll put} {pop pop} ifelse} forall\ od /FontName /Outline0 put od /PaintType 2 put od /StrokeWidth 0 put\ /Outline0 od definefont pop\ /DRAFT { gsave\ initmatrix\ /Outline0 findfont setfont\ DRAFTSTRING dup stringwidth pop 8.875 exch div dup 72 mul dup scale\ 52.3 rotate 2.5 exch div -.35 translate\ 0 0 moveto show\ grestore } def\ /DRAFTGRAY { gsave\ initmatrix\ /Helvetica-Bold findfont setfont\ 0.98 setgray\ DRAFTSTRING dup stringwidth pop 8.875 exch div dup 72 mul dup scale\ 52.3 rotate 2.5 exch div -.35 translate\ 0 0 moveto show\ grestore } def\ /DRAFTGRAYOL { gsave\ initmatrix\ /Outline0 findfont setfont\ 0.5 setgray\ DRAFTSTRING dup stringwidth pop 8.875 exch div dup 72 mul dup scale\ 52.3 rotate 2.5 exch div -.35 translate\ 0 0 moveto show\ grestore } def\ /oldshow /showpage load def\ /oldcopy /copypage load def\ end\ /showpage { DRAFTDICT begin oldshow DRAFTTYPE end } def\ <-- PROBLEM??? ^^^^^^^ ^^^^^^^^^ /copypage { DRAFTDICT begin oldcopy DRAFTTYPE end } def\ <-- PROBLEM??? ^^^^^^^ ^^^^^^^^^ DRAFTDICT begin DRAFTTYPE end\ % End of draft prelude : skip } EOF sed -f /tmp/psd$$.sed **************** END SCRIPT ****************************** The problem appears to be in the ordering of the "oldshow" and "DRAFTTYPE" (and likewise, oldcopy and DRAFTTYPE) in the above lines. In the order given above, after running the script on a postscript file and printing the result, only the original text prints. However, if the reverse order (e.g. DRAFTTYPE oldshow) is used, magically the word "DRAFT" appears. So, what's the problem, you say? Well, when the -1 (DRAFTGRAY) option is used to set "DRAFT" in gray, the underlying text is obscured. So, finally :-)... Is there a way to use this script to have the gray "DRAFT" appear behind the original text so that the text is readable? HW/SW setup: Sun 4/280 SunOS 4.0.1 Interleaf 4.0.74 (ps code produced by pl2ps) Apple LaserWriter II NT Transcript Sorry this post was so long, but I thought the full source of the script might be important. Thanks for all your help; this group is great! Please respond by e-mail and I'll summarize. (Assuredly, much shorter than the above!) Mike Wargo preferred ---> michael@agricola.mit.edu mjwargo@athena.mit.edu