Reputation: 5
/usr/local/bin/wkhtmltopdf: Syntax error: word unexpected (expecting ")")
Generating above error while working with wicked_pdf for creating pdf from html in rails in production
This is my code in controller
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'
}
}
Error in log :-
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 ")")
):
Upvotes: 0
Views: 2681
Reputation: 1262
It seems that you give the path to the binary in the controller. I think you need to run rails generate wicked_pdf
and put the binary path in the initializer.
Upvotes: 1