Hermann Ingjaldsson Hermann Ingjaldsson - 1 month ago 13
Ruby Question

ruby install yob pdf reader

I'm trying to install the yob pdf reader: https://github.com/yob/pdf-reader#readme

I'm following the directions there and do:

gem install pdf-reader


and that reports success.

I place a pdf in my directory, name it
1.pdf
.

Then I create a script that has the following code:

reader = PDF::Reader.new("1.pdf")


when I run that script I get the following error:

uninitialized constant PDF (NameError)


Googling it hasn't been very successful so far.

How do I solve this?

Answer

If it's a pure ruby script, you may be missing the following at the beginning:

require 'rubygems'
require 'pdf-reader'

You can also specify the version of the gem that you want to require, in case you have multiple versions installed:

require 'rubygems'
gem 'pdf-reader', "~> 0.10.0"
require 'pdf-reader'
Comments