Skip to content

Commit 5c90510

Browse files
Fix TextPage missing .parent member.
Addresses #3027.
1 parent 6f57fbf commit 5c90510

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8971,8 +8971,8 @@ def get_textpage(self, clip: rect_like = None, flags: int = 0, matrix=None) -> "
89718971
finally:
89728972
if old_rotation != 0:
89738973
self.set_rotation(old_rotation)
8974-
textpage.parent = weakref.proxy(self)
89758974
textpage = TextPage(textpage)
8975+
textpage.parent = weakref.proxy(self)
89768976
return textpage
89778977

89788978
def get_texttrace(self):

tests/test_textextract.py

+8
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,11 @@ def get(flags=None):
208208

209209
assert not check_good(text_none)
210210
assert not check_good(text_0)
211+
212+
213+
def test_3027():
214+
path = path = f'{pymupdfdir}/tests/resources/2.pdf'
215+
doc = fitz.open(path)
216+
page = doc[0]
217+
textpage = page.get_textpage()
218+
fitz.utils.get_text(page=page, option="dict", textpage=textpage)["blocks"]

0 commit comments

Comments
 (0)