title: Error converting HTML text to a pdf file using itextsharp in asp.net
body: <p>I am using the following code to convert contents in Editor(Ajax control) to pdf,</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  
  using System.IO;
  using iTextSharp.text.html.simpleparser;
  using iTextSharp.text;
  using iTextSharp.text.pdf;
  using iTextSharp.text.html;
  /// &lt;summary&gt;
  /// Summary description for pdfgeneration
  /// &lt;/summary&gt;
  public class pdfgeneration
  {
      public pdfgeneration()
      {
          //
          // TODO: Add constructor logic here
          //
      }
  
      public void pdfgenerator(String name1, AjaxControlToolkit.HTMLEditor.Editor Editor1)
      {
  
          HttpContext.Current.Response.Clear();
          HttpContext.Current.Response.ContentType = &quot;application/pdf&quot;;
          // Create PDF document
          Document pdfDocument = new Document(PageSize.A4, 70, 55, 40, 25);
  
          PdfWriter wri = PdfWriter.GetInstance(pdfDocument, new FileStream(&quot;e://&quot; +name1 + &quot;.pdf&quot;, FileMode.Create));
  
          PdfWriter.GetInstance(pdfDocument, HttpContext.Current.Response.OutputStream);
  
          pdfDocument.Open();
          string htmlText = Editor1.Content;
          System.Collections.Generic.List&lt;IElement&gt; htmlarraylist = HTMLWorker.ParseToList(new StringReader(htmlText), null);
  
          for (int k = 0; k &lt; htmlarraylist.Count; k++)
          {
              pdfDocument.Add((IElement)htmlarraylist[k]);
          }
  
          pdfDocument.Close();
          HttpContext.Current.Response.End();
      }
  
  
  }
  </code></pre>
  <p>I am initially hard coding the following HTML text in the Editor(Ajax control),</p>
  <pre><code>String editorcontent = &quot;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&quot; +
                   &quot;&lt;br/&gt;&quot; + &quot;&lt;P align='center'&gt;&lt;b&gt;&quot; + courtname + &quot;&lt;/b&gt;&lt;/P&gt;&quot;
                  + &quot;&lt;br/&gt;&lt;P align='center'&gt;(Before&quot; + jname + &quot;,&quot; + desname + &quot;)&quot;
                  + &quot;&lt;br/&gt;&quot; + &quot;&lt;P align='right'&gt;&lt;b&gt;&lt;u&gt;&quot; + DropDownList1.SelectedItem + &quot; no. &quot; + TextBox1.Text + &quot;/&quot; + TextBox2.Text + &quot;&lt;/u&gt;&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&quot;
                  + &quot;&lt;br /&gt;&quot;
    **//this table is the problem//**    + &quot;&lt;table&gt;&lt;tr&gt;&lt;td width='750px'&gt;&lt;p align='left'&gt;&quot; + petitioner + &quot;&lt;/p&gt;&quot; + &quot;&lt;/td&gt;&lt;td&gt;&quot; + &quot;&lt;p align='right'&gt;&quot; + &quot;..Applicant&quot; + &quot;&lt;/p&gt;&quot; + &quot;&lt;/td&gt;&lt;/tr&gt;&quot; + &quot;&lt;tr&gt;&lt;td&gt;&lt;p align='center'&gt;&quot; + &quot;V/s&quot; + &quot;&lt;/p&gt;&quot; + &quot;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&quot; + &quot;&lt;/tr&gt;&quot; + &quot;&lt;tr&gt;&lt;td width='75px'&gt;&lt;p align='left'&gt;&quot; + respondent + &quot;&lt;/p&gt;&quot; + &quot;&lt;/td&gt;&lt;td&gt;&quot; + &quot;&lt;p align='right'&gt;&quot; + &quot;..Respondent&quot; + &quot;&lt;/p&gt;&quot; + &quot;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;
                  + &quot;&lt;br/&gt;&lt;P align='center'&gt;&lt;b&gt;&lt;u&gt;ORDER&lt;/u&gt;&lt;/b&gt;&quot;;
              Editor1.Content = editorcontent;
  </code></pre>
  <p>If i remove the following <code>table</code> from the above code than the pdf is generated successfully. but once i include that <code>table</code> in my HTMl code i get the following Error</p>
  <p><img src="https://i.stack.imgur.com/Em3qR.png" alt="enter image description here" /></p>
  <p>How to resolve my problem.</p>