0

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

M N
  • 69
  • 2
  • 14
  • yes, it is an absolute path. When print_r() and exit the output, the image is showing but not when view it in the PDF page – M N May 21 '18 at 09:00

2 Answers2

2

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);

Jalaj Kumar
  • 491
  • 1
  • 3
  • 12
  • Thanks. I tried the above method but image is not appearing in the PDF. so, I used html image. – M N May 21 '18 at 09:06
  • `foreach($defect_photos as $defect_photo){ $pdf->Image(base_url().'/uploads/defects/$defect_photo', '', '', 40, 40, '', '', 'T', false, 300, '', false, false, 1, false, false, false); }` I tried this code but no response. – M N May 21 '18 at 09:10
  • when i fetch image from the database, it is not showing. – M N May 21 '18 at 09:49
0

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 } ?>