问题描述
我正在尝试使用python颠倒pdf页面。我尝试了多个库,例如PyPdf2,PyMuPDF和pdfminer。有关于如何旋转页面的文档,但这不是我想要的。我找到的最接近的解决方案是在PyMuPDF文档页面之一上,但是它只是一个示例,并且没有提供有关如何实现的代码。您可以在此处找到示例页面:https://pymupdf.readthedocs.io/en/latest/matrix.html#flipping。同样,任务是翻转pdf页面而不旋转它们。
谢谢你,谢谢。
解决方法
通过与使用以下参数初始化的矩阵相乘来实现翻转:
# Flip the page left-right (a = -1).
destpage.showPDFpage(r * fitz.Matrix(a=-1),src,sourcepage.number)
OR:
# Flip the page up-down (d = -1).
destpage.showPDFpage(r * fitz.Matrix(d=-1),sourcepage.number)