Exporting Page Data to PDF and Excel in asp.net where data is generated dynamically
<p>For PDF:
I have wrote some code for the page content exporting to PDF.
And Complete design code is under Content Place Holder in design page.
As the data is generated dynamically, it is little tough to handle.
After this code im getting following error at htmlworker.Parse(str);
as Input string was not in a correct format
Can please help on this?</p>

<pre><code>protected void btnExpPDF_Click1(object sender, EventArgs e)
{
    //string attachment = "attachment; filename=CFSSurveyPage.pdf";
    Response.ClearContent();
    // Response.AddHeader("content-disposition", "attachment; filename=" + strFileName + ".xls");
    Response.AddHeader("content-disposition", "attachment; filename=" + "CFSSurveyPage" + ".pdf");
    Response.ContentType = "application/pdf";
    StringWriter stw = new StringWriter();
    HtmlTextWriter htextw = new HtmlTextWriter(stw);
    this.Page.Form.Controls[7].RenderControl(htextw);
    // (this.Page.Master.Controls[3].Controls[7].Controls[47]).RenderControl(htextw);
    //div2.RenderControl(htextw);
    StringReader str = new StringReader(stw.ToString());
    Document document = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
    HTMLWorker htmlworker = new HTMLWorker(document);
    PdfWriter.GetInstance(document, Response.OutputStream);
    document.Open();
    htmlworker.Parse(str);
    document.Close();
    Response.Write(document);
    Response.End();
}

public override void VerifyRenderingInServerForm(Control control)
{

}
</code></pre>
