/ usr / local / bin / wkhtmltopdf:无法执行二进制文件:exec格式错误

时间:2015-11-27 08:05:03

标签: ruby-on-rails wkhtmltopdf wicked-pdf

/ 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 ")")
):

1 个答案:

答案 0 :(得分:0)

似乎您在控制器中提供了二进制文件的路径。我认为您需要运行rails generate wicked_pdf并将二进制路径放在初始化程序中。