美文网首页Django
centos 环境正确配置 wkhtmltopdf:cannot

centos 环境正确配置 wkhtmltopdf:cannot

作者: 不知道是哪个号 | 来源:发表于2019-02-28 18:26 被阅读0次

参考链接:
https://github.com/JazzCore/python-pdfkit/wiki/Using-wkhtmltopdf-without-X-server

1、安装

yum install wkhtmltopdf

2、安装之后,执行操作,若提示“wkhtmltopdf: cannot connect to X server”错误 (如果3,4,5已经完成直接执行 6)

3、需再安装xvfb

yum install xorg-x11-server-Xvfb

4、在 /usr/bin/ 目录下生成脚本 wkhtmltopdf.sh 并写入命令

sudo vim /usr/bin/wkhtmltopdf.sh
  
命令:
xvfb-run -a --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf -q $*

5、更改文件权限并建立连接

chmod a+x /usr/bin/wkhtmltopdf.sh
ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf

6、启动 'virtual' X server (最终解决问题)

 wkhtmltopdf http://www.baidu.com a.pdf

相关文章

网友评论

    本文标题:centos 环境正确配置 wkhtmltopdf:cannot

    本文链接:https://www.haomeiwen.com/subject/hapkuqtx.html