Linux安装:wkhtmltopdf

1、安装

1.1、yum安装

yum install -y wkhtmltopdf

安装的版本是0.12.1

 

2、使用

2.1、如果系统安装了GUI

直接使用

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

2.2、如果系统没有GUI

创建脚本 wkhtmltopdf2

xvfb-run --server-args="-screen 0, 1200x768x24" wkhtmltopdf --margin-top 10mm --
margin-bottom 10mm --outline --outline-depth 4 "$@"

可以如下使用:

wkhtmltopdf2 http://www.baidu.com baidu.pdf

如果系统报错:xvfb-run 命令未找到,需要安装Xvfb

yum install -y Xvfb

 

3、中文乱码

安装中文字体