【发布时间】:2015-11-27 08:05:03
【问题描述】:
/usr/local/bin/wkhtmltopdf:语法错误:单词意外(预期为“)”)
在使用 wicked_pdf 从生产中的 rails 中的 html 创建 pdf 时生成上述错误
这是我在控制器中的代码
render pdf: "Project_#{Time.now.strftime("%B %d, %Y").gsub(',','').gsub(' ','_')}.pdf",
#:show_as_html => true,
template: "work_orders/print_trade.pdf.erb",
orientation: 'Landscape',
page_size: 'Legal',
wkhtmltopdf: '/usr/bin/wkhtmltopdf',
margin: {
top: 27,
bottom: 40,
left: 20,
right: 20
},
header: {
spacing: 10,
html: {
template: 'work_order_pdf/header.html.erb'
}
},
footer: {
spacing: 5,
html: {
template: 'work_order_pdf/footer.html.erb'
}
}
日志错误:-
RuntimeError (Error: Failed to execute:
["/usr/local/bin/wkhtmltopdf", "-q", "--orientation", "Landscape", "--page-size", "Legal", "--margin-top", "27", "--margin-bottom", "40", "--margin-left", "20", "--margin-right", "20", "--header-spacing", "10", "--header-html", "file:////tmp/wicked_header_pdf20151126-3990-ttmmjg.html", "--footer-spacing", "5", "--footer-html", "file:////tmp/wicked_footer_pdf20151126-3990-6tmvq3.html", "file:////tmp/wicked_pdf20151126-3990-1r6mnm6.html", "/tmp/wicked_pdf_generated_file20151126-3990-10ir53b.pdf"]
Error: PDF could not be generated!
Command Error: /usr/local/bin/wkhtmltopdf: 1: /usr/local/bin/wkhtmltopdf: �~: not found
/usr/local/bin/wkhtmltopdf: 1: /usr/local/bin/wkhtmltopdf: cannot create ��@����@/0��I8
ik�O@�ݦ��O��w�[�@
`�n��@9���u{go���W�/�0/���o�C}��i�PAi����k�: Directory nonexistent
/usr/local/bin/wkhtmltopdf: 1: /usr/local/bin/wkhtmltopdf:ELF: not found
/usr/local/bin/wkhtmltopdf: 3: /usr/local/bin/wkhtmltopdf: Syntax error: word unexpected (expecting ")")
):
【问题讨论】:
-
使用您提供的完整命令编辑问题。很可能,您忘记提供要生成的 PDF 的输入 HTML 文件和/或输出路径。参考instructions。
-
遵循完整的步骤wicked_pdf
-
我已经按照所有步骤@Prashant4224
-
查看代码@PrahladYeri
-
错误应该指向导致问题的特定行。这是什么?
标签: ruby-on-rails wkhtmltopdf wicked-pdf