Welcome, guest | Sign In | My Account | Store | Cart

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.

Python, 6 lines
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.

1 comment

Jorj X. McKie (author) 7 years, 5 months ago  # | flag

The above is VERY fast:

To rotate all 1.310 pages of Adobe's manual takes below 1.5 seconds on my machine (Windows 10, 4.0 GHz, 8 GB RAM).