Skip to content
diegoesp edited this page Aug 25, 2012 · 5 revisions

Here's the general reference: https://github.com/pdfkit/pdfkit/wiki/Installing-WKHTMLTOPDF

Linux

  1. Download the correct build from http://code.google.com/p/wkhtmltopdf/. Remember to check if your linux is x32 or x64 with "uname -a"
  2. Extract the bz2 (tar xjvf) to /usr/local/bin. It is just a binary executable so it makes sense to leave it there.
  3. Ensure that there's an executable in the path called "wkhtmltopdf" because that is what the gem will be looking for. For example, I made a hard link to the extracted file wkhtmltopdf-amd64
  4. Add the pdfkit gem to the gemfile
  5. Install unicorn gem as your new server because we need a multi-threaded server for fetching multiple resources for the HTML (css / js / etc).
  6. Add "unicorn" gem to the gemfile
  7. Add a single file "config/unicorn.conf" with only this line: "worker_processes 3" (omit quotation marks)
  8. Launch unicorn instead of WEBRick using this command: "bundle exec unicorn_rails -c config/unicorn.conf" (omit quotation marks)

Additional considerations in pretty reports context:

  1. Take into consideration that PDFKit has to authenticate to fetch the PDF so use authentication in the URL if we keep the HTML authentication: http://user:lacasadelarte@localhost:8080/reports/1.html
  2. Use the tester page whose link is accessible in the index for the web site: http://localhost:8080/pdfkit
Clone this wiki locally