Grim is a simple gem for extracting (reaping) a page from a pdf and converting it to an image as well as extract the text from the page as a string. It basically gives you an easy to use api to ghostscript, imagemagick, and pdftotext specific to this use case.
You will need ghostscript, imagemagick, and xpdf installed. On the Mac (OSX) I highly recommend using Homebrew to get them installed.
brew install ghostscript imagemagick xpdf
gem install grim
pdf = Grim.reap("/path/to/pdf") # returns Grim::Pdf instance for pdf count = pdf.count # returns the number of pages in the pdf png = pdf.save('/path/to/image.png') # will return true if page was saved or false if not text = pdf.text # returns text as a String pdf.each do |page| puts page.text end
See LICENSE for details.