I'm looking for a PDF library which will allow me to extract the text from a PDF document. I've looked at PyPDF, and this can extract the text from a PDF document very nicely. The problem with this is that if there are tables in the document, the text in the tables is extracted in-line with the rest of the document text. This can be problematic because it produces sections of text that aren't useful and look garbled (for instance, lots of numbers mashed together).
I'm looking for something that's a bit more advanced. I'd like to extract the text from a PDF document, excluding any tables and special formatting. Is there a library out there that does this? Or am I forced to do some post-processing on the output text to get rid of these sections?
N.N.closed as off-topic by Anderson Green, CRABOLO, Ken Herbert, HaveNoDisplayName, Shankar DamodaranApr 13 '15 at 2:28
Advanced Python 3 Programming Techniques. The shortcut explains a variety of procedural, object-oriented, and practical-type methods,and the knowledge offered shall be a substantial addition to mostPython programmers’ toolboxes. Name Size Python-2/ - Python/ - A Byte of Python.pdf 609K A Learner's Guide to Programming Using the Python Language.pdf 17M A Primer on Scientific Programming with Python.pdf 6.8M Algorithms with Object-Oriented Design Patterns in Python.chm 3.3M Beginning Game Development with Python and Pygame.pdf 7.6M Beginning Python.
This question appears to be off-topic. The users who voted to close gave this specific reason:
- 'Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.' – Anderson Green, CRABOLO, Ken Herbert, HaveNoDisplayName, Shankar Damodaran
2 Answers
You can also take a look at PDFMiner, an other PDF parser in Python.
The particularity of PDFMiner that can interest you is that you can control how it regroup text parts when doing the extracting. You do this by specifing the space between lines, words, characters, etc. So, maybe by tweeking this you can achieve what you want (that depends of the variability of your documents). PDFMiner can also give you the location of the text in the page, it can extract data by Object ID and other stuff. So dig in PDFMiner and be creative!
But your problem is really not an easy one to solve because, in a PDF, the text is not continous, but made from a lot of small groups of characters positioned absolutely in the page. The focus of PDF is to keep the layout intact. It's not content oriented but presentation oriented.
EtienneEtienne![Advanced Advanced](https://www.edigitalagency.com.au/wp-content/uploads/best-python-tutorials-on-pdf.png)
That's a difficult problem to solve since visually similar PDFs may have a wildly differing structure depending on how they were produced. In the worst case the library would need to basically act like an OCR. On the other hand, the PDF may contain sufficient structure and metadata for easy removal of tables and figures, which the library can be tailored to take advantage of.
I'm pretty sure there are no open source tools which solve your problem for a wide variety of PDFs, but I remember having heard of commercial software claiming to do exactly what you ask for. I'm sure you'll run into them while googling.
akaiholaakaihola