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

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

PHP中文网
Release: 2016-05-25 17:05:32
Original
3577 people have browsed it


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");
        }
Copy after login

                   

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template