嵌入固有下载的 pdf

Embedding a pdf that inherently downloads

我正在尝试嵌入在 API 端点提供的 pdf 文档,但是 pdf 的 url 将 pdf 下载到我的机器上,而不是将其嵌入到 html 页。

不幸的是,由于隐私限制,我不能 post 确切 link,但我附上了几个可以与任何其他在线 pdf 一起使用的示例。是否有 url 的属性使 pdf "download" 而不是 "embed itself"?

以下代码片段适用于在线呈现的 pdf,但是我的 API 端点不适用于这些,因为下载的是 pdf。

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

我完全愿意写一些 javascript 来编辑这个属性,我只是不知道如何解决这类问题。

源服务器可能具有设置为附件的内容配置 header。您可以通过 运行 之类的 curl -I url-of-pdf

来检查

一种解决方案可能是使用 pdf.js 库在网页上加载文件。