Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Wicked PDF - Essential Rails Gems

Wicked PDF - Essential Rails Gems

PDF Creation that Doesn't Suck

Jesse Wolgamott

April 10, 2013
Tweet

More Decks by Jesse Wolgamott

Other Decks in Programming

Transcript

  1. PDF Creation that doesn’t suck Prawn Prince PDF Pdfkit Rtek

    (latex) DocRaptor acts_as_flying_saucer Tuesday, April 9, 13
  2. Why Wicked PDF Great API Uses HTML/CSS you’re used to

    Can use javascript in your PDFs Tuesday, April 9, 13
  3. Bad Parts Difficult to render outside of Rails Request (Though

    not impossible, see codebase at end) The Binary is hard to get configured to be found Tuesday, April 9, 13
  4. Rails 4? Does not work for CSS/JS at time of

    creation :( Tuesday, April 9, 13
  5. Recommended Workflow Create the PDF monthly Save PDF to S3

    in CarrierWave Send link to download file Tuesday, April 9, 13
  6. Hints Have a report.scss that includes parts you need to

    include Have a report.js that includes parts asset_sync is your friend Easiest to render partials Tuesday, April 9, 13
  7. Saving PDFs (CarrierWave) pdf = RendersPdf .new("statement/_show", {as_of_date: Date.today} )

    .render account.account_statement.store!(pdf) Tuesday, April 9, 13
  8. Must Do’s Add “application/pdf”, :pdf to MimeTypes respond_to do |format|

    format.html format.pdf do render :pdf => "file_name", layout: 'report.html', "javascript-delay" => 5000 end end Tuesday, April 9, 13
  9. What did we just see? Using Bootstrap in your PDFs

    Using Morris.js to graph in your PDFs Tuesday, April 9, 13