How to export my aspx page (including buttons and grids) to PDF?
Searching the Internet I found iTextSharp , but it only works with regular html. If my page has grids or buttons, they are not displayed in PDF format.
My current code to export to PDF. This code only exports the basic html (no buttons or grids).
string attachment = "attachment; filename=AllPage.pdf";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/pdf";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
GridView1.AllowPaging = false;
GridView1.DataBind();
GridView1.RenderControl(htextw);
Document document = new Document();
PdfWriter.GetInstance(document, Response.OutputStream);
document.Open();
StringReader str = new StringReader(stw.ToString());
HTMLWorker htmlworker = new HTMLWorker(document);
htmlworker.Parse(str);
document.Close();
Response.Write(document);
Response.End();
source
share