M N
M N

Reputation: 96

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. But image is not showing in the PDF page. 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

Upvotes: 0

Views: 5910

Answers (2)

Iswarya Swaminadhan
Iswarya Swaminadhan

Reputation: 125

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.

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

Upvotes: 0

Jalaj Kumar
Jalaj Kumar

Reputation: 501

Using this line of code you can add image on tcpdf. or in details you can visit https://tcpdf.org/examples/example_009/

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

Upvotes: 2

Related Questions