World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITians, only for AI Learners.
Designed by IITians, only for AI Learners.
New to InsideAIML? Create an account
Employer? Create an account
# 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()