PDFKIT apparently not working because of "wkhtmltopdf"
Asked Answered
R

2

5

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

Rustice answered 28/1, 2011 at 23:33 Comment(0)
E
8

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.

Ear answered 14/4, 2011 at 5:14 Comment(1)
am using rials 3.0.3 ruby version 1.8.7-p352 before its work fine but now it showing me same error as ur's but the solution you is not helpfulTango
R
0

I actually got it to work by deleting PDFKit and wkhtmltopdf. And following step by step as mentioned here:

https://github.com/jdpace/PDFKit/

(make sure you install wkhtmltopdf by hand)

Thanks

Rustice answered 29/1, 2011 at 4:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.