Python资料: PyPDF2 Transformation类

classPyPDF2.Transformation(ctm: Tuple[float, float, float, float, float, float] = (1, 0, 0, 1, 0, 0))[source]
Bases: object

Represent a 2D transformation.

The transformation between two coordinate systems is represented by a 3-by-3 transformation matrix matrix with the following form:

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:

a b 0
[ x′ y′ 1 ] = [ x y 1 ] × c d 0
e f 1
Example

>>> from PyPDF2 import Transformation
>>> op = Transformation().scale(sx=2, sy=3).translate(tx=10, ty=20)
>>> page.add_transformation(op)
apply_on(pt: Union[Tuple[Decimal, Decimal], Tuple[float, float], List[float]])→ Union[Tuple[float, float], List[float]][source]
Apply the transformation matrix on the given point.

Parameters
pt – A tuple or list representing the point in the form (x, y)

Returns
A tuple or list representing the transformed point in the form (x’, y’)

staticcompress(matrix: Tuple[Tuple[float, float, float], Tuple[float, float, float], Tuple[float, float, float]])→ Tuple[float, float, float, float, float, float][source]
Compresses the transformation matrix into a tuple of (a, b, c, d, e, f).

Parameters
matrix – The transformation matrix as a tuple of tuples.

Returns
A tuple representing the transformation matrix as (a, b, c, d, e, f)

propertymatrix: Tuple[Tuple[float, float, float], Tuple[float, float, float], Tuple[float, float, float]]
Return the transformation matrix as a tuple of tuples in the form: ((a, b, 0), (c, d, 0), (e, f, 1))

rotate(rotation: float)→ Transformation[source]
Rotate the contents of a page.

Parameters
rotation – The angle of rotation in degrees.

Returns
A new Transformation instance with the rotated matrix.

scale(sx: Optional[float] = None, sy: Optional[float] = None)→ Transformation[source]
Scale the contents of a page towards the origin of the coordinate system.

Typically, that is the lower-left corner of the page. That can be changed by translating the contents / the page boxes.

Parameters
sx – The scale factor along the x-axis.

sy – The scale factor along the y-axis.

Returns
A new Transformation instance with the scaled matrix.

translate(tx: float = 0, ty: float = 0)→ Transformation[source]
Translate the contents of a page.

Parameters
tx – The translation along the x-axis.

ty – The translation along the y-axis.

Returns
A new Transformation instance
我学习了多继承,多态,类的结构和属性的获取机制,老师讲的好,明白,谢谢老师的教导,明天继续努力
请问下各位老师,想干财务的话,这个学完是不是还需要再去学习其他的跟财务python有关的课程
今天我学习了打开文件的方式,文件/目录的常用管理操作,Python 2.x 如何使用中文以及eval 函数,明天就要飞机大战了,加油!!!
学这个对python爬虫有没有用呀?我需要做一个关于python爬虫的东西
抛出异常的概念:程序执行而且提示错误信息这个动作,称为抛出异常,在程序运行时,可能遇到一些不同类型的异常,而且需要针对不同的类型做出不同的处理方式,这个时候,就需要捕获异常类型了
想问问大家这个课程应付大学python考试够用吗(不是计算机专业的)
中文版修改代码大小:文件---设置---直接搜ctrl---常规----使用ctrl+鼠标滚轮修改字号
换了这个课程之后,适应多了,可能我的编程基础太差,这个难度低一点的课程和我更匹配。准备把这个课程好好学完后,再去用小甲鱼的课程复习巩固一下。
非常不错,谢谢老师,前来学习打卡......
已经试出来了hhh,但是为什么两个不能在一起呢?那个老师的就可以哎,我不明白(=・ω・=)(=・ω・=)