本文介绍了由于“wkhtmltopdf",PDFKIT 显然无法正常工作;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法从 html 页面生成 PDF.
I'm having trouble generating a PDF out of a html page.
我正在使用 PDFkit.在安装它的过程中,我注意到我需要 wkhtmltopdf.所以我也安装了.我做了 PDFkit 文档所说的所有事情.. 现在我在尝试加载 PDF 时遇到了这个错误.
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.
这里是错误:
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" "-" "-"
知道这可能是什么吗?
谢谢
推荐答案
我的 rails 应用程序中有以下配置.我在 irb 中对其进行了测试,效果很好.
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
您需要设置 wkhtmlpdf 可执行文件的路径.
You need to set the path to wkhtmlpdf executable file.
这篇关于由于“wkhtmltopdf",PDFKIT 显然无法正常工作;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!