首页 >php教程 >PHP源码 >PHP WkHtmlToPdf/WkHtmlToImage 将网页直接转换成pdf和图片

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

PHP中文网
PHP中文网原创
2016-05-25 17:05:323566浏览


function convert($type='pdf')
        {
            $filename=time();
            $url=$this->input->get("url");
            if($type=='pdf')
            {
                $filename="upload/tmp/".$filename.".pdf";
                exec("/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");
        }

                   

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn