wkhtmltopdf: cannot connect to X server

环境ubuntu 16.04 

  1. apt-get install wkhtmltopdf

  2. apt-get install xvfb
  3. echo -e '#!/bin/bash\nxvfb-run -a --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf -q $*' > /usr/bin/wkhtmltopdf.sh
  4. chmod a+x /usr/bin/wkhtmltopdf.sh
  5. ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf

结果验证

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

posted on 2018-06-27 17:33  巷尾书生  阅读(728)  评论(0编辑  收藏  举报

导航