向 PDF 页面添加额外 space

Adding extra space to pages in PDF

我有几个 PDF,我想在一侧添加几英寸,以便为笔记应用程序中的手写评论留出更多空间。基本上,我想给自己更多的空间来在页面的两侧涂鸦(讲稿)。

页面不应该缩放,我只想让内容保持在左上角的同一位置,但在右侧和底部添加更多 space。

是否有使用 Python PDF 库之一或使用命令行工具的好方法?

我可以简单地向媒体框添加额外的 space,还是我需要做其他事情?

好的,下面的代码似乎可以工作。 必须设置 mediaBox 和 cropBox 才能获得所需的结果。

from PyPDF2 import PdfFileReader, PdfFileWriter

pdf = PdfFileReader("org.pdf")

writer = PdfFileWriter()

factor = 1.3

for page in pdf.pages:
    x,y = page.mediaBox.lowerRight 
    page.mediaBox.lowerRight = ( (factor * float(x)), float(y))

    x,y = page.cropBox.lowerRight 
    page.cropBox.lowerRight = ( (factor * float(x)), float(y))

    writer.addPage( page )

with open("out.pdf", "wb") as out_f:
    writer.write(out_f)