PyMuPDF v1.9.3 now supports several new features for manipulating PDFs.
Here is an example to rotate a page with just a few lines of Python code.
1 2 3 4 5 6
import fitz # <- PyMuPDF v 1.9.3 doc = fitz.open("mypdf.pdf") # open the PDF page = doc[n] # read page n (zero-based) page.setRotate(-90) # rotate page by 90 degrees counter-clockwise doc.save(doc.name, incremental = True) # update the file - a sub-second matter doc.close()
works for all Python 2 & 3 platforms 2.7 and up, 32bit & 64bit.
Other new features of this version include deleting, copying and moving pages around - and accessing PDF annotations.
NB: look at branch 1.9.3 in GitHub while this is awaiting to be released.