<?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 : Background Watermak and Stamping with Transparency</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 : Background Watermak and Stamping with Transparency]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Fri, 08 May 2026 06:09:59 +0000</pubDate>
  <lastBuildDate>Sun, 13 Jul 2014 06:31:26 +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=2934</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[Background Watermak and Stamping with Transparency : This demo code will draw transparent...]]></title>
   <link>http://www.quickpdf.org/forum/background-watermak-and-stamping-with-transparency_topic2934_post11854.html#11854</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.quickpdf.org/forum/member_profile.asp?PF=1483">AndrewC</a><br /><strong>Subject:</strong> 2934<br /><strong>Posted:</strong> 13 Jul 14 at 6:31AM<br /><br />This demo code will draw transparent background image (wotermark) and text on alternate pages. &nbsp;It shows how to create a new content stream, draw onto it, and then move the contentstream to the background layer.<div><br></div><div>To render the resulting PDF you will need to use the new Debenu Renderer in Debenu PDF Library 10.xx versions. &nbsp;Refer to the README.TXT in the "Rendering and Printing Add-On" folder in the DQPL installation directory.<br><div><br></div><div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int ret = QP.LoadFromFile("Debenu Quick PDF Library 10.15 Reference Guide.pdf", "");</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int imgId = QP.AddImageFromFile("DebenuLogo.bmp", 0);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int fontId = QP.AddStandardFont(4);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double angle = 30;</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 1; i &lt;= QP.PageCount(); i++) &nbsp;// Start at page 1.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SelectPage(i);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.NormalizePage(0); &nbsp; // Fix any page problems and remove rotation</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SetOrigin(1);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int csId = QP.NewContentStream(); &nbsp;// Create a new layer at the top that is drawn last.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SelectContentStream(csId); &nbsp; &nbsp;// Select the content stream</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SaveState(); &nbsp; // Save the graphics state.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SetTransparency(90);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Now draw something into the content stream.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (i % 2 == 0)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SelectImage(imgId);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.DrawImage(0, 0, QP.PageWidth(), QP.PageHeight());</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp;// Draw text</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SelectFont(fontId);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SetTextAlign(1); &nbsp; &nbsp; &nbsp; &nbsp; // Align text center</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SetTextSize(72);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SetTextColor(0, 0, 0);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.DrawRotatedText(QP.PageWidth() / 2 + 3, QP.PageHeight() / 2 + 3, angle, "www.debenu.com"); // Draw Watermark at center</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SetTextColor(0, 0, 1);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.DrawRotatedText(QP.PageWidth() / 2, QP.PageHeight() / 2, angle, "www.debenu.com"); // Draw Watermark at center</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double tx = QP.GetTextWidth("www.debenu.com") / 2 * Math.Cos(angle * Math.PI / 180);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double ty = QP.GetTextWidth("www.debenu.com") / 2 * Math.Sin(angle * Math.PI / 180);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double x, y, w, h;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double hx = QP.GetTextAscent() * Math.Sin(angle * Math.PI / 180);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double hy = QP.GetTextAscent() * Math.Cos(angle * Math.PI / 180);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = QP.PageWidth() / 2 - tx - hx;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = QP.PageHeight() / 2 - ty - hy;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w = tx * 2 + hx;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; h = ty * 2 + hy;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.AddLinkToWeb(x, y, w, h, "http://www.debenu.com", 0);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SetTextSize(132);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SetTextColor(1, 0, 0);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.DrawRotatedText(QP.PageWidth() / 2, QP.PageHeight() / 2 - 80, angle, "DEMO"); // Draw Watermark at center</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.LoadState(); &nbsp;// Restore the graphics state</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.MoveContentStream(csId, 1); &nbsp;// Move the new layer/contentstream to bottom so it is drawn first.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SaveToFile("out.pdf");</div></div><div><br></div></div>]]>
   </description>
   <pubDate>Sun, 13 Jul 2014 06:31:26 +0000</pubDate>
   <guid isPermaLink="true">http://www.quickpdf.org/forum/background-watermak-and-stamping-with-transparency_topic2934_post11854.html#11854</guid>
  </item> 
 </channel>
</rss>