3

I am working in CakePHP 3 application. Here I am using TCPDF for PDF Generation. Everything works fine except image. Image is not displaying.

Here my pdf() action file:

public function pdf()
    {
    $this->loadModel('Users');
    $users=$this->Users->find('all')->select(['firstname','lastname','email','image_path']);
    $this->set(compact('users'));
    $this->viewBuilder()->layout('pdf');
    }

My pdf.ctp file :

$html = '<table>';

foreach($users as $users) {
  $html .= '<tr>
  <td>' . $users['firstname'] . '</td>
  <td>' . $users['lastname'] . '</td>
  <td>' . $users['email'] . '</td>
  <td><img src="/sample/webroot/img/'.$users['image_path'].'"/></td> 
        </tr>';    
}
$html .= '</table>';
$pdf->writeHTML($html, true, false, true, false, '');

Can any one help me to resolve this problem?

Alex M
  • 2,756
  • 7
  • 29
  • 35

0 Answers0