title: aspx to pdf using itextSharp 5.3.0
body: <p>I am using this dll  iTextSharp 5.3.0 to make a pdf file .
  Is there a way to convert full .aspx page in pdf ? My page has grids and server side code .</p>
  
  <p>This is my code:</p>
  
  <p>protected void Button1_Click(object sender, EventArgs e)
      {</p>
  
  <pre><code>    createPDF(Server.MapPath("Default.aspx"));
  
  }
  
  
  private void createPDF(string html)
  {
  
  
      TextReader reader = new StringReader(html);
  
      // step 1: creation of a document-object
      Document document = new Document(PageSize.A4, 30, 30, 30, 30);
  
      // step 2:
      // we create a writer that listens to the document
      // and directs a XML-stream to a file
      PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("c://test.pdf", FileMode.Create));
  
  
      HTMLWorker worker = new HTMLWorker(document);
  
      document.Open();
      worker.StartDocument();
      List&lt;IElement&gt; p = HTMLWorker.ParseToList(new StreamReader(html), new StyleSheet());
      for (int k = 0; k &lt; p.Count; k++)
      {
          document.Add((IElement)p[k]);
      }
  
  
  
      worker.EndDocument();
      worker.Close();
      document.Close();
  
  }
  </code></pre>
  
  <p>It's working but the file test.pdf is just plain text. The html isn't well interpreted, my grids are missing and my server side values (the values from the grids) are also missing .
  I also tried the codes from here:
  <a href="http://forums.asp.net/t/1199774.aspx" rel="nofollow noreferrer">http://forums.asp.net/t/1199774.aspx</a>
  and here:
  <a href="https://stackoverflow.com/questions/824265/problem-with-htmlparser-in-itextsharp">Problem with HTMLParser in Itextsharp</a></p>
  
  <p>Thanks in advance!</p>