Jay K.
Jay K.

Reputation: 636

Embedding a pdf that inherently downloads

I'm attempting to embed a pdf document that is being served at an API endpoint, however the url to the pdf downloads the pdf to my machine instead of embedding it onto the html page.

Unfortunately I can't post the exact link due to privacy constraints, but I've attached several examples that DO work with any other pdf that is online. Is there an attribute of a url that makes a pdf "download" as opposed to "embed itself"?

The following code snippets work with pdfs that render online, however my API endpoint doesn't work with these because the pdf downloads instead.

<object data="http://url.com/thing.pdf" type="application/pdf">
<embed src="http://url.com/thing.pdf" width="500px" height="500px" />

I am completely open to writing some javascript to edit this attribute, I just don't know how to approach this type of problem.

Upvotes: 1

Views: 103

Answers (1)

Marc Rohloff
Marc Rohloff

Reputation: 1352

The origin server probably has a content disposition header that is set to attachment. You can check this by running something like curl -I url-of-pdf

One solution might be to use the pdf.js library to load the file on a web page.

Upvotes: 1

Related Questions