Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix xform in xfoms inducing loop (py-pdf#966)
Browse files Browse the repository at this point in the history
in this PR as the test file needs the other fixes (but not linked with loop issue)
pubpub-zz committed Jun 11, 2022
1 parent ee8d4b6 commit 9768d5f
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions PyPDF2/_page.py
Original file line number Diff line number Diff line change
@@ -1268,9 +1268,10 @@ def process_operation(operator: bytes, operands: List) -> None:
if output != "":
output += "\n"
try:
xobj = self["/Resources"]["/XObject"] # type: ignore
if xobj[operands[0]]["/Subtype"] != "/Image":
text = self.extract_xform_text(xobj[operands[0]], space_width)
xobj = resources_dict["/XObject"] # type: ignore
if xobj[operands[0]]["/Subtype"] != "/Image": # type: ignore
output += text
text = self.extract_xform_text(xobj[operands[0]], space_width) # type: ignore
output += text
except Exception:
warnings.warn(
5 changes: 5 additions & 0 deletions tests/test_workflows.py
Original file line number Diff line number Diff line change
@@ -156,6 +156,11 @@ def test_rotate_45():
"https://github.com/py-pdf/PyPDF2/files/8884470/fdocuments.in_sweet-fundamentals-of-crystallography.pdf",
[0, 1, 34, 35, 36, 118, 119, 120, 121],
),
(
True,
"https://github.com/py-pdf/PyPDF2/files/8884493/998167.pdf",
[0]
),
],
)
def test_extract_textbench(enable, url, pages, print_result=False):

0 comments on commit 9768d5f

Please sign in to comment.