Is there any approach to redirect to certain route/ refresh current page after download the pdf? I've tried to return an URL but it just goes to the url without generating the file. If I use the code below, it will generate the file and display a blank page. I am using laravel and fpdf here.
Route:
Route::post('alumni/labels','AlumniController@labels')->name('alumni/labels');
Controller:
public function labels(){
$alumni = Alumni::whereIn('id', Session::get('alumniId'))->get();
$pdf = new PDF_Label('TJ103');
$pdf->AddPage();
foreach ($alumni as $alumnus) {
$text = sprintf("%s %s\n%s\n%s %s", $alumnus->firstName, $alumnus->lastName, $alumnus->address, $alumnus['hp1'], $alumnus['phone']);
$pdf->Add_Label($text);
}
return $pdf->Output('d');
}
View:
<form method="post" action="labels">
{!! csrf_field() !!}
<button class="btn btn-primary" id="btn-submit">Generate Label</button>
</form>
This is not proper way but if you can open pdf in new page