Sathish Kumar

Sathish Kumar

  • NA
  • 55
  • 12.8k

Export Data into PDF using iTextSharp

Sep 8 2015 9:41 AM
Hi frnds,
 
   I'm using iTextSharp dll in my web applicaiton to export data into PDF. upto certain amt of data (5K records) there's not a problem.
   but in my application there may be a (25K or more records) large data need to export. at the time it getting delay. The page has gone unresponsive.
   The script of the page was  stopped. Any one help me out for this problem,
 
 
   My code is look like follows..
 
   Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition",
"attachment;filename=" + Request.QueryString["surveyName"].ToString() + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
pnlExport.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End(); 
 
Note:  pnlExport is the panel... which have the grid i bound the large data. 
 
 

Answers (1)