Does PyPDF2 work with PDFs in landscape mode?

Viewed 35

I was a writing a program that should extract text from a PDF using PyPDF2, and when I ran the program, it worked with a document that was written in portrait mode and printed out text. However the second document was written in landscape mode, and when it was run through the program, it did not print out any text. Below is what my code currently looks like.

text = ""
pdf = PdfFileReader('TEST.pdf', 'rb')
for i in range(pdf.getNumPages())
    text += pdf.getPage(i).extractText()
print(text)

What I'm wondering is basically can PyPDF2 read documents if they are in landscape mode, or does their orientation matter when extracting text? For additional details on the documents, the font used in the successful document was written with "Grotesque Sans Serif" font (i.e. Helvetica), and the unsuccessful document was written in "Slab Serifs" font (i.e. Rockwell).

Below are what the PDFs look like. The first was the successful document, the second is the unsuccessful document: enter image description hereenter image description here

1 Answers

My previous statement about PyPDF2 not working with PDF versions 1.4 was incorrect. I believe now the reason that the PDF did not work is because it was a bad PDF for whatever reason.

Related