mirror of
https://github.com/jsvine/pdfplumber.git
synced 2026-08-29 08:34:23 +08:00
Fix bug in dedup_chars() in which ._objects was accessed before assignment
Fixes #293
This commit is contained in:
+1
-1
@@ -270,7 +270,7 @@ class Page(Container):
|
||||
and positioning (within `tolerance`) as other characters on the page.
|
||||
"""
|
||||
p = FilteredPage(self, True)
|
||||
p._objects = dict((kind, objs) for kind, objs in self._objects.items())
|
||||
p._objects = dict((kind, objs) for kind, objs in self.objects.items())
|
||||
p._objects["char"] = utils.dedupe_chars(self.chars, **kwargs)
|
||||
return p
|
||||
|
||||
|
||||
Binary file not shown.
@@ -67,3 +67,10 @@ class Test(unittest.TestCase):
|
||||
|
||||
assert last_line_without_drop == '微微软软 培培训训课课程程:: 名名模模意意义义一一些些有有意意义义一一些些'
|
||||
assert last_line_with_drop == '微软 培训课程: 名模意义一些有意义一些'
|
||||
|
||||
def test_extract_text2(self):
|
||||
path = os.path.join(HERE, "pdfs/issue-71-duplicate-chars-2.pdf")
|
||||
pdf = pdfplumber.open(path)
|
||||
page = pdf.pages[0]
|
||||
|
||||
assert page.dedupe_chars().extract_text(y_tolerance=6).splitlines()[4] == "UE 8. Circulation - Métabolismes"
|
||||
|
||||
Reference in New Issue
Block a user