Install dompdf package
composer require barryvdh/laravel-dompdf
Enable GD & zip extension first (php.ini), then use this cmd.
Goto config / app.php
'providers' => [
Barryvdh\DomPDF\ServiceProvider::class,
];
'aliases' => [
'PDF' => Barryvdh\DomPDF\Facade::class,
];
php artisan make:controller PDFController <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use PDF; class PDFController extends Controller { function member_list_pdf(Request $req){ $data = [ 'users' => $users, 'age_from' => $age_from, 'age_to' => $age_to, 'member_code' => $member_code, 'matital_status' => $matital_status, 'religion_id' => $religion_id, 'caste_id' => $caste_id, 'sub_caste_id' => $sub_caste_id, 'mother_tongue' => $mother_tongue, 'profession' => $profession, 'country_id' => $country_id, 'state_id' => $state_id, 'city_id' => $city_id, 'min_height' => $min_height, 'max_height' => $max_height, 'member_type' => $member_type ]; $pdf = PDF::loadView('frontend.member.member_listing.print_pdf', $data)->setPaper('a4', 'landscape'); return $pdf->download('all_member_lists.pdf'); } } php artisan optimize
view @foreach($users as $user) {{$user->name}} @endforeach