Free Support Forum - aspose.com

How to Render HTML tag in a cell of a table in PDF?

How to Render HTML tag in a cell of a table in PDF?

I want to render HTML tag in a cell of a table in PDF.

I used this code…



string s1 = “<font color=”#800080">This is a test for HTML" +

“with colored text.”;


Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(s1);
t1.IsHtmlTagSupported = true;

rowPO77 = table2.Rows.Add();
Aspose.Pdf.Generator.Cell cellPO77 = rowPO77.Cells.Add(t1.ToString()); // I want to show rendered HTML in that cell
rowPO77.DefaultCellTextInfo.FontSize = 8;
rowPO77DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Left;




Need help…

Hi Arunava,

Thanks for using our products.

In order to place HTML text inside table cell, please add Text object to paragraphs collection of a table cell. I have tested the scenario using Aspose.Pdf for .NET 6.2.0 while using the code snippet shared over
Set Border Style, Margins and Padding of the Table, but I have made slight changes and used following code lines to add HTML text to table cell. For your reference, I have also attached the PDF document that I have generated. In case you still face any issue or you have any further query, please feel free to contact.

[Csharp]
string s1 = “<font color=”#800080">This is a test for HTML" + “with colored text.”;
Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(s1);
t1.IsHtmlTagSupported = true;
//Create rows in the table and then cells in the rows
Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
row1.Cells.Add();
row1.Cells[0].Paragraphs.Add(t1);