<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>Debenu Quick PDF Library - PDF SDK Community Forum : PHP Watermark Sample</title>
  <link>http://www.quickpdf.org/forum/</link>
  <description><![CDATA[This is an XML content feed of; Debenu Quick PDF Library - PDF SDK Community Forum : Sample Code : PHP Watermark Sample]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Fri, 08 May 2026 06:02:53 +0000</pubDate>
  <lastBuildDate>Fri, 09 Apr 2010 06:55:34 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 11.01</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.quickpdf.org/forum/RSS_post_feed.asp?TID=1406</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Debenu Quick PDF Library - PDF SDK Community Forum]]></title>
   <url>http://www.quickpdf.org/forum/forum_images/QPDF_Forum_Title.png</url>
   <link>http://www.quickpdf.org/forum/</link>
  </image>
  <item>
   <title><![CDATA[PHP Watermark Sample :  This is probably not the cleanest...]]></title>
   <link>http://www.quickpdf.org/forum/php-watermark-sample_topic1406_post6350.html#6350</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.quickpdf.org/forum/member_profile.asp?PF=1293">Jimeni</a><br /><strong>Subject:</strong> 1406<br /><strong>Posted:</strong> 09 Apr 10 at 6:55AM<br /><br />This is probably not the cleanest example but there is a lack of PHP examples about so it might be useful.<br>It takes paremeters from a form and collects the variables passed and adds the required watermark to all pages of the PDF.<br><br>&lt;?php<br><br>/*<br>$Watermark = "Watermark Text";<br>$EPCN = "Extra Text bottom right";<br>$FilePath = "C:\AM4370_1_0.pdf";<br>*/<br><br>$Watermark = $_REQUEST&#091;'TextStamp'&#093;;<br><br>$EPCN = $_REQUEST&#091;'EPCN'&#093;;<br><br>$FilePath = $_REQUEST&#091;'FilePath'&#093;;<br><br>$OutputPath = $_REQUEST&#091;'OutputPath'&#093;;<br><br><br><br>$qp = new COM("QuickPDFAX0718.PDFLibrary");<br>$validKey = $qp-&gt;UnlockKey("<i><b>YourKey</b></i>");<br><br><br><br>$qp-&gt;SetMeasurementUnits(1); /* Set as measured in mm */<br>echo $r = $qp-&gt;LoadFromFile($FilePath);<br><br>$intPageCount = 1;<br>for ( $qp-&gt;SelectPage($intPageCount); $intPageCount &lt;= $qp-&gt;PageCount; $intPageCount ++) { /* Loop through all pages in doc */<br>&nbsp;&nbsp;&nbsp; $qp-&gt;SelectPage($intPageCount); <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; $pageheight&nbsp; = $qp-&gt;PageHeight;<br>&nbsp;&nbsp;&nbsp; $pagewidth = $qp-&gt;PageWidth;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; $myheight = (($pageheight/2) - ($pageheight * .05)); /* Define center - 5% of height to accomodate angle */<br>&nbsp;&nbsp;&nbsp; $mywidth = ($pagewidth/2);<br>&nbsp;&nbsp;&nbsp; $WatermarkSize = ( ($myheight + $mywidth) / strLen($Watermark) ); /* This should calc the correct text size relative to the document and amount of text */<br>&nbsp;&nbsp;&nbsp; $EPCNTextSize = ( ($myheight + $mywidth) / 60 );<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; $qp-&gt;SetTextAlign(1);/* Align text center */<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; $qp-&gt;SetTransparency(70);<br>&nbsp;&nbsp;&nbsp; $qp-&gt;SetTextSize($WatermarkSize);<br>&nbsp;&nbsp;&nbsp; echo $r = $qp-&gt;DrawRotatedText($mywidth, $myheight, 45, $Watermark); /* Draw Watermark at center */<br>&nbsp;&nbsp;&nbsp; $qp-&gt;SetTextAlign(2); /* Align text right */<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; $qp-&gt;SetTransparency(0);<br>&nbsp;&nbsp;&nbsp; $qp-&gt;SetTextSize($EPCNTextSize);<br>&nbsp;&nbsp;&nbsp; echo $r = $qp-&gt;DrawText($pagewidth -20, 1, "Open EPCN Number: " . $EPCN); /* Draw EPCN at bottom right with 20 padding */<br><br>}<br><br>$result = $qp-&gt;SaveToFile($OutputPath);<br>if ($result == 1)<br>{<br>&nbsp;&nbsp;&nbsp; header("Location: /Output/MyTest2.pdf"); /* Forward the browser straight to the generated PDF */<br>}<br>else<br>{<br>&nbsp;&nbsp;&nbsp; echo "File could not be saved to disk.";<br>&nbsp;&nbsp;&nbsp; echo "&lt;br /&gt;&lt;br /&gt;";<br>}<br>$qp = null;<br><br><br>?&gt;<br><span style="font-size:10px"><br /><br />Edited by Jimeni - 09 Apr 10 at 6:56AM</span>]]>
   </description>
   <pubDate>Fri, 09 Apr 2010 06:55:34 +0000</pubDate>
   <guid isPermaLink="true">http://www.quickpdf.org/forum/php-watermark-sample_topic1406_post6350.html#6350</guid>
  </item> 
 </channel>
</rss>