首先下载wkhtmltox-0.12.4_linux-generic-amd64.tar.xz (不要下载RPM包,依赖太多,需要x-server支持),并解压,执行测试运行正常
移动文件夹到规范目录,设置系统环境变
.PHP调用代码
tar wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
cd wkhtmltox-0.12.4_linux-generic-amd64/bi
./wkhtmltopdf http://www.gaojiufeng.cn 1.pdf
mv wkhtmltox /usr/local //移动文件
vi /etc/profile //编辑配置文件
PATH=/usr/local/wkhtmltox/bin:$PATH export PATH //以上复制文件底部
source /etc/profile //配置文件立即生效
wkhtmltopdf http://www.gaojiufeng.cn 1.pdf
<?php
exec('/usr/local/wkhtmltox/bin/wkhtmltopdf --zoom 1.1 http://www.gaojiufeng.cn 1.pdf',$return);
//exec("wkhtmltopdf http://www.gaojiufeng.cn 2.pdf",$output); //低PHP版本可以用.
if(!$return){
echo 'success';
}
else{
echo 'failed';
}
?> 提示:如果无法执行exec请在php.ini中允许执行exec函数