Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
plz help me to fix this problem i'm facing with exporting gridview to pdf..

(itextsharp.dll have been used in coding)

error...Unable to cast object of type 'iTextSharp.text.html.simpleparser.CellWrapper' to type 'iTextSharp.text.Paragraph

code:
StringReader sr = new StringReader(sw.ToString());
       Document pdfDoc = new Document(PageSize.A4, 20f, 20f, 20f, 20f);
       HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
       PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
       pdfDoc.Open();
      ----> htmlparser.Parse(sr); <------- ERROR
       pdfDoc.Close();
       Response.Write(pdfDoc);
       Response.End();
Posted
Comments
Sandip.Nascar 30-Sep-12 1:57am    
This is definite that the problem is in html with some tags. You need to observe minutely and have to fix the html issue.
Pro Idiot 30-Sep-12 3:34am    
Appears to be this problem: http://am22tech.com/s/22/Blogs/post/2011/09/28/HTML-To-PDF-using-iTextSharp.aspx

1 solution

Have a look at my answer to similar asked question earlier: Exporting aspx page to pdf[^]

Also, refer the following to convert HTML to PDF if needed: How To Convert HTML To PDF With Image Tags Using iTextSharp[^]
 
Share this answer
 

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