• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Download pdf file in browser Chrome com mPdf

#1
Hello friends!

I implemented the mPdf librarie in my project, including with the help of the staff here at the forum. The problem is that I am not able to download the pdf file through the Chrome browser. I generate the pdf with the library but when I click download the file in Chrome the file is not downloaded and a message is displayed that there is a problem with the server. In other browsers, Firefox and Edge the file is downloaded normally! Android also doesn't download.


I took a look at the CodeIgniter documentation and tried several ways to force the download of the pdf file, but without success!

In the controller, I'm calling by doing this:


.
PHP Code:
..
$pdf $mpdf->Output('my-file.pdf''I')->setContentType('application/pdf');

return 
$pdf

Do I need to do anything else to be able to download the file through the browser Chrome?

The version of mPdf is 8.0.

I thank you in advance for any and all help.
Reply

#2
Have you tried this?
PHP Code:
$pdf $mpdf->Output('my-file.pdf''D')->setContentType('application/pdf'); 

And you should not use the return $pdf; part. As it should output to your browser, so just deleting that may help as well.
Reply

#3
(01-30-2020, 12:55 PM)jreklund Wrote: Have you tried this?
PHP Code:
$pdf $mpdf->Output('my-file.pdf''D')->setContentType('application/pdf'); 

And you should not use the return $pdf; part. As it should output to your browser, so just deleting that may help as well.

Hello jreklund, thanks for the help!

I had already tried it that way, but it returns ERR_INVALID_RESPONSE


PHP Code:
return $mpdf->Output('my-file.pdf''D'); 
This way the file is downloaded in Chrome, but not on Android!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.