-
Notifications
You must be signed in to change notification settings - Fork 39
QuickStart
dcvezzani edited this page Nov 3, 2014
·
1 revision
This gem's README.md
does not include the git
option in the gem
declaration. Apparently it's needed because it appeared I was pulling in some other version.
rails new <app>
cd <app>
Update Gemfile
. Make sure that prawn-rails
comes before prawn-table
.
gem 'prawn-rails', '0.1.0', git: 'https://github.com/cortiz/prawn-rails.git'
gem 'prawn-table', '0.2.1'
Install new gems
bundle install
Create config/initializers/prawn-rails.rb
to set prawn
defaults
require 'prawn'
PrawnRails.config do |config|
config.page_layout = :portrait
config.page_size = "A4"
config.skip_page_creation = false
end
Create app/views/<controller name>/<action>.pdf.prawn
prawn_document(:page_layout => :landscape) do |pdf|
pdf.text "Hello World"
end
Start app and navigate to <controller>/<action>.pdf
E.g.,
rails s
open http://localhost:3000/<controller>/<action>.pdf
You should see a pdf file generated with the content, "Hello World"