How do I force files to open in the browser instead of downloading (PDF)?

Is there a way to incorporate the solution provided in this SO link ?

1 Like

Hi @zain910128
You can use link element for that
Screenshot 2022-09-06 at 00.34.43

Well there can be other solutions too :+1:

Actually That’s exactly what I’ve done and what happens is that a new window opens, the file auto downloads and the new window closes.

Hi @zain910128 :wave:
For me it is not the case (Not sure what going wrong)
My file is saved in database…
This is my database pic :point_down:
Screenshot 2022-09-06 at 00.54.25

https://www.loom.com/share/1c208b8117d74294baaa27e3733d5e33

Looks like this is a browser issue because it works fine in chrome, but not in firefox.

So, is there a way to use the stackoverflow solution to ensure that it always opens in a new tab ?

@zain910128
Well i added HTML element as mentioned in one of the answers of stack overflow…
It works as expected :tada: (Tested in Firefox too)
You can try like this…

https://www.loom.com/share/155e4400bcec4fd4bc38c7d808f929d7

Thanks. I’ll try that in a bit.

Do you also know how to use the Content type as suggested in the main answer ?

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

@zain910128
Well i guess this is related to backend/API stuff…
Not sure how to do that :slightly_frowning_face:

This topic was automatically closed after 70 days. New replies are no longer allowed.