Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Watermarking a PDF

Status
Not open for further replies.

ChrisRChamberlain

Programmer
Mar 23, 2000
3,392
GB
Hi

The following code watermarks a .pdf file when added to the front of a .ps file.

%!
% ==================================================================== draft.ps
% Redefine showpage so "DRAFT" is printed in gray on all pages. To
% change the intensity of the message, change the number in front of the
% command "setgray" 0=black, 1=white. Use real value in between.
%
% - Kevin O. Grover, <EMAIL: PROTECTED>
% Wed 06 May 1992 - Original Version
%
% Simply append this file to the begining of a PostScript file you want to
% have printed with the letters in the background.
%
% Usage: cat dsf.ps file.ps | lpr
% =============================================================================

% Define a Dictionary to keep the definitions in

/ShowDict 2 dict def

ShowDict begin
/oldshowpage /showpage load def % Save old showpage command

/draft { % Command to place DRAFT on page
gsave
/Helvetica-Bold findfont 220 scalefont setfont
.85 setgray 130 70 moveto 50 rotate (DRAFT) show
grestore
} bind def
end

% Redefine showpage (using command defined in ShowDict)

/showpage { ShowDict begin oldshowpage draft end } bind def

ShowDict begin draft end % So the first page has the text


It begins at the second page, not the first - what's missing to get it to start at page one?

HTH

Chris [pc2]
 
Hi Chris.

Your example is the wrong way to do that sort of thing. PostScript has the BeginPage and EndPage structures specifically for page-level effects. Here is your code re-written the &quot;right&quot; way:

<<
/BeginPage
{ gsave
/Helvetica_Bold 220 selectfont
.85 setgray 130 70 moveto 50 rotate (DRAFT) show
grestore
} bind
>> setpagedevice

50 100 moveto (This is Page 1) /Times-Roman 24 selectfont show
showpage

50 100 moveto (This is Page 2) /Times-Roman 24 selectfont show
showpage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top