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
本文介绍了如何通过git clone下载Prawn库,将它整合到Rails应用中,并通过配置和初始化模块来实现PDF文件的生成。详细步骤包括:安装依赖、配置加载路径、引入Prawn核心组件、以及测试Prawn功能。
1216

被折叠的 条评论
为什么被折叠?



