mirror of
https://github.com/jsvine/pdfplumber.git
synced 2026-08-29 08:34:23 +08:00
Restore "text" attr to .textboxhorizontal/etc.
Fix regression introduced in 9587cc7 / v0.6.2.
This commit is contained in:
+4
-1
@@ -23,6 +23,7 @@ from pdfminer.layout import (
|
||||
LTLine,
|
||||
LTPage,
|
||||
LTRect,
|
||||
LTTextContainer,
|
||||
)
|
||||
from pdfminer.pdfinterp import PDFPageInterpreter
|
||||
from pdfminer.pdfpage import PDFPage
|
||||
@@ -211,8 +212,10 @@ class Page(Container):
|
||||
attr["object_type"] = kind
|
||||
attr["page_number"] = self.page_number
|
||||
|
||||
if isinstance(obj, LTChar):
|
||||
if isinstance(obj, (LTChar, LTTextContainer)):
|
||||
attr["text"] = obj.get_text()
|
||||
|
||||
if isinstance(obj, LTChar):
|
||||
gs = obj.graphicstate
|
||||
attr["stroking_color"] = gs.scolor
|
||||
attr["non_stroking_color"] = gs.ncolor
|
||||
|
||||
@@ -26,6 +26,8 @@ class Test(unittest.TestCase):
|
||||
page = pdf.pages[0]
|
||||
assert len(page.textboxhorizontals) == 27
|
||||
assert len(page.textlinehorizontals) == 79
|
||||
assert "text" in page.textboxhorizontals[0]
|
||||
assert "text" in page.textlinehorizontals[0]
|
||||
assert len(page.chars) == 4408
|
||||
assert "anno" not in page.objects.keys()
|
||||
|
||||
@@ -38,6 +40,8 @@ class Test(unittest.TestCase):
|
||||
assert len(page.textboxhorizontals) == 74
|
||||
assert len(page.textlineverticals) == 11
|
||||
assert len(page.textboxverticals) == 6
|
||||
assert "text" in page.textboxverticals[0]
|
||||
assert "text" in page.textlineverticals[0]
|
||||
|
||||
def test_issue_383(self):
|
||||
with pdfplumber.open(self.path, laparams={}) as pdf:
|
||||
|
||||
Reference in New Issue
Block a user