Free Support Forum -

SetColumnTextState() with TextState.Underline=true does not get overwritten by DefaultCellTextState.Underline=false

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
        //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;


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)


We managed to replicate the problem of underline text in our environment. An investigation has been logged under the ticket ID PDFNET-44869 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.