title: Export page content to PDF using a iTextSharp (include buttons and grids)
body: <p>How to export my aspx page (include buttons and Grids) to PDF?</p>
  
  <p>Searching the web I found <a href="https://github.com/itext/itextsharp" rel="nofollow">iTextSharp</a>, but it works only with normal html.
  If my page has Grids or Buttons, these do not appear in PDF.</p>
  
  <p>My current code for export to PDF.
  This code exports only basic html (no buttons or grids).</p>
  
  <pre><code>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();
  </code></pre>