from pyPdf import PdfFileWriter PdfFileReader output PdfFileWriter inp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
from pyPdf import PdfFileWriter, PdfFileReader
output = PdfFileWriter()
input = PdfFileReader(open("input.pdf", 'rb'))
for x in xrange(input.numPages):
page = input.getPage(x)
# fucking-out the upper bound
page.mediaBox.upperLeft = (page.mediaBox.getUpperLeft_x() / 1.1,
page.mediaBox.getUpperLeft_y() / 1.1)
# fucking-out the bottom bound
page.mediaBox.lowerLeft = (page.mediaBox.getLowerLeft_x() + 50,
page.mediaBox.getLowerLeft_y() + 50)
output.addPage(page)
output.write(open("output.pdf", "wb"))