Python---PDF旋转角度

PDF顺时针旋转固定角度

from PyPDF2 import PdfFileReader, PdfFileWriter

def pdf_rotate(raw_path, save_path, angle=90):
    """
        将 PDF 顺时针旋转固定角度
    :param raw_path: PDF原文件路径
    :param save_path: 旋转后PDF保存路径
    :param angle: 旋转角度
    :return:
    """
    read_pdf = PdfFileReader(raw_path)
    write_pdf = PdfFileWriter()
    page_0 = read_pdf.getPage(0).rotateClockwise(angle)  # 顺时针旋转angle度
    write_pdf.addPage(page_0)
    with open(save_path, "wb") as f:
        write_pdf.write(f)
    原文作者:Dusk2090
    原文地址: https://blog.csdn.net/qq_41982466/article/details/115863017
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞