mirror of
https://github.com/jsvine/pdfplumber.git
synced 2026-08-29 08:34:23 +08:00
Fix bug w/ use_text_flow=True extractions (#1279)
... related to flows where text bounces between lines. h/t @samuelbradshaw
This commit is contained in:
@@ -587,7 +587,7 @@ class WordExtractor:
|
|||||||
(cx < ax)
|
(cx < ax)
|
||||||
or (cx > bx + x)
|
or (cx > bx + x)
|
||||||
# Interline test
|
# Interline test
|
||||||
or (cy > ay + y)
|
or abs(cy - ay) > y
|
||||||
)
|
)
|
||||||
|
|
||||||
def iter_chars_to_words(
|
def iter_chars_to_words(
|
||||||
|
|||||||
Binary file not shown.
@@ -336,6 +336,19 @@ class Test(unittest.TestCase):
|
|||||||
re.search("2015 RICE PAYMENT 26406576 0 1207631 Cr", not_using_flow) is None
|
re.search("2015 RICE PAYMENT 26406576 0 1207631 Cr", not_using_flow) is None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_text_flow_words_mixed_lines(self):
|
||||||
|
path = os.path.join(HERE, "pdfs/issue-1279-example.pdf")
|
||||||
|
|
||||||
|
with pdfplumber.open(path) as pdf:
|
||||||
|
p0 = pdf.pages[0]
|
||||||
|
words = p0.extract_words(use_text_flow=True)
|
||||||
|
|
||||||
|
texts = set(w["text"] for w in words)
|
||||||
|
|
||||||
|
assert "claim" in texts
|
||||||
|
assert "lence" in texts
|
||||||
|
assert "claimlence" not in texts
|
||||||
|
|
||||||
def test_extract_text(self):
|
def test_extract_text(self):
|
||||||
text = self.pdf.pages[0].extract_text()
|
text = self.pdf.pages[0].extract_text()
|
||||||
goal_lines = [
|
goal_lines = [
|
||||||
|
|||||||
Reference in New Issue
Block a user