I've read that PyPDF can have issues while cropping PDF's with python. Anyone able to help me understand why my script crops and leaves the files blank?
def cropPDF(filenamePDF):
top = 57 ###############################
right = 26 # Margin's to be trimmed #
bottom = 75 # in pixels #
left = 26 ###############################
pdfIn = PdfFileReader(open(filenamePDF,'rb'))
pdfOut = PdfFileWriter()
for page in pdfIn.pages:
page.mediaBox.upperRight = (page.mediaBox.getUpperRight_x() - right, page.mediaBox.getUpperRight_y() -top)
page.mediaBox.lowerLeft = (page.mediaBox.getLowerLeft_x() - left, page.mediaBox.getLowerLeft_y() -bottom)
pdfOut.addPage(page)
ous = open(filenamePDF, 'wb')
pdfOut.write(ous)
ous.close()