使用mpdf在php中以pdf格式插入图像

Nav*_*vya 3 php pdf image file mpdf

这里,下面是我使用mpdf将图像转换为pdf的代码.$ html contains upload/tulips.jpg 但是,当函数执行创建的pdf文件时,图像图标显示该位置upload/tulips.pdf.请告诉我为什么会这样,因为没有错误来临.

   private function ConvertImageToPdf($inputPath,$outputPath)
            { 
                $mpdf=new mPDF();
                $html='<img src='.$inputPath.'/>';
                $mpdf->WriteHTML($html);
                $mpdf->Output($outputPath.".pdf",'F');
                $mpdf->debug = true;

            }
Run Code Online (Sandbox Code Playgroud)

dav*_*rad 9

$html='<img src="'.$inputPath.'"/>';
Run Code Online (Sandbox Code Playgroud)

例如""在图像路径周围,你应该是好的(如果图像存在)

在mPDF包中/examples有一个example04_images.php你可以尝试.

PS:你应该设置$mpdf->debug = true $mpdf->Output()