Home > Backend Development > PHP Tutorial > HTML2pdf将html转为pdf html里面图片丢失

HTML2pdf将html转为pdf html里面图片丢失

WBOY
Release: 2016-06-23 13:39:54
Original
3092 people have browsed it

html里面有图片

转成的pdf却没有

而我用正则将里面的图片替换出来再插入图片
$pattern="/HTML2pdf将html转为pdf html里面图片丢失/i";
    preg_match_all($pattern,$file,$match);
    var_dump($match); 
    for($i=0;$i       $img_url=preg_match("/^http:\/\//",$match[1][$i])?$$match[1][$i]:"http://file.aconf.org".$match[1][$i];
      preg_replace($match[0][$i], $pdf->Image($img_url, 5, 5, 200, 150,$type='',$link="",$paint=true), $file);
    }
   $pdf->Image($img_url, 5, 5, 200, 150,$type='',$link="",$paint=true);
出现错误

求大神指点迷津啊


回复讨论(解决方案)

确认你的图片格式能被接受(JPEG、PNG )
确认远程的图片能用文件函数读取的到(如果对方有防盗链,就读不到了)

图片是jpg的   能读取   可以肯定

vendor('html2fpdf.html2fpdf');
        $pdf = new FPDF();
        $pdf->AddPage();
        $pdf->SetFont('Arial','B',16);
        $pdf->Cell(40,10,'Hello World!');
        $pdf->Image('http://file.aconf.org/public/images/logo.png',60,30,90,0,'PNG');
        $pdf->Output();
我直接使用插入图片的功能报错Alpha channel not supported: http://file.aconf.org/public/images/logo.png

不支持 png 的下述模式
Interlacing (交错式) 
Alpha channel 

谢谢 原来是这样 我换了个图片成功了

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template