All Courses

How to extracting text from PDF file using python

By Subham, 2 years ago
  • Bookmark
0

extract pdf file using python

Pdf
Python
Text file
1 Answer
0

Extracting text from PDF file using python :


# importing required modules
import PyPDF2
  
# creating a pdf file object
pdfFileObj = open('file_path', 'rb')
  
# creating a pdf reader object
pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
  
# printing number of pages in pdf file
print(pdfReader.numPages)
  
# creating a page object
pageObj = pdfReader.getPage(1)
  
# extracting text from page
print(pageObj.extractText())
  
# closing the pdf file object
pdfFileObj.close()

Your Answer

Webinars

Live Masterclass on : "How Machine Get Trained in Machine Learning?"

Jun 1st (5:32 PM) 515 Registered
More webinars

Related Discussions

Running random forest algorithm with one variable

View More