A watermark is any marking which appears behind the text of the page and is generally quite light in apprearence. The main text of the page should be legible above it, and the watermark should be visible beneath.
The PostScript
The PostScript for generating a watermark is quite simple.
After each %%Page: comment (and before the actual
PostScript code for the page, you should insert the code to draw the
watermark (safely wrapped between a
gsave and
grestore pair.
As a concrete example, let us say we want to print the word "Draft" down the page beneath the actual text of the page. Such a watermark would be suitable for printing drafts of documents.
Here is the PostScript code to print the watermark:
gsave .75 setgray /Helvetica-Bold findfont 72 scalefont setfont 80 80 800 { 306 exch moveto % move to the center of the line (Draft) dup stringwidth pop 2 div neg 0 rmoveto % Center the text horizontally show % Show the text } for % and keep doinging it grestore
And here is the PERL script to do the job:
#!/usr/local/bin/perl $flag = 0; while (<>) { if (/^%%Page:/) { if ($flag) { print "grestore\n"; } $flag = 1; print $_; print "gsave\n"; print ".75 setgray\n"; print "/Helvetica-Bold findfont 72 scalefont setfont\n"; print "80 80 800 { 306 exch moveto\n"; print "(Draft) dup\n"; print "stringwidth pop 2 div neg 0 rmoveto show } for\n"; print "grestore\n"; } else { print; } }