title: How do I convert malformed HTML to PDF with iText and XMLWorker?
body: <p>I am trying to convert HTML(with external CSS) into PDF using Itext XMLWorkerHelper,  am facing the run-time exception whenever XMLWorkerHelper parses a malformed HTML. For example:</p>
  
  <p>The html below has input tag not closed : and XMLWorkerHelper cannot parse and throws run-time exception. 
  </p>
  
  <p>if i try with proper HTML input tag enclosed,it works fine.</p>
  
  <p>How can i convert malformed or complex HTML (along with css) to PDF using Itext.</p>
  
  <p>below is my code:</p>
  
  <pre><code>var test_html = File.ReadAllText("C:/Desking _ Lender Program - Dealertrack.html");
  var test_css = File.ReadAllText("C:/login.css");
  using (var msCss = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(test_css)))
                      {
                          using (var msHtml = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(test_html)))
                          {
  
                              //Parse the HTML
                              try
                              {
                                  iTextSharp.tool.xml.XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, msHtml, msCss);
                              }
                              catch { }
                          }
                      }
  </code></pre>