Click here to Skip to main content
15,914,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,I want to export grid data in pdf format this is my following code,problem occur
as pdf open but data not display. please help me ??? to solving problem

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=UserDetails.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GrdATDataView.AllowPaging = false;
GrdATDataView.DataBind();
GrdATDataView.RenderControl(hw);
GrdATDataView.HeaderRow.Style.Add("width", "15%");
GrdATDataView.HeaderRow.Style.Add("font-size", "10px");
GrdATDataView.Style.Add("text-decoration", "none");
GrdATDataView.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
GrdATDataView.Style.Add("font-size", "8px");
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A2, 7f, 7f, 7f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);

Response.Write(pdfDoc);
pdfDoc.Close();
Response.End();
Posted

1 solution

 
Share this answer
 

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