Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,20 @@ def extract_cells(textpage, cell, markdown=False):
):
continue # skip spans outside cell

# only include chars with more than 50% bbox overlap
# only include chars with more than 50% bbox overlap.
# A char with an empty bbox (e.g. second half of a ligature
# with quad corrections unset, or a zero-width combining mark)
# has no area, so fall back to testing its origin: issue #5185.
span_text = ""
for char in span["chars"]:
this_char = char["c"]
bbox = pymupdf.Rect(char["bbox"])
if abs(bbox & cell) > 0.5 * abs(bbox):
if bbox.is_empty:
if pymupdf.Point(char["origin"]) in pymupdf.Rect(cell):
span_text += this_char
elif this_char in white_spaces:
span_text += " "
elif abs(bbox & cell) > 0.5 * abs(bbox):
span_text += this_char
elif this_char in white_spaces:
span_text += " "
Expand Down
Loading