views:

29

answers:

1

I have used the following syntax to generate a pdf file:

Prawn::Document.generate("#{RAILS_ROOT}/public/pdf/generate.pdf") do                                                     
  pdf.text "hello"
end

But when I look for the file within the /public/pdf/ folder, I dont find any file.

Well my controller code for this is

def generate
  respond_to do |format|                                                                                               
    format.pdf{ render :file => "#{RAILS_ROOT}/public/pdf/generate.pdf"}
  end
end
A: 

It could be something else, but the code supplied doesn't seem to work:

Prawn::Document.generate("x.pdf") do
  pdf.text "Hello"
end

gives me

NameError: undefined local variable or method `pdf' for #<Prawn::Document:0x352b6e4>
        from c:/ruby/lib/ruby/gems/1.8/gems/prawn-core-0.8.4/lib/prawn/graphics/color.rb:72:in `method_missing'
        from (irb):3

You should be able to see if you're getting something similar in your log file.

I think the pdf. is not needed:

Prawn::Document.generate("x.pdf") do
  text "Hello"
end
Mike Woodhouse