Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Rails 3.2.9, Ruby 1.9.3
- # wicked_pdf (0.9.2)
- # wkhtmltopdf (0.1.2)
- # wkhtmltopdf-binary (0.9.9.1)
- # Gemfile
- gem 'wicked_pdf'
- gem "wkhtmltopdf-binary", "~> 0.9.9.1"
- # config/application.rb
- require 'wicked_pdf'
- config.middleware.use "WickedPdf::Middleware", :print_media_type => true
- # views/shared/_header.html.erb
- <%= stylesheet_link_tag "application", :media => "all" %>
- # assets/stylesheets/application.css
- @media print {
- .navbar {display: none;}
- }
- # controllers/statements_controller.rb
- # doesn't seem to be picking up any of the rendering options
- def show
- @statements = Statements.find_by_id(params[:id])
- respond_to do |format|
- format.html
- format.pdf do
- render :pdf => 'file_name',
- :template => 'statements/show',
- :handlers => [:erb],
- :formats => [:pdf],
- :print_media_type => true,
- :disable_links => true,
- :disable_internal_links => true,
- :margin => {:top => 300}
- end
- end
- end
- # views/statements/show.html.erb
- <p><%= link_to 'Create PDF document', statement_path(@statement, :format => :pdf) %></p>
- <%= render :partial => 'show' %>
- # views/statements/_show.html.erb
- # irrelevant - working just fine
- # views/statements/show.pdf.erb
- # Also tried renaming to show.pdf.html.erb, then specifying in
- # controllers/statements_controller.rb under :template - no change.
- # Attempting separate template only because it's not picking up
- # print media type (to be able to style with @media)
- <h1>TEST PDF</h1>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement