1

I have a function to show PDF . its triggered by click button to show/download pdf .

this function can show/displayed this data (before download) if i using php artisan serve , but now i not using php artisan serve because of BUG on my datatables , so i using XAMPP .

if i clicking button to download ,its not displaying data, its download automaticly .

how i can solved this ?

public function PDF(Request $request,$id){
    $users = User::findOrFail($id);

    $pdf = PDF::loadView('admin.pdf',['users' => $users]);
    return $pdf->stream('Profile.pdf', array('Attachment'=>0));              
}

its my controller

Adhik Mulat
  • 538
  • 2
  • 10
  • 39

2 Answers2

1

Please mention header

$pdf->stream('Profile.pdf')
           ->header('Content-Type','application/pdf');

Please check your carome setting as well.

1) On your computer, open Chrome.

2) At the top right, click More Settings.

3) At the bottom, click Advanced.

4) Under "Privacy and security," click Site settings.

5) Near the bottom, click PDF documents.

6) Turn on Download PDF files instead of automatically opening them in Chrome.

Dilip Hirapara
  • 14,810
  • 3
  • 27
  • 49
0

I am not sure but I think this might be something that must be set by a browser setting. How to update pdf browser settings

Logan Craft
  • 589
  • 4
  • 9
  • I set this but still didnt work . I think this problem is i using Xampp . If i using artisan serve its can previewed – Adhik Mulat Jul 25 '19 at 13:37