javascripthtmlhttp-headerscontent-disposition

Is it possible to change HTTP-header of a pdf document, you want to embed in a <embed> or <iframe>?


Refering to my other question: Why does pdf document download instead of showing in a embed/iframe?

When i embed a pdf document like the below examples, it downloads the documents instead of showing it embedded in the website.

<embed id="showPdfDocument" src="http://example.com:8080/client/attachment/filename.pdf" type="application/pdf" width="400" height="400">

or

<iframe id="showPdfDocument" src="http://example.com:8080/client/attachment/filename.pdf" style="width:400px;height:400px;"></iframe>

My assumptions:

My question:

Screenshot of the HTTP-Header of the pdf document:
("Chrome Dev-Tools(F12)" -> Network Tab, select the pdf document and check the response headers)

enter image description here


Solution

  • The content-disposition header triggers the save dialog. If you want to avoid it without server-side changes, try loading it via XHR and encode it as "data:" link.