2

A website I work on has a download pdf functionality, sending the proper HTTP headers in the response, to download the PDF file.

It works smoothly across the browsers (Safari, Chrome, Firefox etc), but recently we discovered it fails in the Facebook browser.

The scenario is that people would eventually open the website while navigating on Facebook, and may click the Download pdf button.

Facebook would show an error message saying Cannot render this kind of file or something similar, and the browser view would even crash (backwards/forward browser buttons won’t work anymore), bringing the user back to the Facebook feed.

Is there a classical issue to this problem? I tested using Facebook for iOS.

The headers we use are the following, as suggested here:

Content-Type: application/pdf
Content-Disposition: attachment; filename="filename.pdf"

I just guess this is a general issue, but after a quick search I can’t seem to find any information about it.

While it may be a Facebook, I’m just wondering what would be the recommended ways to fix this on our side.

In the worst case, I thought to hide the button if the user agent tells us that the user uses Facebook browser. But I just guess there should be better solutions.

Ionică Bizău
  • 93,552
  • 74
  • 254
  • 426

1 Answers1

2

There is no simple solution for this. The browsers from social apps will not download the files.

You will have to check the user agent of the browser and not display the download buttons (hiding the UI when needed).

GhitaB
  • 2,907
  • 3
  • 28
  • 52