php 使用mpdf在php中插入pdf中的图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18570408/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 17:49:27  来源:igfitidea点击:

Insert image in pdf in php using mpdf

phpimagefilepdfmpdf

提问by Navya

Here,below is my code for converting an image into pdf using mpdf. $html contains upload/tulips.jpgBut,when the function executes the pdf file created and an image icon shows there with the location upload/tulips.pdf. Kindly tell me why this is happening because no bug is coming.

在这里,下面是我使用 mpdf 将图像转换为 pdf 的代码。$html 包含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;

            }

回答by davidkonrad

$html='<img src="'.$inputPath.'"/>';

eg ""around image-path, and you should be good (if the image exists)

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

In the mPDF-package /examplesthere is a example04_images.phpyou can try out.

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

PS : You should set $mpdf->debug = truebefore$mpdf->Output()

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

回答by Navya

its the comma problem

它的逗号问题

$html='<img src="'.$inputPath.'"/>';