I have used this code to convert pdf to text.
input1 = '//Home//Sai Krishna Dubagunta.pdf'
output = '//Home//Me.txt'
os.system(("pdftotext %s %s") %( input1, output))
I have created the Home directory and pasted the source file in it.
The output I get is
1
And no file with .txt was created. Where is the Problem?
There are various Python packages to extract the text from a PDF with Python.
pdftotext
package: Seems to work pretty well, but it has no options e.g. to extract bounding boxes
For Ubuntu:
sudo apt-get install build-essential libpoppler-cpp-dev pkg-config python-dev
import pdftotext
with open("lorem_ipsum.pdf", "rb") as f:
pdf = pdftotext.PDF(f)
# Iterate over all the pages
for page in pdf:
print(page)
# Just read the second page
print(pdf.read(2))
# Or read all the text at once
print(pdf.read_all())
Install it with pip install pdfminer.six
. A minimal working example is here.