黄聪: PHP WkHtmlToPdf/WkHtmlToImage 将网页直接转换成pdf和图片

function convert($type='pdf')
{
$filename=time();
$url=$this->input->get("url");
if($type=='pdf')
{
$filename="F:/upload/tmp/".$filename.".pdf";
exec("F:/home/phptool/wkhtmltopdf-i386 $url $filename");
header('Content-Type: application/pdf');
}
elseif($type=='image')
{
$filename="upload/tmp/".$filename.".jpg";
exec("/home/phptool/wkhtmltoimage-i386 $url $filename");
header('Content-Type: image/jpeg');
}
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize($filename));
readfile("$filename");
}
上一篇:web前端与后台数据交互


下一篇:android程序打包成APK