🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #3213

More on the DRAFT problem: gray obscures underlying text

#3213
From: Michael J Wargo
Date: Thu, 27 Sep 1990 23:31
167 lines
5488 bytes
Thanks to all who responded to my request for a way to 
put the word "DRAFT" on pages of a postscript document.
Just about everything went great.  

Here's the *but*.  Following is the script that I decided to
use.  This particular solution was chosen because it will 
accept input from a pipe and, as a result, can be hacked 
into a printcap entry.  The problem I encountered was traced
to a point near the end.  I'll continue the description 
down there.  Do a couple of "next page"s now.

BTW, thanks to Tom and all who responded!


*********** BEGIN INCLUDED 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 OF INCLUDED SCRIPT ***************


Welcome back!  The problem concerns the ordering of the 
stuff indicated by         in the above lines.
                   ^^^^^^^ 
When used in the order listed, the printed text does not have a
"DRAFT" superposed on it... It appears just as it would
with no modification.  However, if oldshow is reversed 
with DRAFTTYPE (likewise, oldcopy and DRAFTTYPE in the
following line) it works just fine.  So what's the problem,
you say?  Well when you use the -1 flag to get a gray
"DRAFT", the "DRAFT" is printed over the underlying text,
thus obscuring it.  

So, finally :-), Is there a way to get things to print
so that the text is printed *over* the gray "DRAFT" so that
the text is still readable?  If it matters, the postscript
is produced by Interleaf 4.0.74 running on a Sun 4/280,
SunOS 4.0.1 with Transcript.

Again, please respond by e-mail and I will summarize.
This group is great!


					Thanks a ton,
					Mike Wargo

		preferred ---------->	michael@agricola.mit.edu
					mjwargo@athena.mit.edu
Technical Details
Message-ID: <1990Sep27.233137.13302@athena.mit.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!paperboy!snorkelwacker!bloom-beacon!athena.mit.edu!mjwargo

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!paperboy!snorkelwacker!bloom-beacon!athena.mit.edu!mjwargo
From: mjwargo@athena.mit.edu (Michael J Wargo)
Newsgroups: comp.lang.postscript
Subject: More on the DRAFT problem: gray obscures underlying text
Message-ID: <1990Sep27.233137.13302@athena.mit.edu>
Date: 27 Sep 90 23:31:37 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: 167