<?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 : C# - Using AddImageFromString with Drawing.Imaging</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 : C# - Using AddImageFromString with Drawing.Imaging]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Fri, 08 May 2026 06:03:01 +0000</pubDate>
  <lastBuildDate>Wed, 20 Jun 2012 12:43:43 +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=2308</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[C# - Using AddImageFromString with Drawing.Imaging : Bitmap bmp = new Bitmap(&amp;#034;ThomasCook.bmp&amp;#034;);...]]></title>
   <link>http://www.quickpdf.org/forum/c-using-addimagefromstring-with-drawingimaging_topic2308_post9800.html#9800</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.quickpdf.org/forum/member_profile.asp?PF=1483">AndrewC</a><br /><strong>Subject:</strong> 2308<br /><strong>Posted:</strong> 20 Jun 12 at 12:43PM<br /><br /><div style="text-align: left;"><br></div><div style="text-align: left;"><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Bitmap bmp = new Bitmap("ThomasCook.bmp");</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Create a memory stream and save the bitmap to it</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stream st = new MemoryStream();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bmp.Save(st, System.Drawing.Imaging.ImageFormat.Bmp);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Convert the stream to a byte&#091;&#093; so we can use it with AddImageFromString</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; st.Position = 0;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; byte&#091;&#093; Buffer = new byte&#091;st.Length&#093;;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; st.Read(Buffer, 0, (int)st.Length);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; st.Dispose();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int id = QP.AddImageFromString(Buffer, 0);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SelectImage(id);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SetOrigin(1);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int dpix = QP.ImageHorizontalResolution();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int dpiy = QP.ImageVerticalResolution();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (dpix == 0) dpix = 96;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (dpiy == 0) dpiy = 96;</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int xx = QP.ImageWidth();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int yy = QP.ImageHeight();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double ImageWidthInPoints = (double)QP.ImageWidth() / dpix * 72.0; // assumming dpi units</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double ImageHeightInPoints = (double)QP.ImageHeight() / dpiy * 72.0;</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.DrawImage(0, 0, ImageWidthInPoints, ImageHeightInPoints);</div><div><br></div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Buffer = null;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GC.Collect();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QP.SaveToFile("out.pdf");</div><div><br></div></div>]]>
   </description>
   <pubDate>Wed, 20 Jun 2012 12:43:43 +0000</pubDate>
   <guid isPermaLink="true">http://www.quickpdf.org/forum/c-using-addimagefromstring-with-drawingimaging_topic2308_post9800.html#9800</guid>
  </item> 
 </channel>
</rss>