Skip to content

Commit

Permalink
FIX : Fix Error in transformations
Browse files Browse the repository at this point in the history
Error detected during analysis of py-pdf#1280
  • Loading branch information
pubpub-zz committed Sep 10, 2022
1 parent 0ceaa60 commit a5224c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions PyPDF2/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def compress(matrix: TransformationMatrixType) -> CompressedTransformationMatrix
matrix[0][1],
matrix[1][0],
matrix[1][1],
matrix[0][2],
matrix[1][2],
matrix[2][0],
matrix[2][1],
)

def translate(self, tx: float = 0, ty: float = 0) -> "Transformation":
Expand Down
4 changes: 4 additions & 0 deletions tests/test_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def test_page_operations(pdf_path, password):

page: PageObject = reader.pages[0]

t = Transformation().translate(50, 100).rotate(90)
assert abs(t.ctm[4] + 100) < 0.01
assert abs(t.ctm[5] - 50) < 0.01

transformation = Transformation().rotate(90).scale(1).translate(1, 1)
page.add_transformation(transformation, expand=True)
page.add_transformation((1, 0, 0, 0, 0, 0))
Expand Down

0 comments on commit a5224c0

Please sign in to comment.