Click here to Skip to main content
15,891,654 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
using iTextSharp.text.html.simpleparser;

Response.ContentType = "application/pdf";

        Response.AddHeader("content-disposition", "attachment;filename=Report1.pdf");
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        HtmlForm frm = new HtmlForm();
        gd_dt.Parent.Controls.Add(frm);
        frm.Attributes["runat"] = "server";
        frm.Controls.Add(gd_dt);
        frm.RenderControl(hw);
        StringReader sr = new StringReader(sw.ToString());
        Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
        HTMLWorker htmlparser = new HTMLWorker(pdfDoc);

        PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
        pdfDoc.Open();
        htmlparser.Parse(sr);
       
        pdfDoc.Close();
        Response.Write(pdfDoc);
        Response.End();


this is the code i'm using in button upload.im getting this error.i dont know why it is happen.pls guys help me..



thank in advance
musiw.
Posted
Updated 10-Jun-12 19:12pm
v2
Comments
Ganesan Senthilvel 11-Jun-12 1:12am    
code is updated with proper format.
Sandeep Mewara 11-Jun-12 2:21am    
You sure it's not corrupted PDF?
Where exactly (line of code) this error happens?
musiw 11-Jun-12 5:29am    
pdfDoc.close();

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