Skip to content

Commit

Permalink
DOC: Transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma committed May 26, 2022
1 parent c4c2830 commit 6bf1707
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
16 changes: 10 additions & 6 deletions PyPDF2/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,24 +143,28 @@ class Transformation:
Specify a 2D transformation.
The transformation between two coordinate systems is represented by a 3-by-3
transformation matrix written as follows:
transformation matrix written as follows::
a b 0
c d 0
e f 1
Because a transformation matrix has only six elements that can be changed,
it is usually specified in PDF as the six-element array [ a b c d e f ].
Coordinate transformations are expressed as matrix multiplications:
Coordinate transformations are expressed as matrix multiplications::
a b 0
[ x′ y′ 1 ] = [ x y 1 ] × c d 0
e f 1
Usage
-----
>>> from PyPDF2 import Transformation
>>> op = Transformation().scale(sx=2, sy=3).translate(tx=10, ty=20)
>>> page.add_transformation(op)
>>> from PyPDF2 import Transformation
>>> op = Transformation().scale(sx=2, sy=3).translate(tx=10, ty=20)
>>> page.add_transformation(op)
"""

# 9.5.4 Coordinate Systems for 3D
Expand Down Expand Up @@ -881,7 +885,7 @@ def add_transformation(
:param tuple ctm: A 6-element tuple containing the operands of the
transformation matrix. Alternatively, a
:class:`Transformation<PyPDF2._page.Transformation>`
:py:class:`Transformation<PyPDF2.Transformation>`
object can be passed.
See :doc:`/user/cropping-and-transforming`.
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ You can contribute to `PyPDF2 on Github <https:/py-pdf/PyPDF2>`_.
modules/PdfWriter
modules/PdfMerger
modules/PageObject
modules/Transformation
modules/DocumentInformation
modules/XmpInformation
modules/Destination
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/DocumentInformation.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The DocumentInformation Class
-----------------------------

.. autoclass:: PyPDF2._reader.DocumentInformation
.. autoclass:: PyPDF2.DocumentInformation
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/modules/Transformation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The Transformation Class
------------------------

.. autoclass:: PyPDF2.Transformation
:members:
:undoc-members:
:show-inheritance:

0 comments on commit 6bf1707

Please sign in to comment.