When setting TextState.ForegroundColor to be the result of Aspose.Pdf.Color.Parse("#000") (a 3-digit hex color code), and then using SetColumnTextState with that TextState, the text of all of the columns is set to white.
Please see the below 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 = "75 75 75 75 75";
var numCols = 5;
for (var rowCounter = 0; rowCounter <= 5; rowCounter++)
{
var row = mytable.Rows.Add();
//Create rows in the table and then cells in the rows
for (var colCounter = 0; colCounter < numCols; colCounter++)
{
row.Cells.Add("row" + rowCounter.ToString() + ", col" + colCounter.ToString());
}
}
var textState = new TextState();
textState.ForegroundColor = Color.Parse("#000");
System.Diagnostics.Debug.WriteLine("result of Color.Parse: " + textState.ForegroundColor);
mytable.SetColumnTextState(0, textState);
doc.Save("ColorParseError.pdf");
And the corresponding PDF:
ColorParseError.pdf (40.7 KB)
There are two problems here. The first is that the Foreground Color of the text, when logged, is still #000000 (black), yet the text appears as white. The second problem is that only one column is being called with SetColumnTextState, but all columns are affected (and set to white text color).