<?xml version="1.0" encoding="windows-1252"?>
<node id="417803" title="Re^2: Add watermark to a pdf" created="2004-12-28 12:58:08" updated="2005-08-10 15:11:49">
<type id="11">
note</type>
<author id="241598">
holli</author>
<data>
<field name="doctext">
thank you for that "form"-hint. that was what i needed. i finally assembled a script which does &lt;b&gt;perfectly&lt;/b&gt; what i wanted to achieve:&lt;br&gt;&lt;br&gt;
i know that the string concatenation ($string) is a bit clumsy, but i wanted to add the comments. you cannot have comments in quotes, can you?&lt;br&gt;&lt;br&gt;
&lt;code&gt;
use strict;

use PDF::API2;
use PDF::Reuse;

# specify files
my $ifile = "c:/kopie/anlage-h-beg.pdf";
my $ofile = "c:/kopie/new.pdf";

#find out number of pages
my $ipdf  = PDF::API2-&gt;open($ifile);
my $nop   = $ipdf-&gt;pages;
$ipdf-&gt;end();

#set outfile for PDF::Reuse
prFile($ofile);

#get font
my $intName = prFont("Helvetica");

# assemble watermark text
my $string = 

# save graphic state
"q\n" .

# Begin Text
"BT\n" .

# set font and "size" 
"/$intName 1 Tf\n" .

# set a text matrix
# 1. width of text
# 2. rotation angle (counterclockwise)
# 3. inclination (clockwise)
# 4. height of text
# 5. position x (0=left)
# 6. position y (0=bottom)    
"180 60 -60 180 100 185 Tm\n" .        

#set rgb-color (values between 0 and 1)
#"1 0 0 rg" .

#set grayscale (white=1 black=0)
"0.9 g\n" .

# show text
"(Kopie) Tj\n" .

# End Text
"ET\n" .
"Q\n";


#loop over pages
for (my $i=1;$i&lt;=$nop;$i++)
{
	#add watermark	
	prAdd ($string);

	#add original content	
	my $internalName = prForm 
	( 
		{
			file     =&gt; $ifile,
			page     =&gt; $i,
			effect   =&gt; 'print',
			tolerant  =&gt; 'no'
		} 
	);
	
	#add pagebreak
	prPage;
}

#save and close
prEnd();
&lt;/code&gt;</field>
<field name="root_node">
417718</field>
<field name="parent_node">
417766</field>
</data>
</node>
