1 import PyPDF2
2
3 pdf_in = open('original.pdf', 'rb')
4 pdf_reader = PyPDF2.PdfFileReader(pdf_in)
5 pdf_writer = PyPDF2.PdfFileWriter()
6
7 for pagenum in range(pdf_reader.numPages):
8 page = pdf_reader.getPage(pagenum)
9 page.rotateClockwise(180)
10 pdf_writer.addPage(page)
11
12 pdf_out = open('rotated.pdf', 'wb')
13 pdf_writer.write(pdf_out)
14 pdf_out.close()
15 pdf_in.close()
16