Redirect to another PDF tab

Asked

Viewed 914 times

-1

Hey, I need some help! My current project needs to generate a report from one table, great I did with Dompdf, my doubt is how I make the pdf open in another tab and not in the current tab. The version of the Laravel is 5.5. Thank you very much. :)

    public function pdfexport($id)
{
    //export PDF from students table
    $student = Student::find($id);
    $pdf = PDF::loadView('student.pdf', ['student'=> $student])->setPaper('a4', 'portrait');
    $fileName = $student->name.date("dmy");

    return $pdf->stream($fileName.'.pdf');
}

2 answers

5


Hello, in your view:

<a href="{{route("pdfexport")}}" target="_blank" > visualizar pdf </a>

and en route:

Route::get('/pdf', 'YourController@pdfStream')->name('pdfexport');
  • Thank you, it was so simple and I had forgotten kkk

0

I think the best alternative is for you to give a target in your form.. Follow the example:

<form method="POST" action="suaaction" target="_blank">

Ouuu, could do using window.open("SUAURL);

As reported in this report(https://github.com/barryvdh/laravel-dompdf/issues/419)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.