mirror of
https://github.com/jsvine/pdfplumber.git
synced 2026-08-29 16:40:24 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user