Displaying Table components in Bol

Hi,


We need to display some paragraphs in a table as bold, I tried setting the IsTrueTypeFontBold property but it is not showing in bold in the resulting document.

Text text4 = new Text("\nProvider Section\n\n");
text4.TextInfo.IsTrueTypeFontBold = true;

Are there any conditions that are needed to be met so the the text would appear as bold in the PDF.

Awaiting Replies,
Thank YOu

Hello Jagannath,

Thanks for considering Aspose.

In order to display the text as Bold or Italic in a table cell, please try setting the

Cell.DefaultCellTextInfo.IsTrueTypeFontItalic or IsTrueTypeFontBold as true; but I'm afraid in recent version of Aspose.Pdf for .NET, this feature is not working and for the sake of correction, I've logged it as PDFNET-11394 in our issue tracking system. We will look into the details of this problem and will update you with the status of correction within this forum thread. We apologize for your inconvenience.

As a workaround, please try using the InLineHTML text inside the table cell. Please take a look over the following code snippet in which I've added the bold text in 1st cell and normal text in second cell. The resultant PDF is also in attachment.

[C#]

//Instantiate Pdf document object
Pdf pdf1 = new Pdf();
//Create a section in the Pdf
Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

//Create a table
Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
//Add table in the paragraphs collection of the section
sec1.Paragraphs.Add(tab1);
//set the column widths of the table
tab1.ColumnWidths = "100 100";
//Set default border of the cell using BorderInfo object
tab1.DefaultCellBorder = new BorderInfo((int)BorderSide.All, 0.1F);
//After setting default cell format information for the table, you can add rows
//and columns in the table
Aspose.Pdf.Row row1 = tab1.Rows.Add();

//Create string variables with text containing html tags
string s = "" + "This is a Bold Text ";
//Create text paragraphs containing HTML text
Text t1 = new Text(s);
t1.IsHtmlTagSupported = true;
row1.Cells.Add(new Aspose.Pdf.Cell(row1));
row1.Cells[0].Paragraphs.Add(t1);
row1.Cells.Add("Normal Text");

pdf1.Save(@"d:/pdftest/Text_as_Bold_in_Cell.pdf");

For information on InLineHTML text, please visit HTML Tags in Text

In case of any further query, please feel free to contact.

Hello Jagannath,

Thanks for your patience.

I am pleased to inform you that the issue reported earlier has been fixed in recent release version 5.4.0. Please try using this version and in case you still face any problem or you have any further query, please feel free to contact. We apologize for your inconvenience.

For your reference, I have also attached the resultant PDF that I have generated using following code snippet with Aspose.Pdf for .NET 5.4.0.

[C#]


//Instantiate Pdf document object
Pdf pdf1 = new Pdf();
//Create a section in the Pdf
Aspose.Pdf.Section sec1 = pdf1.Sections.Add();
//Create a table
Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
//Add table in the paragraphs collection of the section
sec1.Paragraphs.Add(tab1);
//set the column widths of the table
tab1.ColumnWidths = “60 100 100”;
//Set default border of the cell using BorderInfo object
tab1.DefaultCellBorder = new BorderInfo((int)BorderSide.All, 0.1F);

//After setting default cell format information for the table, you can add rows
//and columns in the table
Aspose.Pdf.Row row1 = tab1.Rows.Add();
// add a first cell with sample string to cells collection of row1
row1.Cells.Add(“Cell Contents in Bold”);
// Set the formatting information for contents inside Cell1 as Bold
row1.Cells[0].DefaultCellTextInfo.IsTrueTypeFontBold = true;
row1.Cells.Add(“Cell Contents in Italic”);
// Set the formatting information for contents inside Cell1 as Italic
row1.Cells[1].DefaultCellTextInfo.IsTrueTypeFontItalic = true;
row1.Cells.Add(“Normal Text”);
// save the resultant PDF
pdf1.Save(@“d:/pdftest/Text_as_Bold_in_Cell.pdf”);