I'm converting HTML to PDF using with wicked_pdf and wkhtmltopdf and it's working fine on my localhost but when I deploy that code on server then I'm getting following error on server.
Error as well as Logs
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 ... 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 ")")
):
The usr/local/bin/wkhtmltopdf is present on production server but still getting above error.
Do you have access to production?
If you have, login with the same user as your application and the run this:
ls -t /usr/local/bin/wkhtmltopdf
If it does not give you a good result this means your application is pointing to the wrong path.
Cheers