0
votes

I am trying to use wicked_pdf in my rails 3 application. I have followed all the tutorials and I am getting this error:

Failed to execute:
"/usr/local/bin/wkhtmltopdf" -q        "file:////var/folders/_b/50kywsc97r95gvr9gy9nr6700000gn/T/wicked_pdf20130228-874-a51lgi.html" "/var/folders/_b/50kywsc97r95gvr9gy9nr6700000gn/T/wicked_pdf_generated_file20130228-874-1ihqg74.pdf"

I know that wkhtmltopdf exists in the right place because when I type which wkhtmltopdf I am shown the path above. I also get told it's there when I try to brew install again. Furthermore when I type wkhtmltopdf google.com google.pdf it runs fine.

My controller looks like this:

def show #shows some material
@material = Material.find(params[:id])
  respond_to do |format|
    format.html
    format.pdf do
      render :pdf => '#{@material.id}',
             :wkhtmltopdf => '/usr/local/bin/wkhtmltopdf'
    end
  end

end

Any suggestions? Does this seem like a wkhtmltopdf issue or a wicked_pdf issue? I have bundle installed everything and bundle updated everything. I have added the wkhtmltopdf-binary gem (which shouldn't be necessary). It doesn't work on heroku either.

2
you can set a flag to render the stuff as html, does this work?phoet
I'm not sure what you mean. The idea is to render the stuff as a pdf; it already works as html. Or am I missing the point (quite possible)?Finnjon
usually, you include extra infos in a pdf (pagenumber etc) with custom headers. you can set show_as_html as an option to see the output before it's piped into wkhtmltopdf. this is great to make sure that the rendering is actually working as expected.phoet

2 Answers

0
votes

Sounds like there may be a few wkhtmltopdf images out there. If rails is trying to use /usr/local/bin/wkhtmltopdf, try the command /usr/local/bin/wkhtmltopdf from a terminal and see is there are any problems running that one. If you have a few copies around from different gem installs, the one that runs first in your search path may not be the one rails is trying.

Hope it helps

Bob

0
votes

First validate the location of the binaries

  1. Open a terminal prompt and type

    $ which wkhtmltopdf

The return in my machine is

/usr/local/bin/wkhtmltopdf

  1. Validate the binaries are working well

    wkhtmltopdf google.com google It must generate a pdf with the google webpage

  2. Create a class in your initializer

Look at my gist

And that's all