Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Network failure" to download PDF generated with with PHP FPDF/FPDF2File class in Google Chrome

I have reports generated in PHP / FPDF / FPDF2File that are usually displayed in the browser window.

Notice:

  • The parameters are passed to the PHP that generates report POST.
  • The file is being accessed exclusively via HTTPS with a valid certificate.
  • The web server is able to log all errors and errors are being properly recorded in the log, but no error related to that FPDF/PHP is being recorded. (Ie I clean the error log, run the report and no error appears in the log ... forcing a mistake on purpose and it is registered). Thus, it seems that there is no syntax error.
  • The Content-type used is: header ( 'Content-type: application / pdf'); The problem occurs in Windows computers with Google Chrome (tested on multiple machines).
  • All buttons of the PDF rendering plug-in browsers (save, print, rotate, zoom, etc.) work normally. Except the save button in Google Chrome (in other browsers work normal).

When trying to save the PDF already opened and displayed on Google Chrome, the following error occurs:

Failure - Network error

Therefore, you can not save the PDF, unless you go to print and print in PDF, or print the PDF PDF, which does not make much sense.

Could someone tell how to solve this error?

Thanks a lot!

like image 599
xXx Avatar asked Aug 19 '16 20:08

xXx


1 Answers

Do you set the no-store property of the Cache-Control header?

I don't know why, but for me it worked after changing

header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");

to

header("Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0");

like image 171
Amryn Avatar answered Sep 28 '22 12:09

Amryn