生成pdf

cd rails_root
git clone git://github.com/sandal/prawn.git vendor/prawn

$ cd vendor/prawn/
$ git checkout origin/stable
$ git checkout -b stable

Now, prawn-core depends on some helper utilities, such as ttfunk and pdf-inspector (for running tests)


Note that when installing your Rails app on a staging or production server, you will need to init and update the submodule you just created in your project. That is, run these two commands from the root of your project to bring in Prawn. Then cd into vendor/prawn and run them again to bring in ttfunk and pdf-inspector.

config.load_paths << "#{RAILS_ROOT}/vendor/prawn/lib"

Then create a file called config/initializers/prawn.rb and in it, add one of the following lines, depending on your Prawn version:
Prawn through 0.8.4: require "prawn/core"
Prawn 0.9+ or git: require "prawn"
Now, Prawn should be ready to go. To test it, try this out:

$ ./script/console
Loading development environment (Rails 2.3.3)
>> Prawn::BASEDIR
=> "/home/myuser/devel/myproj/vendor/prawn"



sudo gem install pdf-reader
[sudo] password for simon:
Successfully installed Ascii85-1.0.1
Successfully installed pdf-reader-0.10.0
2 gems installed

sudo gem install ttfunk
[sudo] password for simon:
Successfully installed ttfunk-1.0.1
1 gem installed


script/plugin install git://github.com/thorny-sun/prawnto.git
Mime::Type.register_alias "application/pdf", :pdf
--------------------------------------------------------

prawn.gemspec
prawn dependency

猜你喜欢

转载自tongxiaoming520.iteye.com/blog/1158663