Read PDF in Python and convert to text in PDF

Your expression

("pdftotext %s %s") %( input1, output)

will translate to

pdftotext //Home//Sai Krishna Dubagunta.pdf //Home//Me.txt

which means that the first parameter passed to pdftotext is //Home//Sai, and the second parameter is Krishna. That obviously won’t work.

Enclose the parameters in quotes:

os.system("pdftotext '%s' '%s'" % (input1, output))

Leave a Comment