【发布时间】:2019-09-18 14:53:00
【问题描述】:
我在尝试通过生产环境中的pdf_from_url 方法生成 pdf 时遇到了一些麻烦。
错误如下:
Error: PDF could not be generated!
Command Error: /app/vendor/bundle/ruby/2.5.0/gems/wkhtmltopdf-binary-edge-0.12.5.0/libexec/wkhtmltopdf-linux-amd64: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory
下面这行抛出上面的错误:
pdf = WickedPdf.new.pdf_from_url("https://google.com", {:temp_path => Rails.root.join('public')})
该错误仅发生在生产中。在开发过程中一切正常。
在服务器上通过命令行运行wkhtmltopdf https://google.com test.pdf正常工作。
需要注意的一点是,我的应用程序服务器运行在我没有经验的 dokku 容器上。因此,可能由于 dokku 文件架构的工作方式而发生错误。
我已经尝试过的:
- 将 wkhtmltopdf 的 gem 从
wkhtmltopdf-binary更改为wkhtmltopdf-binary-edge - 在服务器上手动安装了 libpng12(而不是在 dokku 容器上)
我目前正在使用什么:
wicked_pdf gem 版:1.1.0
whtmltopdf [提供者 gem]:wkhtmltopdf-binary-edge ~> 0.12.5
平台/发行版和版本:在 Ubuntu 18.04 上运行的 Dokku 容器
【问题讨论】:
标签: ruby-on-rails wkhtmltopdf ubuntu-18.04 dokku