Repository navigation
fix(table): ignore opaque matching fill+stroke rects under lines_strict - #5210
ManojDevarajulu wants to merge 1 commit into
Conversation
veget-able
left a comment
There was a problem hiding this comment.
I looked this over and ran it against our table benchmark set, and I don’t see any regression. Looks good from my side, so I’ve approved.
@JorjMcKie one quick process question. When you ask me to review a PR like this, would you prefer that I merge it myself after approving, or that I just approve and leave the merge to you? Either is fine with me, I just want to follow whatever you find easiest.
In cases like these (an external contributor), after all concerned people have agreed, you could do the merge. |
…_strict Treat opaque 'fs' paths whose stroke matches fill like fill-only paths to prevent phantom table rows, and add regression test for pymupdf#5175. Fixes pymupdf#5175
c8f14c6 to
3a75282
Compare
|
Thanks @ToukoUrsin and @JorjMcKie! I noticed I have updated the branch to extract the |
Fixes #5175.
Credit to @ToukoUrsin for identifying the root cause and providing the reproduction script.
Problem
When using
strategy="lines_strict"withuse_layout=False,Page.find_tables()ignored fill-only rectangles (type="f"), but treated opaque rectangles drawn with both fill and stroke (type="fs") of the same color as table ruling lines.For example, a white redaction or white masking box drawn inside an empty table cell draws no visible border line, but its bounding edges were treated as structural table lines, creating phantom rows or columns (e.g. splitting a 6-column table into 7 columns).
Solution
In
src/table.py(clean_graphics), treattype="fs"paths whose fill color matches stroke color (and both opacities are 1) like fill-only paths underlines_strict.Boxes with contrasting borders (e.g. black stroke on white fill) or semi-transparent fills are unaffected and continue contributing lines as intended.
Tests
test_5175intests/test_tables.py:tests/test_tables.pypass.