Wkhtmltopdf not working (pdfkit)

I am having a problem creating a PDF file on an html page.

I am using PDFkit. I also installed wkhtmltopdf in accordance with the installation instructions. In 'usr / local / bin /' there is now a file called 'wkhtmltopdf'

When I run PDF with PDFkit, it now gives an 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" "-" "-" 

Also, when I try to generate a PDF directly, it gives an error:

 wkhtmltopdf --page-size A4--quiet http://localhost/invoices/22 - '/usr/local/bin/wkhtmltopdf: cannot execute binary file' 

Any idea what this could be? Here's what the PDFkit configuration file looks like:

 PDFKit.configure do |config| config.wkhtmltopdf = '/usr/local/bin/wkhtmltopdf' end 
+4
source share
2 answers

You must specify the entire path to the executable.

The path should look like this: C: /usr/local/bin/wkhtmltopdfwkhtmltopdf.exe

try this it works great

0
source

I installed wkhtmltopdf on my Mac OSX with homegrown, and I use the gem wicked_pdf and I had similar errors. This may be useful:

In my rails 3 application, I have an app / config / initializers / wicked_pdf.rb file containing

 # brew install wkhtmltopdf WickedPdf.config = { :exe_path => '/usr/local/bin/wkhtmltopdf'} if Rails.env == 'development' 

Worked for me. So you can try:

 PDFKit.configure do |config| config.wkhtmltopdf = { :exe_path => '/usr/local/bin/wkhtmltopdf' } end 

Also: see the installation instructions for the github project page:

https://github.com/mileszs/wicked_pdf

0
source

Source: https://habr.com/ru/post/1399775/


All Articles