Reputation: 9385
I've done hours of research trying to get PDFKit to work in my production environment. Everything works fine in development, and "kind of" works on my production server.
wkhtmltopdf google.com public/test5.pdf
-- so I know that wkhtmltopdf is installed and workingrails console
where i can run kit = PDFKit.new('http://google.com')
then file = kit.to_file('public/test.pdf')
-- so at least in rails console I know that PDFKit is able to run successfullyBut, this just isn't working on the actual website. When I visit the URL (which works in development mode) http://staging.myapp.com/tours/5/print_tour.pdf
I get the "We're sorry but something went wrong" error. My Passenger error log only shows this:
bundle exec which wkhtmltopdf
fine from my web root?I'm stumped as wkhtmltopdf runs fine from the command line, as does PDFKit in rails console, but somehow something breaks when serving the page from Nginx/Passenger. Help! :-)
Upvotes: 0
Views: 6967
Reputation:
What path does which wkhtmltopdf return and is it different than the path in your development environment?
PDFkit expects wkhtmlpdf to be in /usr/local/bin so if you haven't installed the wkhtmlpdf binary to that location, make sure you specified the path in an initializer like so:
# config/initializers/pdfkit.rb
PDFKit.configure do |config|
config.wkhtmltopdf = '/path/to/wkhtmltopdf'
# config.root_url = "http://staging.myapp.com" # Use only if your external hostname is unavailable on the server.
end
If your problem isn't related to PDFkit trying to call wkhtmltopdf from the wrong path on the server, have you tried seeing if another gem like wicked_pdf is able to use wkhtmltopdf properly?
Upvotes: 1