I am trying to create a pdf using wicked-pdf from Ruby On Rails. It works great in development mode, but when I deploy in production I get the error:
wkhtmltopdf is not executable
I have the wkhtmltopdf executable located at:
rails_root/bin/wkhtmltopdf-i386
Warbler is setup to include the bin folder in the war:
config.includes = FileList["classes/*","bin/*"]
I have wicked pdf configured to find the bin in the correct spot:
WickedPdf.config = {
:exe_path => Rails.root.join('bin', 'wkhtmltopdf-i386').to_s
}
I run warbler and then deploy the war on jBoss application server. When I try to generate a PDF I get the error about it not being executable. It runs fine in development mode - not in a war.
The permissions on the binary should be fine:
-rwxr-xr-x 1 username group 11446024 Apr 3 11:40 wkhtmltopdf-i386
Instead of manually including the wkhtmltopdf binary, I tried using wkhtmltopdf-binary gem. This too worked fine in development mode, but Wicked PDF can't find the binary in production.
Update: I changed the wicked-pdf config to point to the binary provided by 'wkhtmltopdf-binary' gem when in production mode. It also is getting wkhtmltopdf is not executable
error. The path ends up being: jboss-5.1.0.GA/server/default/tmp/3j001-3g0fg5-hf2xi49o-1-hf2xiuld-9q/myrailsapp.war/WEB-INF/gems/gems/wkhtmltopdf-binary-0.9.9.1/bin/wkhtmltopdf_linux_386
Do you install wkhtmltopdf separately or allow your gem file to install it?
I'd do the following:
gem 'wicked_pdf', '~> 0.9.10'
gem 'wkhtmltopdf-binary', '~> 0.9.9'
and then set the config:
WickedPdf.config = {
exe_path: "#{ENV['GEM_HOME']}/gems/wkhtmltopdf-binary-#{Gem.loaded_specs['wkhtmltopdf-binary'].version}/bin/wkhtmltopdf_linux_386"
}
This bit #{Gem.loaded_specs['wkhtmltopdf-binary'].version}
queries your gems to find the current version if you were to ever change the version of the gem, your prod server would still be able to find the proper folder.