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

Free Support Forum - aspose.com

Delete or hide table from PDF Dynamically

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.


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:


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
// 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
// Flattens annotation and redacts page contents (i.e. removes text and image
// Under redacted annotation)
pdfDocument.Save(dataDir + "Output.pdf");