在 Python 中旋转 PDF 页面

本主题描述了如何使用 Python 以编程方式更新或更改现有 PDF 文件中页面的页面方向。

当您需要在纵向和横向之间切换页面方向或对现有 PDF 内容应用旋转角度时,请使用此页面。

更改页面方向

此函数会旋转 PDF 的每一页 Document 使用 Aspose.PDF for Python 顺时针旋转 90 度。 它对于纠正页面方向问题非常有用,例如扫描的文档被横向放置。原始 PDF 保持不变,旋转后的版本保存为新文件。

import sys
import aspose.pdf as ap
from os import path

def rotate_page(infile, outfile):
    document = ap.Document(infile)
    for page in document.pages:
        page.rotate = ap.Rotation.ON90

    document.save(outfile)

相关页面主题