0

I'm trying to export a table blade with an image to PDF Using TCPDF.

My Controller:

public function exportPDF(){
      $users = User::orderBy('id','DESC')->get();
     $view = View::make('admin.users.export',compact('users'));
     $contents = (string) $view;
      $contents = $view->render();
     $pdf = new PDF();
  $pdf::SetTitle('Users List');
  $pdf::SetSubject('Users List');
  $pdf::SetKeywords('User');
  $pdf::SetTitle('User List');
  $pdf::AddPage();
  $pdf::writeHTML($contents, true, false, true, false, '');
  $pdf::Output('users.pdf');
}

My Blade:

<html>
<head>
<body>
<h4>Users List</h4>
<table>
<tr>
<th>Image</th>
<th>First Name</th>
<th>Last Name</th>
<th>User Name</th>
<th>Email</th>
<th>Role</th>
</tr>     
@if($users->count())  
@foreach($users as $user)  
<tr> 
<td><img src="{{asset('images/users/'.$user->image_path)}}"></td> 
<td>{{$user->first_name}}</td>
<td>{{$user->last_name}}</td>
<td>{{$user->username}}</td>
<td>{{$user->email}}</td>
<td>{{$user->role}}</td>
</tr>
@endforeach 
</table>
</body>
</html>

But when i want to get the pdf it take a long time and after that it gave me this message

TCPDF ERROR: [Image] Unable to get the size of the image:http://127.0.0.1:8000/images/users/1523518590.jpg

Thank's

Hbar01
  • 7
  • 1
  • 6

0 Answers0