2

I've made a small program to search and display an PDF-file, some years ago. The PDF-file is shown inline, so the user can verify that it is the correct file. Usually he then uses the download button of the adobe plugin to save the file on his PC.

Since end of may this makes problems with Microsoft Edge and Google Chrome. The file is displayed correctly and when the user clicks the download button the save dialog opens, but when he presses the save button the file is not downloaded (error message "network error"). Strange thing is, that the print button next to the download button works.

On Firefox the whole thing still works. Each browser is updated automatically.

This is the code I use to display the pdf file:

        header('Content-Type: application/pdf');
        header('Content-Disposition: inline; filename="' . $deliveryPdf->getFilename() . '"');
        header('Content-Transfer-Encoding: binary');
        header('Accept-Ranges: bytes');
        echo $deliveryPdf->getData();

Some notes, I recognized while analyzing the problem:

  • On Edge and Chrome the save dialog does not use the filename given in the response headers, while firefox uses the correct name
  • When using the "download" or "print" button in the adobe view, there is no additional request to the webserver (on none of the browsers). The only request on the webserver appears when initially opening the pdf
  • The print button works fine on all browsers. This raises the question where the difference between download and print is, when they both seem to use the cached file.
ADyson
  • 57,178
  • 14
  • 51
  • 63
  • Older IE are legend for messing this up easily, if they don’t like the caching headers. Possible a similar problem has resurfaced now. https://stackoverflow.com/questions/1597732/php-force-file-download-and-ie-yet-again – CBroe Jul 12 '21 at 11:19
  • The `Accept-Ranges` header seems to be faulty here, because I guess there's no logic in view to partial requests, or? Try to remove it. – Jan Slabon Jul 12 '21 at 14:20
  • Did you find any solution to this problem ? – Rahul_2289 Dec 23 '22 at 01:30
  • Same exact issue, wondering if solution was ever found? Like to avoid opening a similar issue:) – Woody Jan 06 '23 at 21:02

0 Answers0