I want to generate pdf using rake task running through whenever cron job rails.When i running this rake task by this command on console it is generating pdf fine
bundle exec rake auto_invoice_email
if i give this command
which wkhtmltopdf
then i have this path "/usr/bin/wkhtmltopdf"
But when i run it through cron job then i have this error
rake aborted!
Failed to execute:
"/usr/bin/wkhtmltopdf" -q - -
Error: PDF could not be generated!
Tasks: TOP => auto_invoice_email
(See full trace by running task with --trace)
how and where i can specify path for wkhtmltopdf for cron job
Any help?
here is rake task
require 'rubygems'
require 'wicked_pdf'
require 'erb'
require 'date'
task :auto_invoice_email => :environment do
#$PATH = '/usr/bin/wkhtmltopdf'
include ApplicationHelper
users = User.find_subscribers
unless users.blank?
users.each do |user|
@user = user
content = File.read "#{Rails.root}/app/views/accountings/generate_invoice_pdf_rake.html.erb"
template = ERB.new(content)
html_content = template.result(binding)
pdf= WickedPdf.new.pdf_from_string(html_content, :wkhtmltopdf => '/usr/bin/wkhtmltopdf')
name = "#{Rails.root}/public/#{user.subscriber.downcase+" "+Time.now.to_s}.pdf"
File.open(name, 'wb') do |file|
file << pdf
end
end
end
end
Thanks