Create and Modify PDF Files in Python

So far, you’ve learned how to extract text and pages from PDFs and how to concatenate and merge two or more PDF files. These are all common operations with PDF files, but pypdf has many other useful features.

In the following sections, you’ll learn how to rotate and crop pages in a PDF file.

Rotating Pages With PageObject.rotate()

You’ll start by learning how to rotate pages. For this example, you’ll use the ugly.pdf file in the practice_files/ folder. This file contains a lovely version of Hans Christian Andersen’s “The Ugly Duckling,” except that every odd-numbered page is rotated counterclockwise by ninety degrees.

To fix that, in a new IDLE interactive window, start by importing the PdfReader and PdfWriter classes from pypdf,

 

 

 

To finish reading, please visit source site