无法在服务器上生成PDF(生产环境)

时间:2015-11-30 09:16:01

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

我使用wicked_pdf和wkhtmltopdf将HTML转换为PDF,并且它在我的本地主机上工作正常但是当我在服务器上部署该代码时,我在服务器上收到以下错误。

错误以及日志

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

usr / local / bin / wkhtmltopdf出现在生产服务器上但仍然出现错误。

1 个答案:

答案 0 :(得分:1)

您是否可以访问制作?

如果有,请使用与您的应用程序相同的用户登录并运行:

ls -t /usr/local/bin/wkhtmltopdf

如果它没有给你一个好结果,这意味着你的应用程序指向错误的路径。

干杯