<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 - Discussions by JBanta</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Niners/JBanta/Discussions/RSS"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 - Discussions by JBanta</title>
		<link>http://channel9.msdn.com/Niners/JBanta/Discussions</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Niners/JBanta/Discussions</link>
	<language>en</language>
	<pubDate>Sun, 26 May 2013 06:45:27 GMT</pubDate>
	<lastBuildDate>Sun, 26 May 2013 06:45:27 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>0</c9:totalResults>
	<c9:pageCount>0</c9:pageCount>
	<c9:pageSize>0</c9:pageSize>
	<item>
		<title>Tech Off - ASP.NET and iTextSharp (free PDF Generator for .NET)</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Filth said:</div><div class="quoteText">
<p>Hi,</p>
<p>I've just starting using iTextSharp in a code behind page, but when I run it, it just shows a&nbsp;empty pdf.</p>
<p>I was wondering if anyone could see anything crazy that I have or haven't done?<br /><br />The code in my page_load event is:<br /><br /></p>
<p></p>
MemoryStream m = new MemoryStream();
<p></p>
<p>Document document = new Document(PageSize.A4.Rotate(), 10, 10, 10, 10);</p>
<p>try </p>
<p>{</p>
<p>Response.ContentType = &quot;application/pdf&quot;;</p>
<p>PdfWriter.GetInstance(document, m);</p>
<p></p>
<p>document.Open();</p>
<p></p>
<p>document.Add(new Paragraph(DateTime.Now.ToString()));</p>
<p>document.Add(new Paragraph(&quot;This is another test&quot;));</p>
<p>document.Add(new Paragraph(&quot;Yet another test&quot;));</p>
<p>} </p>
<p>catch (DocumentException ex) </p>
<p>{</p>
<p>Console.Error.WriteLine(ex.StackTrace);</p>
<p>Console.Error.WriteLine(ex.Message);</p>
<p>}</p>
<p>// step 5: Close document</p>
<p>document.Close();</p>
<p>// step 6: Write pdf bytes to outputstream</p>
<p>Response.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer().Length);</p>
<p>Response.OutputStream.Flush();</p>
<p>Response.OutputStream.Close();</p>
</div></blockquote>You are trying to use iTextSharp in a web application so you can use ASP.NET's response stream directly to write the PDF.&nbsp; Your code would look something like:<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Response.ContentType = &quot;application/pdf&quot;;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Document doc = new Document();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PdfWriter writer = PdfWriter.GetInstance( doc, this.Response.OutputStream );<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doc.Open();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doc.Add( new Paragraph( DateTime.Now.ToString() ) );<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doc.Add( new Paragraph( &quot;This is a test&quot; ) );<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; finally<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doc.Close();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer.Close();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/117199-ASPNET-and-iTextSharp-free-PDF-Generator-for-NET/74fbe3e7b2ae4bdba3d59dea012bbafc#74fbe3e7b2ae4bdba3d59dea012bbafc</link>
		<pubDate>Mon, 20 Oct 2008 22:43:53 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/117199-ASPNET-and-iTextSharp-free-PDF-Generator-for-NET/74fbe3e7b2ae4bdba3d59dea012bbafc#74fbe3e7b2ae4bdba3d59dea012bbafc</guid>
		<dc:creator>JBanta</dc:creator>
		<slash:comments>79</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/JBanta/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>