1

I generate a PDF using TCPDF and I prompt the user to download it after it's generated. I use this code for the output and it works fine on Desktop:

header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="contract-' . $prename . '-' . $name . '.pdf"');
exit($pdf->Output('contract-' . $prename . '-' . $name . '.pdf"', 'D'));

Now the user should also be able to download while being on a mobile device. The tested iOS devices worked fine but under Android (10) and Firefox (68.7.0) I get this error message:

The file could not be downloaded. Please save the file to your local storage and then try to open it.

After some investigating (here and here) I found that it's supposed to be an Adobe Reader issue and after changing Adobe Reader to not be the default application to handle downloads in Firefox it worked there as well.

Now I also tested this in Chrome (81.0.4044.117) and surprisingly it downloaded just fine using Adobe Reader by default. This makes me think that it's more an issue in the way Firefox "provides" the PDF to Adobe Reader?

Now I obviously want all users to be able to download the PDF without issues and telling them to use a different browser or change any settings is not really an option. Therefore I would like to know if there's something I can do to make downloads work in Firefox if Adobe Reader happens to be the default setting there?

Again it worked fine with Chrome AND Adobe Reader, so maybe there's a difference in the way FF hands PDFs over to Adobe Reader? Anything I could alter in the way I provide the PDF to make this work?

0 Answers0