I have an HTML form where a user can upload a PDF.
I want to extract the whole text from the PDF, search in it for specific words and then store them in my database. Any ideas?
I don't ask you for the whole code of course, but something to begin with. Like a library or something like OCR, but free.
-
1i work in php . that's why i use that tags – martha t Nov 13 '17 at 13:21
-
1Not sure if this is an option in your scenario, but consider distributing fillable PDFs beforehand and then you can easily extract structured data from it. – Vlastimil Ovčáčík Nov 18 '17 at 13:28
-
Why are you thinking of OCR? Aren't these PDFs text? – Mawg says reinstate Monica Dec 10 '18 at 12:44
If the pdf has been created programmatically, rather than scanned, the python library pdfminer can extract the text for you.
It and python are free, gratis & open source, and are available for most platforms.
-
1Thanks for the response! I am afraid that the pdf it's scanned plus i don't know much about Python ! I work mostly in java , c++ , php , html . – martha t Nov 13 '17 at 13:23
-
2The problem with scanned pdf files is that basically they are images, with possibly some attempt at OCR. You could look at github.com/tesseract-ocr/tesseract for an Apache Licenced OCR it is C but there are wrappers for python, java and a few others. – Steve Barnes Nov 13 '17 at 14:42
What about this S.O question ?
The article OCR in PHP: Read Text from Images with Tesseract explains more.
There is a PhpOcr project on SourceForge.
Tesarect would seem to be your best bet.