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

猜你喜欢

转载自www.cnblogs.com/xqianx/p/9235121.html