如何在pyPDF2中旋转页面?

伊格纳西奥(Ignacio Tiraboschi)

我正在使用pyPDF2编辑PDF文件。我设法生成了想要的PDF,但是还没有旋转一些页面。

我去了文档,发现了两个方法:rotateClockwiserotateCounterClockwise,尽管他们说参数是一个int,但我无法使其工作。Python说:

TypeError: unsupported operand type(s) for +: 'IndirectObject' and 'int'

要产生此错误:

page = input1.getPage(i)
page.rotateCounterClockwise(90)
output.addPage(page)

我找不到有人解释该程序。但是,stackoverflow中有一个问题,但是答案只是模糊的。

提前致谢。对不起,如果我错过了什么。

挪威语

这是rotateClockwise功能的一个已知错误有一个尚未合并的修复程序只需pdf.py使用此修复程序编辑'_rotate'方法

def _rotate(self, angle):
    rotateObj = self.get("/Rotate", 0)
    currentAngle = rotateObj if isinstance(rotateObj, int) else rotateObj.getObject()
    self[NameObject("/Rotate")] = NumberObject(currentAngle + angle)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章