Project 2: pdf extractor using python
let us prepare a project of few codes to extract the whole pdf
import pip install PyPDF2
code:
.............................................................................................................................................
from PyPDF2 import PdfFileReader
#read a pdf file ie. by rb mode
file=open("Handbook.pdf",'rb')
#reader ia s variable use to read file
reader=PdfFileReader(file)
#lets get the info of the pdf document
print("document info:",reader.getDocumentInfo())
print()
#getNumPages() this comand can get you page numbers of pdf
print("number pf pages are:",reader.getNumPages())
#lets take variable "pages" to take comand over get number of pages
pages=reader.getNumPages()
for i in range(0,pages):
print("page number=",i+1)
pageObj = reader.getPage(i)
print(pageObj.extractText())
print()
print(reader.getDocumentInfo().creator)
file.close()
..............................................................................................................................................
OUTPUT:
Comments
Post a Comment