Is there any Python module to convert PDF files into text? I tried one piece of code (mirror) found in Activestate which uses pypdf but the text generated had no space between and was of no use.

This question was originally posted on stack overflow by cnu but it got closed.


The python pdfminer2 or pdfminer3k/pdfminer.six for python 3 libraries can extract the text from pdf files that contain text, (note that scanned documents stored as pdf will contain no text or an attempt at OCR).

It includes the command line pdf2txt.py utility to allow convenient use in the terminal.

|improve this answer|||||

The easiest way to manage pdf in python is PyPDF2 also you can extract text and other information like pages, author, creator...

You said you tried pypdf but it is an outdated version and this issue could be solved. Maybe your problem is with an specific file. If PyPDF2 does not solve your trouble, Did you see unix command pdftotext?? Does it gives you a correct output?

|improve this answer|||||

The only solution that worked for me for UTF-8 content: Apache Tika

from tika import parser
parsed = parser.from_file('/path/to/file.pdf')
|improve this answer|||||

You can use GroupDocs.Conversion Cloud SDK for Python to convert PDF to Text. It can convert other common file formats to text as well. Its free package plan provides 50 free credits per month.

I'm developer evangelist at Aspose.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.