kuldeep singh

kuldeep singh

  • NA
  • 56
  • 15.7k

display data in text boxes and export to pdf

May 28 2015 2:50 AM
Good Morning Friends,
 
I have a employee's salary database and i have designed salary slip in web form and displaying data in that form from data base.
When i am exporting the form to pdf  it is only exporting the HTML content only, not the data which i have fetched from data base(using show button)
can anyone give me an idea how to export the web form data to pdf(as it is displayed in web form).
 
my code
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End(); 
 
 

Answers (19)