Support the ongoing development of Laravel.io →
posted 9 years ago
Views

Hi Guys,

hi guys, im trying to use barryvdh/laravel-dompdf, everything works fine except i cant load my data to the view to dynamically produce content, i keep getting 'Undefined variable: data'

here is my code:

  $data =[
	'fname'=>Input::get('efname'),
	'lname'=>Input::get('elname'),
	'dob'=>Input::get('edob'),
	'reg_date'=>date('Y-m-d'),
	'email'=>Input::get('eemailaddrs'),
	'gender'=>Input::get('gender'),
	'mobile'=>Input::get('emobile'),
	'p_addrss'=>Input::get('epaddress'),
	'c_addrss'=>Input::get('ecaddress'),
	'quals'=>Input::get('quali'),
	'pdfname'=>$pdfname,
	'empId'=>Input::get('employeeId'),
	];
return PDF::loadView('employee/generatepdf',$data)
		->save(public_path().'/pdfs/'.$pdfname.'.pdf');

its going to pdf template page..But cant get the array values.

<!DOCTYPE html>
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<img align="center" src="{{public_path()}}/assets/img/logo.png">
<table align="center" style="width:100%;margin-top:25px;">
<tr>
	<td style="width:50%">Registration ID</td>
	<td style="width:50%">:{{$data['empId']}}</td>
</tr>
<tr>
	<td style="width:50%">Name</td>
	<td style="width:50%">:{{$data['fname']}} {{$data['lname']}}</td>
</tr>
</table>
</body>
</html>

also not taking css rules into pdf file.

How can i solve this issue...?

Thanks

Last updated 3 years ago.
0

Similar to building emails you only echo the Key not the array[key]

     <td style="width:50%">:{{$fname}} {{$lname}}</td>
Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

jishadp jishadp Joined 31 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.