系统:centos6 x64
官方网站: http://wkhtmltopdf.org
What is it?
wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the Qt WebKit rendering engine.
These run entirely “headless” and do not require a display or display service.
安装:
[root@www ~]# wget -c http://download.gna.org/wkhtmltopdf/0.12/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz [root@www ~]# yum install -y xz* [root@www ~]# xz -d wkhtmltox-0.12.3_linux-generic-amd64.tar.xz [root@www ~]# tar xvf wkhtmltox-0.12.3_linux-generic-amd64.tar [root@www ~]# cp -R wkhtmltox /usr/local/
拷贝windows字体文件到linux中,否则生成pdf或图像会显示方框乱码。
把C:\Windows\Fonts下的 “微软雅黑”或”宋体 常规”(一个就行) 上传到linux下的/usr/share/fonts
[root@www ~]# cp msyh.ttc simsun.ttc /usr/share/fonts
生成pdf:
[root@www ~]# /usr/local/wkhtmltox/bin/wkhtmltopdf https://www.rootop.org ~/rootop.pdf
生成jpg:
[root@www ~]# /usr/local/wkhtmltox/bin/wkhtmltoimage https://www.rootop.org ~/rootop.jpg
原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/3524.html