html - PDF 未加载到对象标签中

标签 html pdf

pdf 路径没问题,但浏览器不会在对象标签中加载 PDF。

响应 header :

Accept-Ranges:bytes
Connection:keep-alive
Content-Disposition:attachment; filename=1.pdf
Content-Length:234790
Content-Type:application/pdf
Date:Tue, 28 Oct 2014 14:26:16 GMT
Last-Modified:Wed, 09 Jul 2014 14:00:55 GMT
Server:nginx/0.7.67
Set-Cookie:sessionid=1c64bc0b9ab545d9f7568c09a8ed6fe3; httponly; Path=/

目标代码:

<object data="http://example.com/protected/documents/7" type="application/pdf">
    <p>File:  
        <a href="/protected/documents/7" target="_blank" class="turquesa"> 
           /protected/documents/7
        </a>
    </p>
</object>

如果我单击后备链接,我就会下载 PDF,因此服务器工作正常。

所以...有什么想法吗?

最佳答案

问题在于 Content-Disposition header 。 “附件”告诉浏览器下载文件而不是内联显示它。如果您能够更改响应,使其显示为“内联”,则问题将得到解决。

关于html - PDF 未加载到对象标签中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26611123/

相关文章:

html - 我的 anchor 标记重定向到我自己的 WordPress 网站/"the link I gave in Tag"

grails - 将Grails Base64转换为PDF-内联渲染PDF

pdf - 如何在 react native 应用程序中查看和共享来自 URL 的 pdf?

android - 如何显示 PDF?

pdf - 如何使用itextsharp API从PDF读取特定页面的内容

html - 如何水平和垂直居中一个div

html - 尝试将我的标签放在输入类型文本上方

javascript - 如何提醒 Tic Tac Toe 中的赢家?

batch-file - Windows 10 从命令行打印为 PDF

javascript - 使用 jQuery 从 Ajax GET 响应中选择 HTML 元素