-1

I'm trying to flip pdf pages upside down using python. I have tried multiple libraries like PyPdf2, PyMuPDF and pdfminer. There is documentation on how to rotate a page, but that is not what I'm looking for. The closest solution I found was on one of PyMuPDF documentation pages, but its an example and doesn't offer the code as to how it was achieved. You can find the example page here: https://pymupdf.readthedocs.io/en/latest/matrix.html#flipping . Again the task is to flip the pdf pages not to rotate them.

Thank you, in advance for your answers.

Ajay Alex
  • 21
  • 3

1 Answers1

1

The flipping is achieved by multiplying with a matrix that is initialized with those parameters:

# Flip the page left-right (a = -1).
destpage.showPDFpage(r * fitz.Matrix(a=-1), src, sourcepage.number)

OR:

# Flip the page up-down (d = -1).
destpage.showPDFpage(r * fitz.Matrix(d=-1), src, sourcepage.number)
Aviv Yaniv
  • 6,188
  • 3
  • 7
  • 22