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
Insert image in pdf in php using mpdf
提问by Navya
Here,below is my code for converting an image into pdf using mpdf.
$html contains upload/tulips.jpg
But,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 /examples
there is a example04_images.php
you can try out.
在 mPDF 包中/examples
有一个example04_images.php
你可以试试。
PS : You should set $mpdf->debug = true
before$mpdf->Output()
PS:你应该设置$mpdf->debug = true
前$mpdf->Output()
回答by Navya
its the comma problem
它的逗号问题
$html='<img src="'.$inputPath.'"/>';