html - "Failed to load PDF document"HTML5 对象

标签 html pdf

我试图在我的网页上显示一些 PDF 文档,但我的浏览器中一直显示 Failed to load PDF document。我已经在 Google Chrome 和 Mozilla Firefox(都是最新版本)中尝试过。每当我检查对象并直接在浏览器中打开 src url 时,路径都是正确的,它会下载 PDF 文件。

这是我使用的代码:

<object data="https://example.com/_f/user/pdf/my_file.pdf" type="application/pdf" width="100%" height="100%">
  <p>Alternative text</p>
</object>

更新

我找到了一个 solution here on StackOverflow我用过的。效果很好!

最佳答案

我遇到了同样的问题,不得不更改Content-Disposition attachment header 。

我改变了:

内容配置:附件;文件名="文件名.pdf"

Content-Disposition: inline;文件名="文件名.pdf"

另请参阅:How to force files to open in browser instead of download (pdf)?

关于html - "Failed to load PDF document"HTML5 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29956630/

相关文章:

javascript - FullCalendar HTML5 拖放 API

css - Flying Saucer PDF 不显示颜色

java - Android:读取pdf文件

sql - 在sql server中创建pdf文件

parsing - 以编程方式从 PDF 文件中提取文本(手动) - 丢失一些文本

javascript - 单击其他按钮时隐藏一个表单(两个按钮,两个表单)(PHP/HTML/Javascript)

html - 悬停时在图像上显示文字

jquery - 相对定位扩展 div 的内容不会压低 sibling

html - css不显示html元素之间的文本

java - PDF到图像转换