convert pdf to string python code example
Example 1: pdf to string python
pip install PyPDF2
import PyPDF2
pdfFileObject=open(r"F:\fileName.pdf",'rb')
pdfReader = PyPDF2.PdfFileReader(pdfFileObject) //Creating reader obj
print(" No. Of Pages :", pdfReader.numPages)//To know no.of pages
Example 2: pdf to text python
import tabula
df = tabula.read_pdf("sample.pdf",pages=[1,2])
df[1]
Example 3: pdf to string python
import PyPDF2
pdfFileObject = open(r"F:\pdf.pdf", 'rb')
pdfReader = PyPDF2.PdfFileReader(pdfFileObject)
print(" No. Of Pages :", pdfReader.numPages)
pageObject = pdfReader.getPage(0)
print(pageObject.extractText())
pdfFileObject.close()