Skip to content

Commit b387b06

Browse files
authored
DOC: Transformation (#907)
1 parent c4c2830 commit b387b06

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

PyPDF2/_page.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -143,24 +143,28 @@ class Transformation:
143143
Specify a 2D transformation.
144144
145145
The transformation between two coordinate systems is represented by a 3-by-3
146-
transformation matrix written as follows:
146+
transformation matrix written as follows::
147+
147148
a b 0
148149
c d 0
149150
e f 1
151+
150152
Because a transformation matrix has only six elements that can be changed,
151153
it is usually specified in PDF as the six-element array [ a b c d e f ].
152154
153-
Coordinate transformations are expressed as matrix multiplications:
155+
Coordinate transformations are expressed as matrix multiplications::
154156
155157
a b 0
156158
[ x′ y′ 1 ] = [ x y 1 ] × c d 0
157159
e f 1
158160
161+
159162
Usage
160163
-----
161-
>>> from PyPDF2 import Transformation
162-
>>> op = Transformation().scale(sx=2, sy=3).translate(tx=10, ty=20)
163-
>>> page.add_transformation(op)
164+
165+
>>> from PyPDF2 import Transformation
166+
>>> op = Transformation().scale(sx=2, sy=3).translate(tx=10, ty=20)
167+
>>> page.add_transformation(op)
164168
"""
165169

166170
# 9.5.4 Coordinate Systems for 3D
@@ -881,7 +885,7 @@ def add_transformation(
881885
882886
:param tuple ctm: A 6-element tuple containing the operands of the
883887
transformation matrix. Alternatively, a
884-
:class:`Transformation<PyPDF2._page.Transformation>`
888+
:py:class:`Transformation<PyPDF2.Transformation>`
885889
object can be passed.
886890
887891
See :doc:`/user/cropping-and-transforming`.

docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ You can contribute to `PyPDF2 on Github <https://github.com/py-pdf/PyPDF2>`_.
4242
modules/PdfWriter
4343
modules/PdfMerger
4444
modules/PageObject
45+
modules/Transformation
4546
modules/DocumentInformation
4647
modules/XmpInformation
4748
modules/Destination

docs/modules/DocumentInformation.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
The DocumentInformation Class
22
-----------------------------
33

4-
.. autoclass:: PyPDF2._reader.DocumentInformation
4+
.. autoclass:: PyPDF2.DocumentInformation
55
:members:
66
:undoc-members:
77
:show-inheritance:

docs/modules/Transformation.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
The Transformation Class
2+
------------------------
3+
4+
.. autoclass:: PyPDF2.Transformation
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

0 commit comments

Comments
 (0)