Download:
Download(18.5 MB, 8:14)
Alternativer Download für iPod & Apple TV(16.8 MB, 8:14)
Resourcen:
- Episode 153: PDFs with Prawn
- Rethinking PDF Creation in Ruby
- PDFKit
- wicked_pdf
- Full episode source code
Quellcode:
[bash]
bundle install
rake middleware
[/bash]
[ruby]
# config/application.rb
config.middleware.use "PDFKit::Middleware", :print_media_type => true
[/ruby]
[html]
<!– layouts/application.html.erb –>
<%= stylesheet_link_tag ‚application‘, :media => "all" %>
<!– orders/show.html.erb –>
<p id="pdf_link"><%= link_to "Download Invoice (PDF)", order_path(@order, :format => "pdf") %></p>
[/html]
[css]
/* application.css */
@media print {
body {
background-color: #FFF;
}
#container {
width: auto;
margin: 0;
padding: 0;
border: none;
}
#line_items {
page-break-before: always;
}
#pdf_link {
display: none;
}
}
[/css]