I've gone through all the questions about the matter in the SO and tried all the tricks without getting much further.
Environment is Rails 3.0.9 in development mode, running on Ubuntu 10.4 in a VMPlayer VM.
I installed wkhtmltopdf using apt-get, and the binary is found from /usr/bin/. The binary works just fine when used from terminal.
The exact error message is as follows:
command failed: "/usr/bin/wkhtmltopdf" "--page-size" "letter" "--orientation" "landscape" "--quiet"
I have following configuration set in application.rb:
PDFKit.configure do |config|
config.wkhtmltopdf = "/usr/bin/wkhtmltopdf"
config.default_options = {
:page_size => 'letter',
:orientation => 'landscape'
}
In rails console, creating a PDFKit.new, with the same url which produces that error, and saving that into a file works fine. The code in the actions looks like this:
@url = params[:url]
@kit = PDFKit.new(Base64.decode64(@url))
@filename = "#{Time.now.strftime("%Y%m%d-%H%M%S")}owner.pdf"
@filepath = "#{Rails.root}/public/pdfs/#{@filename}"
@file = File.open(@filepath, 'w')
@kit.to_file(@file.path)
@file = File.open(@filepath, 'r')
send_data(@file.read, :type => "pdf", :filename => @filename)
So basically, the url comes in encoded with Base64 encoding, and decoded in the controller action. The url encode/decode part works fine, that should not be part of the problem.
The pdf is (/should be) saved into a time-stamped file and also sent to user to download.
Permissions are set as an answer in this question suggests. I've tried using the wkhtmltopdf gem, no help.
I'm really getting frustrated with this and would greatly appreciate any help to me into right direction of what's wrong.
EDIT: The command itself seems to work fine. I copy pasted the command from the error message into terminal, and it works. So I can't think of any other reason for the problem than permission issues. Checking...