Cell TextInfo Problem



In my project I’m dynamically creating a Table to add to a PDF document, but I want the text in the header row to be in bold but the header row keeps defaulting to the tables defaultCellTextInfo settings and not the values I specify for the individual cells or text segment.

In my project I set the tables default font using:

objTable.IsFirstRowRepeated = True

objTable.DefaultCellTextInfo.FontName = "Helvetica"
objTable.DefaultCellTextInfo.FontSize = 10

’-- fill the table with the contents of the DataTable
objTable.ImportDataTable(objDataTable, True, 0, 0)

Then i cycle through the header row to try and change the font to bold using:

For x As Integer = 0 To objTable.Rows(0).Cells.Count - 1
'-- Setting the cells TEXT.TEXTINFO properties
Dim t As Aspose.Pdf.Text = objTable.Rows(0).Cells(x).Paragraphs(0)
t.Segments(0).Content = data_view.columns(x).header
t.TextInfo = New Aspose.Pdf.TextInfo
t.TextInfo.FontName = “Helvetica-Bold”
t.TextInfo.FontSize = 12
t.TextInfo.Color = New Color(“black”)

'-- setting the cells default TEXTINFO settings
objTable.Rows(0).Cells(x).DefaultCellTextInfo = New Aspose.Pdf.TextInfo
objTable.Rows(0).Cells(x).DefaultCellTextInfo.FontName = “Helvetica-Bold”
objTable.Rows(0).Cells(x).DefaultCellTextInfo.FontSize = 12
objTable.Rows(0).Cells(x).DefaultCellTextInfo.Color = New Color(“black”)
objTable.Rows(0).Cells(x).DefaultCellTextInfo.IsTrueTypeFontBold = True

But neither of these methods work as the header row is not bold. Is this a bug or should I be specifiying these values in a different way? Is it possible to have the header row in a bold font?

Thanks in advance for your help,


Dear Andy,

Thanks for your consideration.

In your case, your have to set the font info of each segments in the text. In Aspose.Pdf, the font used in text is decided finally by the segment’s font setting. If you have set the font info of a Text object and use “Segment(Text)” constructor to create a Segment object, the Segment object will inherit font info from the Text object. But if you set the font info of the Text object after it’s segments are created, the setting will not affect it’s segments.