0

I'm trying to display a HTML string in the PdfPTable using itextpdf.

Here's what I have done:

String solution = "<p>some text</p>";
Phrase htmlPhrase = new Phrase(": ", fontNormal10);
StyleSheet styleSheet = new StyleSheet();
styleSheet.loadTagStyle("body", "size", "10pt");
styleSheet.loadTagStyle("p", "size", "10pt");
java.util.List < Element > ie = HTMLWorker.parseToList(new StringReader(solution), styleSheet);
for (Element element: ie) {
    htmlPhrase.add(element);
}
cell = new PdfPCell(htmlPhrase);
cell.setBorder(Rectangle.NO_BORDER);
table.addCell(cell);

I still see HTML tags in the related cell.

talha06
  • 6,206
  • 21
  • 92
  • 147
  • See the comments of this question asked less only 8 hours before your question was asked: http://stackoverflow.com/questions/24533150/itextsharpstyling-related-to-html-page-not-coming-in-generated-pdf – Bruno Lowagie Jul 03 '14 at 06:32
  • I have already seen it; did not work for me. By the way I'm using iTextPDF; not ITextSharp. – talha06 Jul 03 '14 at 10:04
  • I'm the developer of iText. iTextSharp is the C# port of iText. It is maintained by people I hire. I'm sorry that it doesn't work for you. It's a pity you don't explain the problem (otherwise people would do an attempt to answer): http://lowagie.com/doesntwork – Bruno Lowagie Jul 03 '14 at 13:26
  • I think it's clear; "did not work" means I still see HTML tags despite using HTMLWorker. The question is clear, how can I display a HTML text into a cell; that's all. – talha06 Jul 03 '14 at 20:56

0 Answers0