1

Rails 4.1.1 Ruby 2.1.2

Gemfile : gem 'prawn', '~> 2.0.0'

I have PDF's working ok. I am now trying to add table in the pdf. But when i add table I get the following error...

undefined method `table' for XPDFClass

I tried adding...

require "prawn/table"

to the top of my file but then i get this error...

cannot load such file -- prawn/table

Any ideas where I might be going wrong?

polarcare
  • 575
  • 1
  • 6
  • 24

2 Answers2

1

Make sure you have prawn-table in your Gemfile, in addition to the prawn gem. That should solve your problem.

Gregory Brown
  • 1,380
  • 9
  • 15
  • Yes I did try that. In my Gemfile I have "gem 'prawn-table'" directly under the prawn gem. I then add the require 'prawn/table' to top of my file, but I still get "undefined method `table' for XPdf:Class" – polarcare Mar 05 '15 at 20:29
0

It was my own fault, I had table outside of a method. Working version...

def table_rows
  table([
    ["X", "Y"]
  ])
end

When it wasn't working I had it as just...

table([
  ["X", "Y"]
])
polarcare
  • 575
  • 1
  • 6
  • 24