import PyPDF2 |
pdf_reader = PyPDF2.PdfFileReader( open ( "/path/to/file.pdf" , "rb" )) |
pdf_writer = PyPDF2.PdfFileWriter() |
for page_num in range (pdf_reader.numPages): |
page = pdf_reader.getPage(page_num) |
page.rotateClockwise( 90 ) |
pdf_writer.addPage(page) |
with open ( "/path/to/rotated_file.pdf" , "wb" ) as file : |
pdf_writer.write( file ) |