-
Notifications
You must be signed in to change notification settings - Fork 0
Pdf kit
diegoesp edited this page Aug 25, 2012
·
5 revisions
Here's the general reference: https://github.com/pdfkit/pdfkit/wiki/Installing-WKHTMLTOPDF
- Download the correct build from http://code.google.com/p/wkhtmltopdf/. Remember to check if your linux is x32 or x64 with "uname -a"
- Extract the bz2 (tar xjvf) to /usr/local/bin. It is just a binary executable so it makes sense to leave it there.
- 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
- Add the pdfkit gem to the gemfile
- Install unicorn gem as your new server because we need a multi-threaded server for fetching multiple resources for the HTML (css / js / etc).
- Add "unicorn" gem to the gemfile
- Add a single file "config/unicorn.conf" with only this line: "worker_processes 3" (omit quotation marks)
- 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:
- 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
- Use the tester page whose link is accessible in the index for the web site: http://localhost:8080/pdfkit