I am using the pdfkit gem and it is working in development using wkhtmltopdf from the wkhtmltopdf-binary gem.
On the server pdfkit fails with the error
undefined method `chomp' for nil:NilClass
at
shared/bundle/ruby/2.1.0/gems/pdfkit-0.8.2/lib/pdfkit/configuration.rb:22:in `wkhtmltopdf'
The method that fails is
def wkhtmltopdf
@wkhtmltopdf ||= (defined?(Bundler::GemfileError) && File.exists?('Gemfile') ? `bundle exec which wkhtmltopdf` : `which wkhtmltopdf`).chomp
end
After some debugging it appears that `bundle exec which wkhtmltopdf' when called from this method returns blank.
When called from the commandline in application root it gives
/var/www/<app>/shared/bundle/ruby/2.1.0/bin/wkhtmltopdf
I have tried initializing the value of @wkhtmltopdf from the initializer as follows
PDFKit.configure do |config|
if Rails.env.production?
config.wkhtmltopdf = "/var/www/<app>/shared/bundle/ruby/2.1.0/bin/wkhtmltopdf"
end
config.default_options = {
:page_size => 'A4',
}
end
But I still get the same error. ie it is still trying to run the 'which' command and failing with a blank.