Save 37% off PRO during our Black Friday Sale! »

Wicked PDF - Essential Rails Gems

Wicked PDF - Essential Rails Gems

PDF Creation that Doesn't Suck

3b5cb0411cbd1012acab1b60f7ce3606?s=128

Jesse Wolgamott

April 10, 2013
Tweet

Transcript

  1. WICKED PDF Essential Rails Gems by @jwo for @houstonrb Tuesday,

    April 9, 13
  2. PDF Creation that doesn’t suck Prawn Prince PDF Pdfkit Rtek

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

    Can use javascript in your PDFs Tuesday, April 9, 13
  4. 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
  5. Rails 4? Does not work for CSS/JS at time of

    creation :( Tuesday, April 9, 13
  6. Install gem install wicked_pdf Tuesday, April 9, 13

  7. Development group :development do gem "wkhtmltopdf-binary" end Tuesday, April 9,

    13
  8. Production group :production do gem 'wkhtmltopdf-heroku' end Tuesday, April 9,

    13
  9. Recommended Workflow Create the PDF monthly Save PDF to S3

    in CarrierWave Send link to download file Tuesday, April 9, 13
  10. 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
  11. Saving PDFs (CarrierWave) pdf = RendersPdf .new("statement/_show", {as_of_date: Date.today} )

    .render account.account_statement.store!(pdf) Tuesday, April 9, 13
  12. 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
  13. Example Tuesday, April 9, 13

  14. What did we just see? Using Bootstrap in your PDFs

    Using Morris.js to graph in your PDFs Tuesday, April 9, 13
  15. Codebase https://github.com/jwo/railsdotpdf http://railsdotpdf.herokuapp.com/ Tuesday, April 9, 13