What's the benefit to using this over `pdftotext` and/or `pdfimages | convert | tesseract`?
Show HN: An API to extract texts from images and PDF files
21–30 of 33 posts
Re: Show HN: An API to extract texts from images and PDF files
#22Why would someone want to use an API instead of a library?
Re: Show HN: An API to extract texts from images and PDF files
#23Any custom requests? Let us *know.
Re: Show HN: An API to extract texts from images and PDF files
#24Why would someone want to use an API instead of a library?
some langages might not have an appropriate library, some might want to not have heavy processes on their device (mobiles). We also think that's easier to use as there is nothing to install. That mainly depends on your case.
1) Mobiles have pretty good CPUs. I think uploading and waiting for response would be slower and less reliable.
2) If the mobile user doesn't have an internet connection, the app won't work.
3) As a developer, I would be dependant on an external service, that could stop working someday.
Re: Show HN: An API to extract texts from images and PDF files
#25I'm excited to try this.. so figure out a way to take my money soon.
Re: Show HN: An API to extract texts from images and PDF files
#26What's the benefit to using this over `pdftotext` and/or `pdfimages | convert | tesseract`?
Also, it's an "API" (looks more like a url poiting to a CGI program to me, but whatever). API's are "cool" and "fun", while running local programs that you have control over is old and boring and not the future of computing.
Re: Show HN: An API to extract texts from images and PDF files
#27This follows the API documented by Stampin (minus the throttling errors)--it does not currently do the OCR, but as mentioned elsewhere by zdw you can probably get tesseract to get you like 80% of the way there. If you wanted to use that, you'd likely just replace the hacky `pdftotext` callout with your preferred toolchain.
You'll need Ruby, Sinatra, and the Xpdf tools, I believe.
Dual-licensed under the AGPL, BSD, and WTFPL licenses. idklol.
The code:
require 'sinatra'
require 'json'
use Rack::Logger
post '/extracttext' do
begin
status 204 and return unless params["file"] != nil
type = params["type"] || "text"
lang = params["lang"] || "en"
tmpfilename = params["file"][:tempfile].path
`pdftotext #{tmpfilename}`
File.delete(tmpfilename)
convfile = File.open("#{tmpfilename}.txt","r")
lines = convfile.read.split("\n")
convfile.close
File.delete(convfile.path)
content_type "application/json"
{"text"=>lines}.to_json
rescue
status 500 and return
end
end
EDIT:For God's sake run this in a jail and only on an internal network!
Re: Show HN: An API to extract texts from images and PDF files
#28What's the benefit to using this over `pdftotext` and/or `pdfimages | convert | tesseract`?
:)
I love the happy little Unix-style legos of productivity.
Re: Show HN: An API to extract texts from images and PDF files
#29 /\n\nnmrs wn\ufb02qyi mm mm\nTlIIEI\ufb02|\ufb02llllM\u2018l coRe: Show HN: An API to extract texts from images and PDF files
#30The OCR is really useless. I tested it with some reddit "advice animal" memes (because there is a need for transcriptions). You would think that text is pretty simple and easy, but the output I got was like: /\n\nnmrs wn\ufb02qyi mm mm\nTlIIEI\ufb02|\ufb02llllM\u2018l co