We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

TextFragment won't override TextState


For our current use-case we allow attributes to be set in an Aspose.PDF table using TextStates. Further, we might want to later override the TextStates at the column level by TextFragment at the cell level. However, it seems Aspose doesn’t support this override.

Our use-case is such that we would want to have multiple styles to a single piece of text in a cell. Currently, we use TextFragments to achieve this. The text is broken into parts and each of them is attributed with some styles using TextSegments. These segments are then bundled to make a TextFragment which we add to our cell.

It looks like once we set the table styles using TextStates we can’t really override them later using Fragments. However, TextStates at cell level do override TextStates at column level. We would like to allow multiple styles to a text which is only possible through Fragments.

ActualOutput.pdf (35.3 KB)
ExpectedOutput.pdf (35.4 KB)

Do let us know how to generate the expected output using fragments.

Following is a reproducer for the same.

static void columnStates()
            Document doc = new Document();
            Page page = doc.Pages.Add();
            var table = new Table
                ColumnAdjustment = ColumnAdjustment.Customized,
                ColumnWidths = "50 50",
            var row1 = table.Rows.Add();
            var row2 = table.Rows.Add();
            var r1c1 = row1.Cells.Add("R1C1");
            var r1c2 = row1.Cells.Add("R1C2");
            var r2c1 = row2.Cells.Add("R2C1");
            var r2c2 = row2.Cells.Add("R2C2");
            var columnTextState = new TextState(System.Drawing.Color.Green, 10);
            table.SetColumnTextState(0, columnTextState);
            table.SetColumnTextState(1, columnTextState);
            var cellTextFragment = new TextFragment("Fragment Override");

            cellTextFragment.TextState.FontSize = 20;
            cellTextFragment.TextState.ForegroundColor = Color.AliceBlue;
            var cellTextState = new TextState(System.Drawing.Color.DarkRed);
            r2c2.DefaultCellTextState = cellTextState;


We were able to reproduce the same issue using Aspose.PDF for .NET 21.3 in our environment. For the sake of further investigation, we have logged a ticket as PDFNET-49610 in our issue tracking system. We will further look into details of it and keep you informed about its resolution status. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hi @asad.ali

Any update on this topic?


We are afraid that the earlier logged ticket could not get resolved due to other issues in the queue logged prior to it. However, we will surely let you know once we make some certain progress towards resolution of the ticket. Please give us some time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFNET-49610) have been fixed in Aspose.PDF for .NET 22.1.