Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)
I want to read a pdf format data in python. As far as I know, there is one way of changing its format from pdf to text, but I want to import the content directly from pdf.

Kindly explain which package in python is best for pdf extraction?

1 Answer

0 votes
by (108k points)

In your case, if you do not want to convert the pdf into text, then you can use the PyPDF2 package, refer to the below code for reference:

#install pyDF2

pip install PyPDF2

# importing all the required modules

import PyPDF2

# creating an object 

file = open('example.pdf', 'rb')

# creating a pdf reader object

fileReader = PyPDF2.PdfFileReader(file)

# print the number of pages in pdf file

print(fileReader.numPages)

For more information regarding the same, do check out the Python certification course that will help you in understanding the topic in a better way.

Related questions

0 votes
1 answer
asked Jan 2, 2021 in Python by ashely (50.2k points)
0 votes
1 answer
0 votes
1 answer
asked Jul 12, 2019 in Python by Sammy (47.6k points)

Browse Categories

...