Click here to Skip to main content
15,918,706 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?

XML
Design Page:

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="CPH1">
<div id="MyDiv" style="background-color: #DDE3EC;">
 <table>
Some code
 </table>
 <table>
<tr>
            <td style="height: 21px">
                <asp:Literal ID="LiQues" runat="server"></asp:Literal>
                <asp:PlaceHolder ID="phQues" runat="server" ></asp:PlaceHolder>
            </td>
        </tr>
 </table>
 <table>
Some code
 </table>

</div>
</<asp:Content>




Code behind

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)
{

}
Posted
Updated 2-May-13 23:39pm
v3
Comments
Thanks7872 3-May-13 3:42am    
whats the error?wheres the error?
apr1234 3-May-13 5:37am    
near htmlworker.Parse(str); and error is Input string was not in a correct format
Thanks7872 3-May-13 5:53am    
i just intended to have you a look at that function,not at gridview.
apr1234 3-May-13 5:56am    
ok sure... can you please post the same link again?
apr1234 3-May-13 8:57am    
Can any other help me on this please
OriginalGriff or CPallini ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900