Rails: Wkhtmltopdf Runtimeerror (Location of Wkhtmltopdf Unknown)

Rails: wkhtmltopdf RuntimeError (Location of wkhtmltopdf unknown)

do you use static wkhtmltopdf binary? i downloaded it here and extraced it to /path/to/rails_app/bin

and add it to rails like this:

#config/initializers/wicked_pdf.rb
WickedPdf.config = {
:exe_path => Rails.root.join('bin', 'wkhtmltopdf-i386').to_s,
}

wkhtmltopdf-binary not being found on development server

All the elements of solution were in the question.

One forgotten element was that the server was multiuser and wkhtmltopdf was originally installed by another user. As the wkhtmltopdf gem page states, there is a permissions issue during installation; it is then observed that those permissions were assigned to the other user.

As per link to wicked PDF gem, creating an initializer containing:

WickedPdf.config = {
exe_path: '/home/deploy/.rbenv/shims/wkhtmltopdf'
}

solved the issue.

WKHTMLTOPDF path in ROR application

In the source of wkhtmltopdf it looks like all it is doing is running File.exists? on that path:

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

So we gotta double check the assumption that wkhtmltopdf is correctly installed at /usr/local/bin/wkhtmltopdf

Could you give a bit more information? Just to verify, what is the output of which wkhtmltopdf

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

You could try specifying the path in the configuration (in an initializer as mentioned in the wkhtmltopdf readme) just to see if that makes a difference too.

And lastly you could move the executable to a different directory, and then specify that in the initializer to see if it maybe has something to do with folder permissions.

Environment conflicts with WickedPDF and Heroku

WickedPdf tries to figure out where the wkhtmltopdf binary lives, but can have a hard time on some systems (particularly shared servers).

You probably have to set it manually in an initializer something like this:

bin_location = case Rails.env
when 'production' then "/wherever/your/binary/is/bin/wkhtmltopdf"
when 'development' then "/local/path/to/wkthmltopdf"
else `which wkhtmltopdf`
end
WickedPdf.config = { :exe_path => bin_location }

an issue with the wkhtmltopdf-binary gem in the production

It sounds like your production server doesn't have an xserver installed.

sudo apt-get install libxrender1

should work for you on Ubuntu.



Related Topics



Leave a reply



Submit