Reputation: 161
I've been using PyPDF2 (version 1.26.0) to create new PDFs with no problems so far: rotating, cropping pages and more.
For some reason, the second line throws an error:
from PyPDF2 import PdfFileWriter, PdfFileReader
page = PageObject.createBlankPage(100, 100)
Being the error the following:
NameError: name 'PageObject' is not defined
Why could this be happening?
Upvotes: 2
Views: 5875
Reputation: 41
It seems like you aren't importing the PageObject class. Python only has access to the things you import. Please add this to the top of your file:
from PyPDF2.pdf import PageObject
Upvotes: 4
Reputation: 161
I found another way to achieve what I wanted, using PdfFileWriter's "addBlankPage"
from PyPDF2 import PdfFileWriter, PdfFileReader
output = PdfFileWriter()
output.addBlankPage(100, 100)
Upvotes: 0