Click here to Skip to main content
13,632,608 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
The error is Unable to cast object of type "'iTextSharp.text.html.simpleparser.CellWrapper' to type 'iTextSharp.text.Paragraph'". Plese dont duplicate i couldnot find the solution.
Please Help



Response.ContentType = "application/pdf";
        Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf");
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        pnlPerson.RenderControl(hw);
        gridstudentnotes.DataBind();

        StringReader sr = new StringReader(sw.ToString());
        Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
        HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
        PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
        pdfDoc.Open();
        htmlparser.Parse(sr);
        pdfDoc.Close();
        Response.Write(pdfDoc);
        Response.End();
Posted 15-Mar-15 19:27pm
Updated 22-Mar-17 0:01am
v2
Comments
   
In what line? Whatever it is, of course you cannot cast it; what could possibly be unclear in this error message?
—SA
manchanx 16-Mar-15 1:50am
   
I assume it's occurring in non-user-code in htmlparser.Parse(sr); because there's nowhere a visible cast. Maybe some sort of configuration mistake, but I have no experience with iTextSharp.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web04-2016 | 2.8.180712.1 | Last Updated 22 Mar 2017
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100