Skip to content

Commit

Permalink
Add transform method to Transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
rrthomas committed Apr 2, 2023
1 parent b385ce9 commit d381c5b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pypdf/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,19 @@ def compress(matrix: TransformationMatrixType) -> CompressedTransformationMatrix
matrix[2][1],
)

def transform(self, m: "Transformation") -> "Transformation":
"""
Apply one transformation to another.
Args:
m: a Transformation to apply.
Returns:
A new ``Transformation`` instance
"""
ctm = Transformation.compress(matrix_multiply(self.matrix, m.matrix))
return Transformation(ctm)

def translate(self, tx: float = 0, ty: float = 0) -> "Transformation":
"""
Translate the contents of a page.
Expand Down

0 comments on commit d381c5b

Please sign in to comment.