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 tNov 13, 2017 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čáčíkNov 18, 2017 at 13:28
-
2Why are you thinking of OCR? Aren't these PDFs text?– Mawg says reinstate MonicaDec 10, 2018 at 12:44
2 Answers
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 tNov 13, 2017 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. Nov 13, 2017 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.