Hello,
I want to delete or hide table from a pdf file using aspose. I have a pdf file which is having a 14 tables with some values. I need to delete a table from that file. I don’t find any option to hide or delete any of the tables. I can read the tableindex and cell list and also could change the text but I am not able to delete any table.
Please help me out with this issue.
Thanks
There is no direct way to remove the table from PDF documents. You can retrieve the rectangle region of a table, and then remove elements from this region with redact feature of the API. Please try the following code:
[C#]
string dataDir = @"c:\temp\";
// Load existing PDF file
Document pdfDocument = new Document(dataDir + "input.pdf");
// Create TableAbsorber object to find tables
TableAbsorber absorber = new TableAbsorber();
// Visit first page with absorber
absorber.Visit(pdfDocument.Pages[1]);
// Create RedactionAnnotation instance for specific page region
RedactionAnnotation annot = new RedactionAnnotation(pdfDocument.Pages[1], absorber.TableList[0].Rectangle);
annot.FillColor = Aspose.Pdf.Color.White;
annot.Color = Aspose.Pdf.Color.White;
// Add annotation to annotations collection of first page
pdfDocument.Pages[1].Annotations.Add(annot);
// Flattens annotation and redacts page contents (i.e. removes text and image
// Under redacted annotation)
annot.Redact();
pdfDocument.Save(dataDir + "Output.pdf");