简体   繁体   English

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

[英]How to show image in pdf page using TCPDF?

Please find the below code. 请找到下面的代码。 When i print_r() the output, image shows in the webpage. 当我print_r()输出时,图像显示在网页中。 But image is not showing in the PDF page. 但是图像未显示在PDF页面中。 Can anyone please tell me what is wrong in my code? 谁能告诉我代码中的错误吗?

$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, '');

Thanks in advance 提前致谢

Using this line of code you can add image on tcpdf. 使用此行代码,您可以在tcpdf上添加图像。 or in details you can visit https://tcpdf.org/examples/example_009/ 或详细信息,您可以访问https://tcpdf.org/examples/example_009/

$pdf->Image('images/image_demo.jpg', '', '', 40, 40, '', '', 'T', false, 300, '', false, false, 1, false, false, false); $ pdf-> Image('images / image_demo.jpg','',``,40,40,'','','T',false,300,'',false,false,1,false,false ,false);

i have also same issue but i rectified my issue by giving relative path to the image instead of giving the base_URL() or absolute path have a look below code what i add .It should be helpful. 我也有同样的问题,但我通过提供图像的相对路径而不是给base_URL()或绝对路径来纠正我的问题,请在下面添加的代码中查看。这应该会有所帮助。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM