title: Why is my PDF being generated as blank?
body: <p>I am using ItextSharp and c#, asp.net MVC to generate a PDF report. However, when I generate the report the PDF comes back as blank (apart from a header which is working fine). I would love your input.</p>
  
  <p>The code that generates the report is as follows:</p>
  
  <pre><code>                using (var writer = PdfWriter.GetInstance(doc, ms))
                  {
                      // This sorts out the Header and Footer parts.
                      var headerFooter = new ReportHeaderFooter(reportsAccessor);
                      writer.PageEvent = headerFooter;
  
                      var rootPath = ConfigurationManager.AppSettings["SaveFileRootPath"];
                      string html = File.ReadAllText(rootPath + "/reports/report.html");                      
  
                      // Perform the parsing to PDF
                      doc.Open();
  
                      // The html needs to be sorted before this call.
                      StringReader sr = new StringReader(html);
                      XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, sr);
                      doc.Close();
                      writer.Close();
                      res = ms.ToArray();
                  }
  </code></pre>
  
  <p>I know there is a lot hidden, but for arguments sake an example of the HTML that this generates and puts in the StringReader is here:</p>
  
  <pre><code>    &lt;table style="font-size:10pt"&gt;
          &lt;tr&gt;
              &lt;td rowspan="4"&gt; Address&lt;br/&gt; &lt;/td&gt;
              &lt;td&gt;Phone: phone&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Fax: fax&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Email: email@example.com&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Website: example.com&lt;/td&gt;
          &lt;/tr&gt;
      &lt;table&gt;
  
      &lt;table style="font-size:10pt; width:100%"&gt;
          &lt;tr style="width:50%"&gt;
              &lt;td&gt;Settlement: 30 days from invoice&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Delivery Charge Notes: N/A&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
      &lt;p style="width:100%; font-size:10pt"&gt;
      I love notes&lt;/p&gt;
  
      &lt;table&gt;
      &lt;tr style="font-weight:bold"&gt;
          &lt;td&gt;Item&lt;/td&gt;
          &lt;td&gt;Item Code&lt;/td&gt;
          &lt;td&gt;Description&lt;/td&gt;
          &lt;td&gt;Unit Size&lt;/td&gt;
          &lt;td&gt;Units Per Outer&lt;/td&gt;
          &lt;td&gt;Units Per Pallet&lt;/td&gt;
          &lt;td&gt;Invoice Price Volume Breaks&lt;/td&gt;
          &lt;td&gt;Branding&lt;/td&gt;
          &lt;td&gt;Notes&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;/table&gt;
  </code></pre>
  
  <p>However, this html generates a nice blank PDF file (not what I want). I can't see what might be wrong with this and would love some input in to two things:</p>
  
  <p>[1] Why the report is blank
  [2] If this is an error in the parsing, why it doesn't come up with an error and instead a blank report (is there a setting or argument I can set that will throw errors which are much more useful than blank reports?)</p>
  
  <p>UPDATE: 
  I have added the code for the header/footer </p>
  
  <p>public string HeaderTitle { get; set; }
          public IReportsAccessor ReportsAccessor { get; set; }
          public ReportHeaderFooter(IReportsAccessor reportsAccessor)
          {
              this.ReportsAccessor = reportsAccessor;
          }</p>
  
  <pre><code>    public override void OnStartPage(PdfWriter writer, Document document)
      {
          base.OnStartPage(writer, document);
          var rootPath = ConfigurationManager.AppSettings["SaveFileRootPath"];
          GetReportImageResult imgInfo = ReportsAccessor.GetImage(4);
  
          byte[] header_img = imgInfo.ReportImage;
          string logoFn = rootPath + "/tmp/logo.png";
          File.WriteAllBytes(logoFn, header_img);
          string html = File.ReadAllText(rootPath + "/reports/report_header.html");
          html = html.Replace("{{ title }}", HeaderTitle);
          html = html.Replace("{{ logo_img }}", logoFn);
  
          StringReader sr = new StringReader(html);
          XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, sr);          
      }
  </code></pre>