3

I'm looking for well-maintained and well-documented powerful PDF parsing libraries for Python (mainly to extract and parse data from various types of PDFs with different/unpredictable structures, including with the help of reliable and powerful OCR).

Currently I'm aware of the following main projects:


PDFMiner: https://github.com/euske/pdfminer (last commit 11 days ago)

PDFMiner.six: https://github.com/pdfminer/pdfminer.six (last commit 3 days ago - seems to be the most actively maintained project)

^-- not sure to have understood exactly the difference between the two.

The PDFMiner API appears to me a bit overly-complicated to use - see a good example here.


PyPDF2: https://github.com/mstamy2/PyPDF2 (last commit in June 2018)

PyPDF4: https://github.com/claird/PyPDF4 (last commit in May 2019)

Short version: PyPDF4 is a clean break designed to do what PyPDF2 did, but on a more sustainable, business-worthy basis. Yes, in principle we could have just reconfigured PyPDF2 (or PyPDF3, for that matter) until it arrived where we want PyPDF4 to be. Our judgment was that the cost of leaving PyPDF2's assets and liabilities behind was less than the gain from a fresh organizational start.


Modern table parser for PDF with Camelot-py (https://github.com/camelot-dev/camelot) -> this is a great project, but currently only covers parsing of tables in PDFs. Plus it appears to rely on PyPDF2 & PDFMiner.six for actually reading the PDF.


So what other general-purpose powerful, reliable (=accurate and robust) and modern (=with great API) open-source PDF parsing library that is well maintained exists for Python?

3

Finally I went for OCRmyPDF (https://github.com/jbarlow83/OCRmyPDF), which uses tesseract for the actual OCR part (https://github.com/tesseract-ocr/tesseract) - as I understand tesseract is a OCR tool that has been open-sourced by Google.

OCRmyPDF has great documentation, also works from the command line and has many language packs:

ocrmypdf -l eng pdf_to_ocr.pdf new_pdf_with_ocr.pdf


In order to extract text from the PDF, the best tool I found is pdftotext (https://github.com/jalan/pdftotext), which is a Python wrapper for Poppler (https://poppler.freedesktop.org/). I am getting very satisfying results with this tool, far better than PyPDF2.

| improve this answer | |
  • Good question & good answer. Please click the tick to accept your own answer. Doing so will help others who read this question in future. Thanks for that recommendation :-) – Mawg says reinstate Monica Nov 19 '19 at 13:20
  • 1
    Thanks for the tip, I missed that last step in accepting the answer :) indeed hope this info can save others some time. – Jean Monet Nov 19 '19 at 15:45
  • Welcome aboard. Hope you'll be active :-) – Mawg says reinstate Monica Nov 19 '19 at 18:14

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.