Skip to content

Commit 8a0c126

Browse files
committed
Restore "text" attr to .textboxhorizontal/etc.
Fix regression introduced in 9587cc7 / v0.6.2.
1 parent e63a038 commit 8a0c126

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pdfplumber/page.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
LTLine,
2424
LTPage,
2525
LTRect,
26+
LTTextContainer,
2627
)
2728
from pdfminer.pdfinterp import PDFPageInterpreter
2829
from pdfminer.pdfpage import PDFPage
@@ -211,8 +212,10 @@ def process_attr(item: Tuple[str, Any]) -> Optional[Tuple[str, Any]]:
211212
attr["object_type"] = kind
212213
attr["page_number"] = self.page_number
213214

214-
if isinstance(obj, LTChar):
215+
if isinstance(obj, (LTChar, LTTextContainer)):
215216
attr["text"] = obj.get_text()
217+
218+
if isinstance(obj, LTChar):
216219
gs = obj.graphicstate
217220
attr["stroking_color"] = gs.scolor
218221
attr["non_stroking_color"] = gs.ncolor

tests/test_laparams.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def test_with_laparams(self):
2626
page = pdf.pages[0]
2727
assert len(page.textboxhorizontals) == 27
2828
assert len(page.textlinehorizontals) == 79
29+
assert "text" in page.textboxhorizontals[0]
30+
assert "text" in page.textlinehorizontals[0]
2931
assert len(page.chars) == 4408
3032
assert "anno" not in page.objects.keys()
3133

@@ -38,6 +40,8 @@ def test_vertical_texts(self):
3840
assert len(page.textboxhorizontals) == 74
3941
assert len(page.textlineverticals) == 11
4042
assert len(page.textboxverticals) == 6
43+
assert "text" in page.textboxverticals[0]
44+
assert "text" in page.textlineverticals[0]
4145

4246
def test_issue_383(self):
4347
with pdfplumber.open(self.path, laparams={}) as pdf:

0 commit comments

Comments
 (0)