如何使用TCPDF在pdf页面中显示图像?

时间:2018-05-21 08:32:46

标签: php codeigniter tcpdf

请找到以下代码。当我print_r()输出时,图像显示在网页中。但图像未显示在PDF页面中。谁能告诉我我的代码有什么问题?

$link = base_url();
    foreach($defect_photos as $defect_photo){
    $html1 .= "<td><img src='$link/uploads/defects/$defect_photo' border='0' height='500' width='500' align='right'></td>";
    }
    $html1 .= '</tr></table>';
    //print_r($html1);
    //exit;
    $pdf->writeHTML($html1, true, false, true, false, '');

提前致谢

2 个答案:

答案 0 :(得分:2)

使用这行代码,您可以在tcpdf上添加图像。或详细信息,您可以访问https://tcpdf.org/examples/example_009/

$ pdf-&gt;图片(&#39; images / image_demo.jpg&#39;,&#39;&#39;,&#39;&#39;,40,40 && 39;& #39;,&#39;&#39;,&#39; T&#39;,false,300,&#39;&#39;,false,false,1,false,false,false);

答案 1 :(得分:0)

我也有同样的问题,但我通过给出图像的相对路径而不是给base_URL()或绝对路径看看我添加的代码下面来纠正我的问题。它应该是有用的。

<?php $imgs=$results->image4; 
    foreach($imgs as $im){  ?>
    <td><img src="<?php echo 'uploads/images/'.$im ?>" /></td>
<?php } ?>
相关问题