【发布时间】:2011-11-11 00:40:20
【问题描述】:
我运行的是 64 位的 Windows 7。我最近更新了我的操作系统以安装最新的更新。从那时起,大多数 PDF 文档已停止在我的程序中呈现。我的程序想要在单独的 iFrame 中显示 PDF 文档。我通过获取 PDF 文档的 URL 并设置 window.frames['docview'].location = url; 来做到这一点。在大多数情况下,iframe 视图保持空白(如果之前在那里显示过某些内容,则清除)。如果我使用相同的 URL 并在新选项卡或窗口中打开它,它会呈现正常。
当它无法在我的 iframe 中呈现时,我会在 Chrome 控制台中看到以下消息:
Resource interpreted as Document but transferred with MIME type application/pdf.
Firefox 不会在其错误控制台或 FireBug 控制台中提供任何类型的消息。
我无法控制 PDF 文件的来源,因此我无法更改它们的标题信息。
奇怪的是,有些文件确实可以正确加载。
查看 Chrome 中的网络请求,我看到(例如)加载失败的文档:
Request URL:http://es.csiro.au/pubs/paradis_mdm03.pdf
Request Method:GET
Status Code:200 OK
Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Host:es.csiro.au
Referer:http://querium.fxpal.net:8080/querium/ui/query?searcherId=2&compact=true&sidx=rank&topicId=2&queryId=1&lastEventId=1490893682130103&highlight=undefined
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1
Response Headers
Accept-Ranges:bytes
Connection:Keep-Alive
Content-Length:71764
Content-Type:application/pdf
Date:Tue, 06 Sep 2011 04:59:26 GMT
ETag:"1f48c8-11854-43e4ee482ef40"
Keep-Alive:timeout=15, max=100
Last-Modified:Wed, 07 Nov 2007 04:07:49 GMT
Server:Apache/2.0.55 (Ubuntu) PHP/5.1.2 mod_ssl/2.0.55 OpenSSL/0.9.8a
从单独的选项卡(文档在其中呈现)打开时,我得到以下信息:
Request URL:http://es.csiro.au/pubs/paradis_mdm03.pdf
Request Method:GET
Status Code:304 Not Modified
Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Host:es.csiro.au
If-Modified-Since:Wed, 07 Nov 2007 04:07:49 GMT
If-None-Match:"1f48c8-11854-43e4ee482ef40"
Range:bytes=0-71763
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1
Response Headers
Connection:Keep-Alive
Date:Tue, 06 Sep 2011 05:07:15 GMT
ETag:"1f48c8-11854-43e4ee482ef40"
Keep-Alive:timeout=15, max=100
Server:Apache/2.0.55 (Ubuntu) PHP/5.1.2 mod_ssl/2.0.55 OpenSSL/0.9.8a
一个奇怪的事情是状态的不同,但也许服务器很聪明,或者与缓存有一些有趣的交互。谁知道呢。
任何帮助将不胜感激。
基因
编辑:2011 年 9 月 6 日
当我删除标签时
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
从我的 HTML 页面的 <head> 元素开始,许多(但不是全部)PDF 开始正确呈现。这显然是标题中另一个元标记的重复:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
这是否有助于揭示潜在问题?
【问题讨论】:
标签: firefox pdf google-chrome iframe