开发者

generating a pdf file using prawnto (mysql table)

开发者 https://www.devze.com 2023-01-10 08:33 出处:网络
I\'ve used Prawnto quite a bit in a few Rails projects. As I\'m trying to integrate it into this project, I\'m unable to get it working!

I've used Prawnto quite a bit in a few Rails projects. As I'm trying to integrate it into this project, I'm unable to get it working!

I've installed the plugin, and the files are there: script/plugin install git://github.com/thorny-sun/prawnto.git

I've added this line to environment.rb in the config block:

config.gem "prawn"

Prawn is installed as a gem and configured:

gem list --local prawn (0.5.1) prawn-core (0.5.1) prawn-format (0.2.1) prawn-layout (0.2.1)

Here's an update. There appears to be two ways to invoke Prawnto: as I stated above using the "prawnto" method call, and via a respond_to block, like so:

...among others.

And lastly, I've set up my controller method to handle the PDF:

Hi there, I've used Prawnto quite a bit in a few Rails projects. As I'm trying to integrate it into this project, I'm unable to 开发者_StackOverflow社区get it working!

I've installed the plugin, and the files are there: script/plugin install git://github.com/thorny-sun/prawnto.git

I've added this line to environment.rb in the config block:

config.gem "prawn"

Prawn is installed as a gem and configured:

gem list --local prawn (0.5.1) prawn-core (0.5.1) prawn-format (0.2.1) prawn-layout (0.2.1)

Here's an update. There appears to be two ways to invoke Prawnto: as I stated above using the "prawnto" method call, and via a respond_to block, like so:

...among others.

And lastly, I've set up my controller method to handle the PDF:

def show @book = Book.find(params[:id]) @book_pdf= Book.find(:all)

respond_to do |format|
  format.html # show.html.erb
  format.xml  { render :xml => @book }
  format.pdf { render :layout => false }
  end

end the result is Missing template books/show.erb in view path app/views


I'd definitly recommend you this screencast: - http://railscasts.com/episodes/153-pdfs-with-prawn

There is another one concerning pdfkit which looks much more cool!

0

精彩评论

暂无评论...
验证码 换一张
取 消