I have noticed an inconsistency between TextState.Underline and TextState.FontStyle. Please see the following code:
var doc = new Document();
var page = doc.Pages.Add();
//Instantiate a table object
var mytable = new Table {Broken = TableBroken.Vertical};
//Add the table in paragraphs collection of the desired section
page.Paragraphs.Add(mytable);
//Set with column widths of the table
mytable.ColumnWidths = "100 100 100 100";
var columnCount = 4;
//Add colspan header Row
var headerRow1 = mytable.Rows.Add();
var firstspan = headerRow1.Cells.Add("header 1");
var secondspan = headerRow1.Cells.Add("header 2");
var thirdspan = headerRow1.Cells.Add("header 3");
var fourthspan = headerRow1.Cells.Add("header 4");
//Add header Row 2
var row1 = mytable.Rows.Add();
for (int i = 0; i < columnCount; i++)
{
row1.Cells.Add("cell " + i);
}
var row2 = mytable.Rows.Add();
for (int i = 0; i < columnCount; i++)
{
row2.Cells.Add("cell " + i);
}
var underlineTextState = new TextState();
underlineTextState.Underline = true;
underlineTextState.FontStyle = FontStyles.Bold | FontStyles.Italic;
mytable.SetColumnTextState(0, underlineTextState);
mytable.Rows[0].Cells[0].DefaultCellTextState.Underline = false;
mytable.Rows[0].Cells[0].DefaultCellTextState.FontStyle = FontStyles.Regular;
doc.Save("UnderlineOverwrite.pdf");
When I create a new TextState and set Underline, Bold, and Italic to be true, and then call SetColumnTextState with that new TextState, I am able to override the Bold and Italic FontStyle through cell.DefaultCellTextState. However, this does not work for cell.DefaultCellTextState.Underline – setting it as false does not remove the underline property from that cell, as can be seen in the attached PDF (first cell of first row). I would expect that this property override the Underline property in a manner consistent to the FontStyles.
UnderlineOverwrite.pdf (44.1 KB)