Add .curve_edges, use by default in table-detect.

Most of the groundwork was already there to add a PDF/Page.curve_edges
property. And, inspired, by
https://github.com/jsvine/pdfplumber/discussions/858 and related issues,
we now include 0/90/180/270-degree oriented curve segments into the
default table-detection strategy. As before, you can still switch to the
"lines_strict" to use only lines defined as such (rather than also using
rect and curve edges).
This commit is contained in:
Jeremy Singer-Vine
2023-04-12 18:40:59 -04:00
parent 4b373977be
commit 6f6b465260
6 changed files with 45 additions and 16 deletions
+13
View File
@@ -211,3 +211,16 @@ class Test(unittest.TestCase):
}
assert page.extract_table(table_settings)
assert page.extract_tables(table_settings)
def test_table_curves(self):
# See https://github.com/jsvine/pdfplumber/discussions/808
path = os.path.join(HERE, "pdfs/table-curves-example.pdf")
with pdfplumber.open(path) as pdf:
page = pdf.pages[0]
assert len(page.curves)
tables = page.extract_tables()
assert len(tables) == 1
t = tables[0]
assert t[-2][-2] == "Uncommon"
assert len(page.extract_tables({"vertical_strategy": "lines_strict"})) == 0