Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDFKIT apparently not working because of "wkhtmltopdf"

I'm having trouble generating a PDF out of a html page.

I'm using PDFkit. In the process of installing it, I noticed I needed wkhtmltopdf. So I installed it too. I did everything PDFkit's documentation said to do.. and now I'm getting this error when I try to load the PDF.

Here is the error:

command failed: "/usr/local/bin/wkhtmltopdf" "--margin-right" "0.75in" "--page-size" "Letter" "--margin-top" "0.75in" "--margin-bottom" "0.75in" "--encoding" "UTF-8" "--margin-left" "0.75in" "--quiet" "-" "-"

Any idea of what this could be?

Thanks

like image 512
criticerz Avatar asked Jan 28 '11 23:01

criticerz


1 Answers

I have the following configuration in my rails application. I tested it in irb and it worked well.

PDFKit.configure do |config|
  config.wkhtmltopdf = `which wkhtmltopdf`.to_s.strip
  config.default_options = {
    :encoding=>"UTF-8",
    :page_size=>"A4",
    :margin_top=>"0.25in",
    :margin_right=>"1in",
    :margin_bottom=>"0.25in",
    :margin_left=>"1in",
    :disable_smart_shrinking=>false
    }
end

You need to set the path to wkhtmlpdf executable file.

like image 112
Esenbek Kydyr uulu Avatar answered Oct 05 '22 11:10

Esenbek Kydyr uulu