Is there a way to force PDF files to open in the browser when the option "Display PDF in browser" is unchecked?
I tried using the embed tag and an iframe, but it only works when that option is checked.
What can I do?
Is there a way to force PDF files to open in the browser when the option "Display PDF in browser" is unchecked?
I tried using the embed tag and an iframe, but it only works when that option is checked.
What can I do?
Here is another method of forcing a file to view in the browser in PHP:
To indicate to the browser that the file should be viewed in the browser:
To have the file downloaded rather than viewed:
The quotes around the filename are required if the filename contains special characters such as
filename[1].pdf
which may otherwise break the browser's ability to handle the response.If you are using HTML5 (and I guess nowadays everyone uses that), there is an attribute called
download
.For example,
Here
filename
is optional, but if provided, it will take this name for the downloaded file.This is for ASP.NET MVC
In your cshtml page:
In your controller:
Just open Adobe Reader, menu → Edit → Preferences → Internet, then change to browser mode or for detailed instructions on different browsers try Display PDF in browser | Acrobat, Acrobat Reader.
If you have Apache add this to the
.htaccess
file: