title: How to convert stringbuilder text and get pdf format file output in asp.net
body: <p>I'm using Visual Studio 2008 and I need to convert some stringbulider text and get pdf format output file on button click event..</p>
  
  <p>Following is sample stringbuilder text.</p>
  
  <pre><code>StringBuilder reqReport = new StringBuilder();
  reqReport.Append("&lt;li&gt;Five copies of your latest Passport size.&lt;/li&gt;");
  reqReport.Append("&lt;li&gt;Your certificates, testimonials etc. (in original with one photocopy)&lt;/li&gt;");
  reqReport.Append("&lt;li&gt;Residence &amp; Identity proof required in Bank account opening process as per RBI guidelines.&lt;/li&gt;");
  </code></pre>
  
  <p>I tried using itextsharp..</p>
  
  <pre><code>string html = reqReport.ToString();
  Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
  PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
  pdfDoc.Open();
  System.Xml.XmlTextReader _xmlr = new System.Xml.XmlTextReader(new StringReader(html));
  HtmlParser.Parse(pdfDoc, _xmlr);
  Response.ContentType = "application/pdf";
  Response.AddHeader("content-disposition", "attachment;filename=Table.pdf");
  Response.Cache.SetCacheability(HttpCacheability.NoCache);
  Response.Write(pdfDoc);
  Response.End();
  </code></pre>
  
  <p>This creates the pdf file.. But when I try to open the file, it shows the the file is either corrupted or damaged and could not be opened..</p>
  
  <p>Is there any other format to do the function..?</p>
  
  <p>Thanks in advance...</p>