Free Support Forum - aspose.com

Aspose.Pdf.Table - render HTML within a cell?

Hello again,

We are using the following method to render cells:

Dim cell1 As Aspose.Pdf.Cell = tableRow.Cells.Add(strText, TextInfo)

This effectively inserts plain text, with associated styling, into the cell.

However, we would like to render HTML in the cell, in the same way that a paragraph can have an Aspose.Pdf.Text object, with the property .IsHTMLTagSupported = true.

Is there anyway we can do this within a table cell?


Thanks again!

Mark

Hello Mark,

Please try using the following code snippet and in case you face any problem or you have any further query, please feel free to contact.

[VB.NET]

' Instantiate an object PDF class
Dim pdf As Pdf = New Pdf()
' add the section to PDF document sections collection
Dim section As Aspose.Pdf.Section = pdf.Sections.Add()

'Instantiate a table object
Dim tab1 As Table = New Table()
'Add the table in paragraphs collection of the desired section
section.Paragraphs.Add(tab1)
'Set with column widths of the table
tab1.ColumnWidths = "150 150 150"
'Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new BorderInfo((BorderSide.All, 0.1F)
'Set table border using another customized BorderInfo object
tab1.Border = New BorderInfo(BorderSide.All, 1.0F)

'Create text paragraphs containing HTML text
Dim text2 As Aspose.Pdf.Text = New Aspose.Pdf.Text(" This is a sample text Bold line of text ")
' enable the property to display HTML contents within their own formatting
text2.IsHtmlTagSupported = True

'Create rows in the table and then cells in the rows
Dim row1 As Aspose.Pdf.Row = tab1.Rows.Add()
row1.FixedRowHeight = 60
row1.Cells.Add().Paragraphs.Add(text2)
row1.Cells.Add("col2")
row1.Cells.Add("col3")
'Save the pdf document
pdf.Save("D:\2_body\body.pdf")

I have also enclosed the resultant PDF that I have generated using Aspose.Pdf for .NET 4.6.0.

Nayyer, thank you once again!

We should only have a few more questions as we work through the minor issues (I hope you aren’t going on holiday next week :wink:

Mark

Hello Mark,

I am pleased to hear that your requirement has been fulfilled. However, if you have any further query, please feel free to contact. We would be pleased to assist you in that regard.