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

Free Support Forum - aspose.com

Color.Parse Breaks with 3-Digit Hex Color Code

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


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).


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

Please also note that in the generated PDF, the text is still present in the document (the text can be selected and copy-pasted into a text editor, for example), so the issue is not that the text isn’t present at all.


You are right. We have also logged this information into the issue tracking system under the same ticket ID PDFNET-44880. We will let you once a significant progress has been made in this regard.