Retrieve tables and modify font color in a specific cell within a pdf document

How do I retrieve a specific table (may based on table index or content of first cell) and modify font color of a specific cell within the table in a pdf document. Can you please post some sample code? Is it not similar to retrieving tables like in a word document?


Hi Raj,

Thanks for contacting support.

In order to accomplish your requirements, please try using following code snippet. In case you encounter any issue, please share your input file.


load existing PDF file

Document pdfDocument = new Document("c:/pdftest/table.pdf");

// Create TableAbsorber object to find tables

TableAbsorber absorber = new TableAbsorber();

// Visit first page with absorber


// Get access to first table on page, their first cell and text fragments in it

TextFragment fragment = absorber.TableList[0].RowList[0].CellList[1].TextFragments[1];

// Change text of the text fragment in second cell

fragment.Text = "hello world";

// set font color

fragment.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;


Thank you for the reply Nayyer.
When I use the snippet that you sent, I encounter an error “Index was out of range. Must be non-negative and less than the size of the collection.” at the line:
TextFragment fragment =

The count of the fragments is always 0 (zero). Further, in the debug mode I am able to see counts of absorbed tables and rectangles.

The pdf document that I am working on has a few tables, but I am unable to read the text fragments using the snippet you have suggested. Please find the test document in the attachment.


Hi Raj,

Thanks for sharing the resource file.

I have tested the scenario and have managed to reproduce same problem. For the sake of correction, I have logged it as PDFNEWNET-40807 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

Sure, please keep me posted on this.


Hi Raj,

Thanks for your feedback. Sure, we will keep you updated about the issue resolution progress within this forum thread.

Thanks for your patience and cooperation.

Best Regards,