Hi,
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?
Thanks,
Raj
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.
[C#]
// 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
absorber.Visit(pdfDocument.Pages[1]);
// 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;
pdfDocument.Save("c:/pdftest/DefaultTextInfor_Result_updated.pdf");
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 =
absorber.TableList[0].RowList[0].CellList[1].TextFragments[1];
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.
Thanks,
Raj
Hi Raj,
Sure, please keep me posted on this.
Thanks,
Raj
Hi Raj,
The issues you have found earlier (filed as PDFNET-40807) have been fixed in Aspose.PDF for .NET 24.3.