🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #7101

Re: psdraft

#7101
From: Ken Yap
Date: Wed, 27 Apr 1988 16:09
79 lines
2395 bytes
Thanks to all who sent me copies of psdraft and to Spencer Thomas for
writing it in the first place. Works great. Some of you asked me for
copies and I also made one small change to handle ()\ characters
correctly so I'm posting.

Next question. How do I make a transparent stipple? I tried doing 0.90
setgray then (string) show but it obscures the existing page contents.
I suppose I could lay the gray string first thing, but I see no
beginning of page operator I can redefine.

	Ken

#! /bin/sh
#
# Put the word "DRAFT" (or a specified word) on each page of a postscript
# document.
#
# Usage:
# 	psdraft -s draftstring file ...
#
# Author: Spencer W. Thomas
#	  Computer Science Dept.
#	  University of Utah
#	  (Now spencer@crim.eecs.umich.edu)

#
# Insert header after first line that does not begin %% or %!
#

trap "rm -f /tmp/psd$$.*" 0 1 2 15

if [ "x$1" = "x-s" ] ; then
	draftstring=`echo $2 | sed 's/[()\\\\]/\\\\&/g'`
	shift
	shift
else
	draftstring=DRAFT
fi

if [ "x$*" = "x" ] ; then
	echo "Usage: psdraft [-s draftstring] files ..."
fi

# Create sed script file

sed "s/(DRAFT)/($draftstring)/" <<'EOF' >/tmp/psd$$.sed
1,/^[^%]/{ 
s/^%/%/
s/^$//
t skip
i\
% Prelude to show a draft string on every page.\
(DRAFT)\
/DRAFTDICT 10 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\
/oldshow /showpage load def\
/oldcopy /copypage load def\
end\
/showpage { DRAFTDICT begin DRAFT oldshow end } def\
/copypage { DRAFTDICT begin DRAFT oldcopy end } def\
% End of draft prelude
: skip
}
EOF

cat $* | sed -f /tmp/psd$$.sed 
Technical Details
Message-ID: <9078@sol.ARPA>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!bbn!rochester!ken
References: <8996@sol.ARPA>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!bbn!rochester!ken
From: ken@cs.rochester.edu (Ken Yap)
Newsgroups: comp.lang.postscript
Subject: Re: psdraft
Message-ID: <9078@sol.ARPA>
Date: 27 Apr 88 16:09:02 GMT
References: <8996@sol.ARPA>
Reply-To: ken@cs.rochester.edu (Ken Yap)
Organization: U of Rochester, CS Dept, Rochester, NY
Lines: 79