From 19d3162cd4bb19e57140733a9aa76ed7114a3438 Mon Sep 17 00:00:00 2001 From: Holmlund Date: Thu, 4 Jul 2024 09:21:29 +0200 Subject: [PATCH] Adding get_bounding_box property --- camelot/core.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/camelot/core.py b/camelot/core.py index 4448cabe..b8c48998 100644 --- a/camelot/core.py +++ b/camelot/core.py @@ -376,6 +376,23 @@ def parsing_report(self): "page": self.page, } return report + + @property + def get_bounding_box(self) -> Cell: + """Get Cell containing bounding box for entire table""" + bounding_box = self.cells[0][0] + for row in self.cells: + for cell in row: + if bounding_box.x1 > cell.x1: + bounding_box.x1 = cell.x1 + if bounding_box.y1 > cell.y1: + bounding_box.y1 =cell.y1 + if bounding_box.x2 < cell.x2: + bounding_box.x2 = cell.x2 + if bounding_box.y2 < cell.y2: + bounding_box.y2 = cell.y2 + + return bounding_box def set_all_edges(self): """Sets all table edges to True."""