WKHTMLTOPDF path in ROR application

I use the wicked_pdf gem to convert HTML to PDF. According to the descriptions on Github, I installed everything correctly. But I get a runtime error -

RuntimeError (Bad wkhtmltopdf path: / usr / local / bin / wkhtmltopdf): app / controller / orders_controller.rb: 46: in `create

`44 @count = Item.count(:qty) 45 @temp = Item.where(:received => true).count() 46 render :pdf => "Bill" , 47 :template => 'orders/create.pdf.erb', # Excluding ".pdf" extension. 48 page_height: 100, 49 page_width: 80` 

and wkhtmltopdf is installed on my system at / usr / local / bin / wkhtmltopdf

It is indicated that the path for wkhtmltopdf should be where it is already installed.

I can’t understand what the problem is.

+5
source share
3 answers

In the wkhtmltopdf source, does it look like everything it does is launch File.exists? on this way:

https://github.com/mileszs/wicked_pdf/blob/56aa1a195d65eaaf33fbd0254e1e7df99ce1fd1c/lib/wicked_pdf.rb#L41

So, we have to double check the assumption that wkhtmltopdf is correctly set to /usr/local/bin/wkhtmltopdf

Could you give a little more information? Just to check what the output of which wkhtmltopdf

And when you run wkhtmltopdf -V in the console, what do you get?

You can try to specify the path in the configuration (in the initializer, as indicated in readme) to make sure that this also matters.

And finally, you can move the executable file to another directory, and then specify that in the initializer see if it can do something with the permissions on the folder.

+2
source

Did you try to specify the path in the initializer? ({rails.root} /config/initializers/wicked_pdf.rb) ex ..

 WICKED_PDF = { :exe_path => '/usr/local/bin/wkhtmltopdf-amd64'#should be whatever your version is called } 
+2
source

I had a similar problem. Try reinstalling the gem, and also install the library to support this gem. here are the links to install this library on mac and ubuntu:

failed to install wkhtmltopdf with qt fixed in ubuntu 16.04

http://macappstore.org/wkhtmltopdf/

0
source

All Articles