ubuntu14.10安装wkhtmltopdf(html转pdf的工具)

Installing wkhtmltopdf on Ubuntu Server 14.10 to dynamically create PDF documents from HTML.

安装步骤:

1
2
3
4
5
6
7
8
9
10
sudo su
apt-get update
apt-get install wkhtmltopdf
apt-get install xvfb
echo 'xvfb-run --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf $*' > /usr/bin/wkhtmltopdf.sh
chmod a+rx /usr/bin/wkhtmltopdf.sh
ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf
/usr/local/bin/wkhtmltopdf http://www.baidu.com output.pdf
或者
/usr/bin/wkhtmltopdf.sh http://www.baidu.com output.pdf

遇到的问题:

1
2
3
4
5
6
Unable to load library icui18n "Cannot load library icui18n: (libicui18n.so.48: cannot open shared object file: No such file or directory)" 
wkhtmltopdf: cannot connect to X server

解决办法:
sudo apt-get install libicu48
sudo apt-get install openssl build-essential xorg libssl-dev

 

坚持原创技术分享,您的支持将鼓励我继续创作!