pdf 改变页面大小 python_python – 裁剪.pdf文件的页面

pypdf在我所期望的这个领域.使用以下脚本:

#!/usr/bin/python

#

from pyPdf import PdfFileWriter, PdfFileReader

input1 = PdfFileReader(file("in.pdf", "rb"))

output = PdfFileWriter()

numPages = input1.getNumPages()

print "document has %s pages." % numPages

for i in range(numPages):

page = input1.getPage(i)

print page.mediaBox.getUpperRight_x(), page.mediaBox.getUpperRight_y()

page.trimBox.lowerLeft = (25, 25)

page.trimBox.upperRight = (225, 225)

page.cropBox.lowerLeft = (50, 50)

page.cropBox.upperRight = (200, 200)

output.addPage(page)

outputStream = file("out.pdf", "wb")

output.write(outputStream)

outputStream.close()

所得到的文档有一个200×200点的修剪框,从媒体框内的25,25点开始.

裁剪盒是装饰箱内的25点.

以下是使用以上代码处理后,我的样本文档在acrobat专业版中的显示方式:

crop pages screenshot http://i40.tinypic.com/fkqn2t.png当在acrobat reader中加载时,此文档将显示为空白.

你可能感兴趣的:(pdf,改变页面大小,python)