Screencast: PDF Dokumente mit PDFKit generieren

 

Download:

Download(18.5 MB, 8:14)
Alternativer Download für iPod & Apple TV(16.8 MB, 8:14)

 

Resourcen:

 

Quellcode:

bundle install
rake middleware
# config/application.rb
config.middleware.use "PDFKit::Middleware", :print_media_type => true
<!-- 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>
/* 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;
  }
}
Be Sociable, Share!