Remove Tables from PDF using Python

Delete tables from PDF document using Aspose.PDF for Python for .NET Library

How to deleting Tables from PDF document Using Python for .NET Library

In order to delete table, use Aspose.PDF for Python via .NET, a powerful and easy-to-use API. Open PyPI, search for aspose-pdf, and install it. Alternatively, run the command:

Console

pip install aspose-pdf

Delete Tables from PDF using Python


You need Aspose.PDF for Python via .NET to try the code in your environment.

  1. Load the PDF with an instance of Document.
  2. Create TableAbsorber object to find tables.
  3. Visit first page with absorber.
  4. Get first table on the page.
  5. Remove the table. Save the file.

Delete Tables from PDF - Python

import aspose.pdf as apdf

from os import path
path_infile = path.join(self.data_dir, infile)
path_outfile = path.join(self.data_dir, outfile)

document = apdf.Document(path_infile)
absorber = apdf.text.TableAbsorber()
absorber.visit(document.pages[1])
table = absorber.table_list[0]
absorber.remove(table)
document.save(path_outfile)