title: iTextSharp.tool.xml.XMLWorkerHelper.GetInstance().ParseXHtml not working
body: <p>I'm using  iTextSharp version: 5.5.6; iTextSharp XML Worker version: 5.5.6</p>
  
  <p>I got some code from <a href="https://stackoverflow.com/questions/25164257/how-to-convert-html-to-pdf-using-itextsharp/25164258#25164258">Here</a>, but after I run the code, the PDF file will never open </p>
  
  <blockquote>
    <p>:The file is damaged and could not be repaired. Local\EWHvxm9t5++</p>
    
    <p>htmltext="\r\n\r\n\r\n\r\n\r\n
    \r\n       \r\n        \r\n       \r\n         \r\n   \r\n<br>
     \r\n    Item \r\n    Description\r\n   <br>
    LotNo\r\n   Revision\r\n   NamePlatSN\r\n<br>
    DateCreated\r\n   CreatedBy\r\n \r\n   \r\n<br>
    \r\n    \r\n     100-817412-001\r\n      X500-G02 -
    ENV DWG            \r\n    15020008\r\n     B<br>
    \r\n    testing123\r\n     4/9/2015 12:00:00
    AM\r\n     ULTRATCS\xma\r\n     \r\n    \r\n<br>
    \r\n        \r\n  \r\n\r\n\r\n\r\n"</p>
  </blockquote>
  
  <p>The HTML string (better formatted) looks like this:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=\"en\" &gt;
  &lt;body&gt;
  
  
  
  
          &lt;table&gt; 
  
     &lt;tr&gt; 
     &lt;th&gt; Item &lt;/th&gt;
     &lt;th&gt; Description&lt;/th&gt;
     &lt;th&gt;   LotNo&lt;/th&gt;
     &lt;th&gt;Revision&lt;/th&gt;
     &lt;th&gt;NamePlatSN&lt;/th&gt;
     &lt;th&gt;DateCreated&lt;/th&gt;
     &lt;th&gt;CreatedBy&lt;/th&gt;
  
     &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt; 100-817412-001&lt;/td&gt;
       &lt;td&gt; X500-G02 - ENV DWG            &lt;/td&gt;
      &lt;td&gt;15020008&lt;/td&gt;
      &lt;td&gt; B      &lt;/td&gt;
      &lt;td&gt;testing123&lt;/td&gt;
      &lt;td&gt; 4/9/2015 12:00:00 AM&lt;/td&gt;
      &lt;td&gt; ULTRATCS\\xma&lt;/td&gt;
  
      &lt;/tr&gt;
      &lt;/table&gt;
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code> protected ActionResult ViewPdf(object model)
          {
              // Create the iTextSharp document.          
              Document doc = new Document();
              byte[] buf;
              // Set the document to write to memory.
              MemoryStream memStream = new MemoryStream();
              PdfWriter writer = PdfWriter.GetInstance(doc, memStream);
              writer.CloseStream = false;
              doc.Open();
              string htmltext = this.RenderActionResultToString(this.View(model));      
  
                 using (var srHtml = new StringReader(htmltext))
                   {
                              //Parse the HTML
                              XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, srHtml);
                              //buf  = new byte[memStream.Position];
                              //memStream.Position = 0;
                              //memStream.Read(buf, 0, buf.Length);
  
                              buf = memStream.ToArray(); 
  
                              doc.Close();
                          }       
             // System.IO.File.WriteAllBytes(@"c:\\temp\test.pdf", buf);
              // Send the binary data to the browser.
              return new BinaryContentResult(buf, "application/pdf");
          }       
      }
  }
  </code></pre>
  
  <p>What is wrong?</p>