from urllib.request importurlopenfrom pdfminer.pdfinterp importPDFResourceManager, process_pdffrom pdfminer.converter importTextConverterfrom pdfminer.layout importLAParamsfrom io importStringIOfrom io importopendefreadPDF(pdfFile):
rsrcmgr=PDFResourceManager()
retstr=StringIO()
laparams=LAParams()
device= TextConverter(rsrcmgr, retstr, laparams=laparams)
process_pdf(rsrcmgr, device, pdfFile)
device.close()
content=retstr.getvalue()
retstr.close()returncontent
pdfFile= urlopen("http://pythonscraping.com/pages/warandpeace/chapter1.pdf")
outputString=readPDF(pdfFile)print(outputString)
pdfFile.close()