Bram Jetten
Bram Jetten

Reputation: 282

Wicked PDF generation error in production mode

I'm using WickedPDF in my Rails app to generate PDF files. It's working great on my local machine. In production I'm seeing the following error in my log:

Started GET "/financieel/facturen/2.pdf" for 81.205.74.167 at 2012-09-19 14:58:37 +0200
  Processing by InvoicesController#show as PDF
  Parameters: {"id"=>"2"}
***************WICKED***************
Rendered invoices/show.pdf.haml (6.9ms)
Completed 500 Internal Server Error in 38ms

NoMethodError (undefined method `chomp' for nil:NilClass):
  app/controllers/invoices_controller.rb:22:in `block (2 levels) in show'
  app/controllers/invoices_controller.rb:17:in `show'

In invoices_controller.rb there's nothing unusual:

format.pdf do
  render pdf: 'factuur'
end

Upvotes: 1

Views: 1462

Answers (1)

Unixmonkey
Unixmonkey

Reputation: 18784

Probably this line, where wicked_pdf tries to guess where your wkhtmltopdf binary is, is causing your trouble: https://github.com/mileszs/wicked_pdf/blob/master/lib/wicked_pdf.rb#L207

If wkhtmltopdf is actually installed on the server, probably the best thing to do is specifically set your path to wkhtmltopdf in an initializer like so:

# config/initializers/wicked_pdf.rb
WickedPdf.config = { :exe_path => '/opt/bin/wkthmltopdf' } # or wherever it actually is

Upvotes: 1

Related Questions