title: iTextSharp asp:DataGrid does not show up in PDF
body: <p>Converting a generated html page to pdf using iTextSharp, I cannot get the table created from the asp:DataGrid to show up in the PDF.  The page's HTML output for the datagrid looks like this:</p>
  
  <pre><code>&lt;p&gt;Purchases:&lt;/p&gt;
      &lt;table rules="all" id="dg_Purchase" style="font-size: smaller; border-collapse: collapse;" border="1" cellspacing="0"&gt;
      &lt;tbody&gt;&lt;tr&gt;
          &lt;td&gt;Lot #&lt;/td&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td&gt;Title&lt;/td&gt;
          &lt;td align="right"&gt;Price&lt;/td&gt;
          &lt;td align="right"&gt;Buyer's Premium&lt;/td&gt;
          &lt;td align="right"&gt;Tax&lt;/td&gt;
          &lt;td align="right"&gt;Sub Total&lt;/td&gt;
      &lt;/tr&gt;&lt;tr&gt;
          &lt;td&gt;118&lt;/td&gt;
          &lt;td&gt;&lt;input id="dg_Purchase_ctl02_CheckBox1" name="dg_Purchase$ctl02$CheckBox1" type="checkbox"&gt;&lt;/td&gt;
          &lt;td&gt;Yih-Wen Kuo (1959, Taiwan)&lt;/td&gt;
          &lt;td align="right"&gt;$1,900.00&lt;/td&gt;
          &lt;td align="right"&gt;$332.50&lt;/td&gt;
          &lt;td align="right"&gt;$0.00&lt;/td&gt;
          &lt;td align="right"&gt;$2,232.50&lt;/td&gt;
      &lt;/tr&gt;&lt;tr&gt;
          &lt;td&gt;119&lt;/td&gt;
          &lt;td&gt;&lt;input id="dg_Purchase_ctl03_CheckBox1" name="dg_Purchase$ctl03$CheckBox1" type="checkbox"&gt;&lt;/td&gt;
          &lt;td&gt;Yih-Wen Kuo (1959, Taiwan)&lt;/td&gt;
          &lt;td align="right"&gt;$1,800.00&lt;/td&gt;
          &lt;td align="right"&gt;$315.00&lt;/td&gt;
          &lt;td align="right"&gt;$0.00&lt;/td&gt;
          &lt;td align="right"&gt;$2,115.00&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;
  
  &lt;p&gt;Payments:&lt;/p&gt;
      &lt;table rules="all" id="dg_Payment" style="font-size: smaller; border-collapse: collapse;" border="1" cellspacing="0"&gt;
      &lt;tbody&gt;&lt;tr&gt;
          &lt;td style="width: 120px;"&gt;Payment Method&lt;/td&gt;
          &lt;td&gt;Date&lt;/td&gt;
          &lt;td align="right"&gt;Amount&amp;nbsp;&amp;nbsp;&lt;/td&gt;
      &lt;/tr&gt;&lt;tr&gt;
          &lt;td&gt;Total&lt;/td&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td align="right"&gt;$0.00&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;
  </code></pre>
  
  <p>When the HTML page is viewed, the table looks exactly how it should.  But when I generate the PDF, the table (or rather, everything within the table) is not shown.  Only the border is visible, pretty much being just a 2 px straight line for each table.</p>
  
  <p>So in my normal script, after the entire page has loaded, the very last thing I do is:</p>
  
  <pre><code>    StringWriter stringWriter = new StringWriter();
      HtmlTextWriter writer = new HtmlTextWriter(stringWriter);
      Render(writer);
  </code></pre>
  
  <p>The functions for iTextSharp are below:</p>
  
  <pre><code>protected override void Render(HtmlTextWriter writer)
  {
      MemoryStream mem = new MemoryStream();
      StreamWriter twr = new StreamWriter(mem);
      HtmlTextWriter myWriter = new HtmlTextWriter(twr);
      base.Render(myWriter);
      myWriter.Flush();
      myWriter.Dispose();
      StreamReader strmRdr = new StreamReader(mem);
      strmRdr.BaseStream.Position = 0;
      string pageContent = strmRdr.ReadToEnd();
      strmRdr.Dispose();
      mem.Dispose();
      writer.Write(pageContent);
      CreatePDFDocument(pageContent);
  }
  
  public void CreatePDFDocument(string strHtml)
  {
  
      string strFileName = HttpContext.Current.Server.MapPath("test.pdf");
      // step 1: creation of a document-object
      Document document = new Document();
      // step 2:
      // we create a writer that listens to the document
      PdfWriter.GetInstance(document, new FileStream(strFileName, FileMode.Create));
      StringReader se = new StringReader(strHtml);
      HTMLWorker obj = new HTMLWorker(document);
      document.Open();
      obj.Parse(se);
      document.Close();
      ShowPdf(strFileName);
  }
  
  public void ShowPdf(string strFileName)
  {
      Response.ClearContent();
      Response.ClearHeaders();
      Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName);
      Response.ContentType = "application/pdf";
      Response.WriteFile(strFileName);
      Response.Flush();
      Response.Clear();
  }
  </code></pre>
  
  <p>Again, everything on the page that is set programatically does show up in the PDF EXCEPT for the datagrid.  Going off the borders, it appears that it is not a <code>width</code> issue.  It just appears to be empty, is all.  Any help would be greatly appreciated.</p>