0

within a function of my code I am trying to open a new tab with pdf. I precisely want the pdf to be shown in the browser, vs it being downloaded, but the browser are instead downloading. I have disabled my browsers settings to download pdf files vs showing them, so that can't be the issue.

The relevant part of the code is simple:

if (isMobile) {
  newTab.location = redirectUrl;
} else {
  window.location = redirectUrl;
}

It works for mobile, but downloads it on desktop. The url is a pdf that is stored on a AWS S3 cloud.

Is there a way to ensure the pdf is opened in the browser, vs downloading it?

Laurents Mohr
  • 68
  • 1
  • 1
  • 6
  • So, what research have you done to try to find the answer? – Isaac Vidrine Sep 21 '18 at 15:18
  • I googled 'open pdf in new tab instead of download' and [this](https://stackoverflow.com/questions/6293893/how-do-i-force-files-to-open-in-the-browser-instead-of-downloading-pdf) was the first link. – Isaac Vidrine Sep 21 '18 at 15:20
  • 1
    I should have been more precise. My function is running on the front-end, the url is returned by an AWS S3 server, which I have no access to. The link you gave only has solutions by changing the header, which I can't do – Laurents Mohr Sep 22 '18 at 13:16

0 Answers0