Hi everyone
I am importing data from grid view to pdf but when I am trying to open that pdf file it is showing some error like "there was an error opening this document the file is damaged and could not be repaired pdf" But I am able to open some other pdf files. i have written code like this. can you any one tell me how to overcome this issue its very urgent.
CODE:
Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Gridview1.AllowPaging = false; Gridview1.DataBind(); Gridview1.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(); System.Web.HttpContext.Current.Response.Write(pdfDoc); //Response.Write(pdfDoc); Response.End(); Thanks in Advance Satish Madugundu