FIROZ ANSARI

FIROZ ANSARI

  • NA
  • 52
  • 5.6k

Export GridView Data into PDF file

Nov 14 2016 1:19 AM
I   want to Export grid view data into pdf but only Header & Footer  Description is coming.
my Code is below:-> 
 
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter swr = new StringWriter();
HtmlTextWriter htmlwr = new HtmlTextWriter(swr);
grdReports.AllowPaging = false;
BindgrvReports();
grdReports.RenderControl(htmlwr);
StringReader srr = new StringReader(swr.ToString());
Document pdfdoc = new Document(PageSize.A2, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfdoc);
PdfWriter.GetInstance(pdfdoc, Response.OutputStream);
pdfdoc.Open();
htmlparser.Parse(srr);
pdfdoc.Close();
Response.Write(pdfdoc);
Response.End();

Answers (4)