ruby-on-rails – wicked_pdf不在Ubuntu服务器上运行:wkhtmltopdf:无法连接到X服务器

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – wicked_pdf不在Ubuntu服务器上运行:wkhtmltopdf:无法连接到X服务器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试在我的服务器上使用wicked_pdf,但是它会持续下去:
RuntimeError (Failed to execute:
"/usr/bin/wkhtmltopdf" -q        "file:////tmp/wicked_pdf20130709-23109-1adqx5g.html" "/tmp/wicked_pdf_generated_file20130709-23109-1ic5dbe.pdf"
Error: PDF could not be generated!
 Command Error: wkhtmltopdf: cannot connect to X server
):
  app/controllers/contrats_controller.rb:15:in `block (2 levels) in show'
  app/controllers/contrats_controller.rb:11:in `show'

我试图按照这个答案:wkhtmltopdf: cannot connect to X server但仍然不行.

解决方法

这篇文章帮我解决了我的问题:
http://www.stormconsultancy.co.uk/blog/development/generating-pdfs-in-rails-with-pdfkit-and-deploying-to-a-server/

我正在复制这篇文章,帮助我安装它:

# first,installing dependencies
sudo aptitude install openssl build-essential xorg libssl-dev

# for 64bits OS
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2
mv wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf
chmod +x /usr/local/bin/wkhtmltopdf

他还创建一个初始化程序来告诉pdfKit它在哪里,所以这种方法是用于恶意的PDF和PDF工具包.

猜你在找的Ruby相关文章