Friday, September 18, 2015

wkhtmltopdf config on Mac

I ran into a snarl of a problem trying to get wkhtmltopdf working on my mac.  The long of the short of it, these instructions (should) work. 


Get the right version installed via brew:
brew uninstall wkhtmltopdf
cd /usr/local/Library/Formula/
git checkout https://gist.github.com/389944e2bcdba5424e01.git /usr/local/Library/Formula/wkhtmltopdf.rb
brew install wkhtmltopdf

WickedPDF needs to point to the development env properly:

# config/development.rb
WickedPdf.config = {
  :exe_path => "/usr/local/Cellar/wkhtmltopdf/0.9.9/bin/wkhtmltopdf",
  :root_url => "http://localhost:3000"}


Make sure you are not running a single threaded application server. In my cause configure unicorn:

# config/unicorn.rb
if ENV["RAILS_ENV"] == "development"  worker_processes 3
end
timeout 30

And last but not least. I'm using RubyMine.  Point the debugging environment to the unicorn config:


I hope this saves someone some time.

Credits:
http://stackoverflow.com/questions/12517640/why-does-pdfkit-wkhtmltopdf-hang-but-renders-pdf-as-expected-when-rails-app-is-k
https://github.com/pdfkit/pdfkit

No comments:

Post a Comment