title: HTML table to PDF using IText
body: <pre><code>public class FontItext {
      public static void main(String[] args) throws IOException, DocumentException {
          com.itextpdf.text.Document document = new com.itextpdf.text.Document(PageSize.A4,55f,30f,30f,30f);
          document.setMarginMirroring(true);
          PdfWriter.getInstance(document, new FileOutputStream("D://AAA.pdf"));
          document.open();       
          BaseFont bf = BaseFont.createFont("D:\\times.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
          Font font = new Font(bf);
          Paragraph _p = new Paragraph();       
          ArrayList htmlObjs = (ArrayList)HTMLWorker.parseToList(new StringReader("&lt;table border=1&gt;&lt;tr&gt;&lt;td&gt;Test&lt;/td&gt;&lt;td&gt;Test&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"),
                  null);
          for (int k = 0; k &lt; htmlObjs.size(); ++k) {
              ArrayList&lt;Chunk&gt; chunk = (ArrayList&lt;Chunk&gt;)((Paragraph)htmlObjs.get(k)).getChunks();
              for (int l = 0; l &lt; chunk.size(); l++) {
                  Font _original_chunk_font = chunk.get(l).getFont();
                  Font _newchunk_font = new Font(bf);
                  _newchunk_font.setFamily(_original_chunk_font.getFamilyname());
                  _newchunk_font.setStyle(_original_chunk_font.getStyle());
                  _newchunk_font.setSize(_original_chunk_font.getSize());
                  _newchunk_font.setColor(_original_chunk_font.getColor());
                  chunk.get(l).setFont(_newchunk_font);
              }
              _p.add((Element)htmlObjs.get(k));
  
              document.add((Element)htmlObjs.get(k));
  
          } 
  
          document.close();
      }
  }
  </code></pre>
  
  <p><strong>Error...</strong>  </p>
  
  <pre><code>Exception in thread "main" java.lang.ClassCastException: com.itextpdf.text.pdf.PdfPTable cannot be cast to com.itextpdf.text.Paragraph
      at Font.FontItext.main(FontItext.java:46)
  </code></pre>
  
  <p>Hey Guys help me....</p>