Reputation: 1
I want to open a PDF file in the browser but instead of opening, it is downloading. I do not want to change the default settings of the browser.
If there any PDF viewer package which is easy to use, please refer. I tried like this
first import the pdf
import Pdf from "../../../assets/pdf/abc.pdf";
then tried to open it like this
<a href={Pdf} target="\_blank" className="btn"\>Learn More</a>
But it is downloading the file. But I want to open it.
Upvotes: 0
Views: 879
Reputation: 11875
As a user you have full control, as a server you can only request the user follows your desires, but they do not have to.
A PDF application/pdf mime file is a potential source of exploit so just like a user can change settings to block adverts or images they can also block unsolicited display of a PDF.
The browsing client may choose to download and view or download only or do not download it is the same in Mozilla or Chromium, just different plugins.
Upvotes: 0
Reputation: 51
If you are using Chrome browser, select the three vertical dots in the upper-right corner. Choose Settings > Advanced > Privacy and security. Select Site Settings > PDF documents. Use the toggle switch next to Download PDF files instead of automatically opening them in Chrome to turn the feature on and off.
Upvotes: 1