How can i use Prawn to generate PDF of form data in Sinatra?
My form is at the index action of the site but Prawn doesn't recognize the variables passed in.i've found this code in the documentation at http://prawnpdf.org/docs/0.11.1/Prawn/Document.html.
get '/download' do content ="Hello World" Prawn::Document.generate"example.pdf" do |pdf| pdf.font"Times-Roman" pdf.draw_text content, :at => [200,720], :size => 32 end end
Now this is great, but when i try to pass in my variables from the parameters like this :
post '/resume' do @name = params.fetch 'name' . . . end
And then if i add that into the/download route like this :
get '/download' do Prawn::Document.generate"example.pdf" do |pdf| pdf.font"Times-Roman" pdf.draw_text @name, :at => [200,720], :size => 32 end end
It it will draw nothing.Also, weirdly, it generates a pdf file but doesn't redirect to it and i have to manually load it.
Really stuck on this one - advice?