Last post Mar 16, 2015 12:04 PM by Shruthin
Mar 16, 2015 11:26 AM|Shruthin|LINK
I tried eporting a Aspx page to pdf. it gives the error. Unable to cast object of type 'iTextSharp.text.html.simpleparser.CellWrapper' to type 'iTextSharp.text.Paragraph'.It throws the error here htmlparser.Parse(sr); I have checked the internet for
solution, but there seems to be none solving my problem. Somebody please help me out
Mar 16, 2015 11:43 AM|Rion Williams|LINK
Do you have an example of the code or markup that you are trying to convert? iTextSharp can be very sensitive with regards to any syntax errors or unexpected content and may be prone to throwing errors like this. You'll also want to ensure that you are using
the correct parser, as I believe that the original HTML parser was deprecated for the
XML Worker instead.
Mar 16, 2015 12:04 PM|Shruthin|LINK
Thank you for ur fast reply Rion :) Please check my code .
protected void Button2_Click(object sender, EventArgs e)
Response.ContentType = "application/pdf";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
htmlparser.Parse(sr); // Here i am getting error like this Unable to cast object of type 'iTextSharp.text.html.simpleparser.CellWrapper' to type 'iTextSharp.text.Paragraph'.
public override void VerifyRenderingInServerForm(Control control)
/* Verifies that the control is rendered */