Skip to content

Commit 7990a2a

Browse files
authored
Update table.py
Adds header_margin and footer_margin keyword-arguments to page.find_tables(), letting callers ignore running headers/footers without manually building a clip rectangle. Parameters after page are now keyword-only to keep all existing code that omits the new args fully backward-compatible.
1 parent 29a327a commit 7990a2a

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/table.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,10 @@ def page_rotation_reset(page, xref, rot, mediabox):
23482348

23492349
def find_tables(
23502350
page,
2351+
*, # ← forces keyword use
23512352
clip=None,
2353+
header_margin: float = 0,
2354+
footer_margin: float = 0,
23522355
vertical_strategy: str = "lines",
23532356
horizontal_strategy: str = "lines",
23542357
vertical_lines: list = None,
@@ -2376,6 +2379,10 @@ def find_tables(
23762379
global CHARS, EDGES
23772380
CHARS = []
23782381
EDGES = []
2382+
if clip is None and (header_margin or footer_margin):
2383+
clip = Rect(page.rect)
2384+
clip.y0 += header_margin
2385+
clip.y1 -= footer_margin
23792386
old_small = bool(TOOLS.set_small_glyph_heights()) # save old value
23802387
TOOLS.set_small_glyph_heights(True) # we need minimum bboxes
23812388
if page.rotation != 0:

0 commit comments

Comments
 (0)