[comp.lang.postscript] ps commands to print "DRAFT"

yahnke@vms.macc.wisc.edu (Ross Yahnke, MACC) (07/03/90)

August 1990 MacUser had a tip on how to print the large word "DRAFT"
over a document, using a PS escape font. I've sort of gotten it to
work in Nisus, only problem is the word "DRAFT" obscures the
underlying text - unlike the example in the magazine. Can anybody
suggest what must be done to make the word "DRAFT" transparent?
Here's the code, thanks!:

gsave

initgraphics

/font /Helvetica-Bold def
/pointsize 100 def
/text (DRAFT) def

/center {dup stringwidth pop
2 div neg 0 rmoveto} def
306 396 moveto
90 setgray
font findfont pointsize scalefont setfont
45 rotate
24 0 text center ashow
grestore

>>> yahnke@macc.wisc.edu <<<

glenn@heaven.woodside.ca.us (Glenn Reid) (07/04/90)

In article <3937@dogie.macc.wisc.edu> yahnke@vms.macc.wisc.edu (Ross Yahnke, MACC) writes:
>August 1990 MacUser had a tip on how to print the large word "DRAFT"
>over a document, using a PS escape font. I've sort of gotten it to
>work in Nisus, only problem is the word "DRAFT" obscures the
>underlying text - unlike the example in the magazine. Can anybody
>suggest what must be done to make the word "DRAFT" transparent?

You have to draw the word "DRAFT" before you start drawing the page.
It's not really transparent, it's underneath the rest of the text.
You can do this by redefining "showpage" to image your DRAFT notice
after it's done printing the page, but you still have to prime the
pump so it works on the first page.  Try something like this:

	/DRAFT {
	    % draft code here
	} def
	
	/orig_showpage /showpage load def
	
	/showpage {
	    orig_showpage
	    DRAFT
	} def

Then make sure you put one call to DRAFT at the beginning, before the
first page executes.

Note that this will not work as you expect in the event that the
application paints the page white before it starts drawing text.  It
will white out your DRAFT notice, too.  I'm not sure why programs do
this, but it's not that uncommon.

I have gotten around this in the past by making the DRAFT notice actually
print along the edge of the paper, right where you would flip the pages
with your thumb, rather than being large and in the middle of the page.
If you put a continuous border of "DRAFT DRAFT DRAFT DRAFT" around the
page, it works pretty well and stays out of the way of the rest of the
page.

Cheers,
 Glenn

-- 
 Glenn Reid				PostScript/NeXT consultant
 glenn@heaven.woodside.ca.us		One-day turnaround on many projects
 ..{adobe,next}!heaven!glenn		Unparalleled Quality

philip@pescadero.Stanford.EDU (Philip Machanick) (07/05/90)

In article <196@heaven.woodside.ca.us>, glenn@heaven.woodside.ca.us
(Glenn Reid) writes:
> In article <3937@dogie.macc.wisc.edu> yahnke@vms.macc.wisc.edu (Ross
Yahnke, MACC) writes:
> >August 1990 MacUser had a tip on how to print the large word "DRAFT"
> >over a document, using a PS escape font. I've sort of gotten it to
> >work in Nisus, only problem is the word "DRAFT" obscures the
> >underlying text - unlike the example in the magazine. Can anybody
> >suggest what must be done to make the word "DRAFT" transparent?
> 
> You have to draw the word "DRAFT" before you start drawing the page.
> It's not really transparent, it's underneath the rest of the text.
> You can do this by redefining "showpage" to image your DRAFT notice
> after it's done printing the page, but you still have to prime the
> pump so it works on the first page.  Try something like this:
[sample code plus various hints on how to make it work]

Excuse my ignorance, but what's wrong with simply putting the PS
before anything else that prints on the page? This may not always
be possible, but most word processors presumably print from top to
bottom (I don't know Nisus), so you just put your PostScript first
(assuming "a PS escape font" means you just embed PS in your text).
Some DTP packages allow you to "send to back", which is even more
explicit. Of course, none of this will work if the word processor
whites out underneath itself, as Glenn observed, but then neither
will his approach (without changing the stragey, again as he noted).

Philip Machanick
philip@pescadero.stanford.edu

yahnke@vms.macc.wisc.edu (Ross Yahnke, MACC) (07/05/90)

Thanks for all the replies! Turns out that I was issueing the
ps commands in my document footer so naturally it painted the
word DRAFT on top of the already printed text. So I switched it
to the header and it works fine there.

>>> yahnke@macc.wisc.edu <<<

zben@umd5.umd.edu (Ben Cranston) (07/06/90)

In article <3937@dogie.macc.wisc.edu> yahnke@vms.macc.wisc.edu
(Ross Yahnke, MACC) writes:

> August 1990 MacUser had a tip on how to print the large word "DRAFT"
> over a document, using a PS escape font. I've sort of gotten it to
> work in Nisus, only problem is the word "DRAFT" obscures the
> underlying text - unlike the example in the magazine. Can anybody
> suggest what must be done to make the word "DRAFT" transparent?
> Here's the code, thanks!:

> gsave
> initgraphics
> /font /Helvetica-Bold def
> /pointsize 100 def
> /text (DRAFT) def
> /center {dup stringwidth pop
> 2 div neg 0 rmoveto} def
> 306 396 moveto
> 90 setgray
  ==  I certainly hope this is a mistype of .9 !!!
> font findfont pointsize scalefont setfont
> 45 rotate
> 24 0 text center ashow
> grestore

Anyway, here's my current slashed banner program, the gore is to avoid
having to have magic constants like 306 and 396 for each different page size.

%!-Adobe-1.0
%%Title: smudge.ps
%%Creator: Ben Cranston <zben@umd2.umd.edu>
%%CreationDate: June 12, 1990
%%Pages 0
% Print a word or phrase in gray on every succeeding page

/smudgepage {
    gsave
	(BUSHLIPS) .95 /Helvetica-Bold
	findfont dup setfont clippath pathbbox
	dup 3 index add 2 div 5 1 roll 1 index 4 index add 2 div 6 1 roll
	3 -1 roll sub 3 1 roll exch sub exch 2 copy exch atan 3 1 roll
	dup dup mul 2 index dup mul add sqrt 3 1 roll 2 copy lt {exch} if div
	newpath 0 0 moveto 7 index true charpath pathbbox
	dup 3 index add 2 div 5 1 roll 1 index 4 index add 2 div 6 1 roll
	3 -1 roll sub 3 1 roll exch sub exch
	6 -2 roll 3 -1 roll mul 3 -1 roll add div dup 7 1 roll
	dup 4 -1 roll mul neg exch 3 -1 roll mul neg 3 -1 roll 5 -2 roll
	translate rotate moveto scalefont setfont setgray show
    grestore
} bind def

/showpage [
	/showpage load dup type (operatortype) ne {/exec load} if
	/smudgepage load /exec load
] cvx def
smudgepage

% (YOUR POSTSCRIPT GOES HERE)
-- 

Ben Cranston <zben@umd2.umd.edu>
Warm and Fuzzy Networking Group, Egregious State University
My cat is named "Perpetually Hungry Autonomous Carbon Unit"; I call him "Sam".

woody@chinacat.Unicom.COM (Woody Baker @ Eagle Signal) (07/06/90)

In article <3937@dogie.macc.wisc.edu>, yahnke@vms.macc.wisc.edu (Ross Yahnke, MACC) writes:
> August 1990 MacUser had a tip on how to print the large word "DRAFT"
> over a document, using a PS escape font. I've sort of gotten it to
> work in Nisus, only problem is the word "DRAFT" obscures the
> underlying text - unlike the example in the magazine. Can anybody
> suggest what must be done to make the word "DRAFT" transparent?
> Here's the code, thanks!:
> 
> gsave
> 
> >>> yahnke@macc.wisc.edu <<<
First of all, don't do initpage.  that is a NO NO.
The make sure that the draft routine gets called AT THE FIRST OF THE PAGE,
so that it gets layed down first.  Postscript uses an OPAQUE painting model
(unfortunatly that is *ALL* you get, there is no way to get quite the
same effect transparently).  At anyrate, by placing the DRAFT down
on the page first, then text will get put on top of it.  In addition, you 
should pick a fine, but light (very light) gray shade.  I like the one
Don uses,

106 45 {dup mul exch dup mul add 1.0 exch sub } setscreen

This establishes a fine gray...

Cheers
Woody