Extracting Tables from PDF files in Ruby
You may want to take a look at this answer (How to convert PDF to Excel or CSV in Rails 4). It solves the same problem you are trying to solve.
Checkout this gem I think it's what your looking for: pdf-reader gem