From 6bf1707997bbeb5ea8e0f1a4fa70120d29e390d2 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Thu, 26 May 2022 22:42:25 +0200 Subject: [PATCH] DOC: Transformation --- PyPDF2/_page.py | 16 ++++++++++------ docs/index.rst | 1 + docs/modules/DocumentInformation.rst | 2 +- docs/modules/Transformation.rst | 7 +++++++ 4 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 docs/modules/Transformation.rst diff --git a/PyPDF2/_page.py b/PyPDF2/_page.py index ef576f773..21d45213f 100644 --- a/PyPDF2/_page.py +++ b/PyPDF2/_page.py @@ -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 @@ -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` + :py:class:`Transformation` object can be passed. See :doc:`/user/cropping-and-transforming`. diff --git a/docs/index.rst b/docs/index.rst index 1f19888ee..7d1cad807 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -42,6 +42,7 @@ You can contribute to `PyPDF2 on Github `_. modules/PdfWriter modules/PdfMerger modules/PageObject + modules/Transformation modules/DocumentInformation modules/XmpInformation modules/Destination diff --git a/docs/modules/DocumentInformation.rst b/docs/modules/DocumentInformation.rst index 8a154d411..41103b0a1 100644 --- a/docs/modules/DocumentInformation.rst +++ b/docs/modules/DocumentInformation.rst @@ -1,7 +1,7 @@ The DocumentInformation Class ----------------------------- -.. autoclass:: PyPDF2._reader.DocumentInformation +.. autoclass:: PyPDF2.DocumentInformation :members: :undoc-members: :show-inheritance: diff --git a/docs/modules/Transformation.rst b/docs/modules/Transformation.rst new file mode 100644 index 000000000..5fbba321b --- /dev/null +++ b/docs/modules/Transformation.rst @@ -0,0 +1,7 @@ +The Transformation Class +------------------------ + +.. autoclass:: PyPDF2.Transformation + :members: + :undoc-members: + :show-inheritance: