PHP PDF生成 - IE7 / Acrobat8:“网站无法显示”

时间:2021-06-29 21:10:51

I've got some trouble with displaying pdfs in IE7 (which were generated by R&OS' ezpdf).

我在IE7中显示pdf有些麻烦(由R&OS的ezpdf生成)。

IE7 with Acrobat Reader 8.1.2. says "The page cannot be displayed"

IE7与Acrobat Reader 8.1.2。说“页面无法显示”

Other Browsers (like FF3/Acrobat 8.1.2. or IE6/Acrobat 7) have no problem with the file.

其他浏览器(如FF3 / Acrobat 8​​.1.2。或IE6 / Acrobat 7)对文件没有任何问题。

The following headers are returned by the server:

服务器返回以下标头:

Date: Thu, 08 Jan 2009 10:52:40 GMT
Server: Apache/2.2.8 (Win32) mod_ssl/2.2.8 OpenSSL/0.9.8g PHP/5.2.5 DAV/2
X-Powered-By: PHP/5.2.5
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 4750
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/pdf

日期:2009年1月8日星期四10:52:40 GMT服务器:Apache / 2.2.8(Win32)mod_ssl / 2.2.8 OpenSSL / 0.9.8g PHP / 5.2.5 DAV / 2 X-Powered-By:PHP / 5.2 .5到期日:1981年11月19日星期四08:52:00 GMT Cache-Control:无存储,无缓存,必须重新验证,post-check = 0,pre-check = 0 Pragma:no-cache Content-Length :4750 Keep-Alive:timeout = 5,max = 100 Connection:Keep-Alive Content-Type:application / pdf

Does anybody know how to fix this problem?

有人知道如何解决这个问题吗?

2 个解决方案

#1


Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache

Cache-Control:no-store,no-cache,must-revalidate,post-check = 0,pre-check = 0 Pragma:no-cache

...so IE won't store the file in the Temporary Internet Files folder. However the mechanism used to directly 'Open' a file from the browser in IE often requires it to be opened from inside Temporary Internet Files. Directly opening a file from a browser is generally unreliable, especially in IE; 'Save as' works better.

...所以IE不会将文件存储在Temporary Internet Files文件夹中。但是,用于在IE中直接从浏览器“打开”文件的机制通常需要从Temporary Internet Files中打开它。直接从浏览器打开文件通常是不可靠的,尤其是在IE中; “另存为”效果更好。

Consider replacing the cachebusting headers with an alternative method, such as add a '?randomstring' parameter to the URL. Also consider adding a "Content-Disposition: attachment; filename=..." header, which will stop a plug-in trying and failing to display the file in the browser UI.

考虑使用替代方法替换cachebusting标头,例如向URL添加“?randomstring”参数。还要考虑添加“Content-Disposition:attachment; filename = ...”标题,这将阻止插件尝试并且无法在浏览器UI中显示该文件。

#2


I think I've solved the problem.

我想我已经解决了这个问题。

The problem is not on the server-side but on the client-side. The generated PDF is being displayed in a popup-window (javascript: window.open) and IE7 chokes on it.

问题不在服务器端,而在客户端。生成的PDF显示在弹出窗口(javascript:window.open)和IE7上。

When I open a html-file in the popup which is redirecting to the PDF it works.

当我在弹出窗口中打开一个重定向到PDF的html文件时,它可以工作。

#1


Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache

Cache-Control:no-store,no-cache,must-revalidate,post-check = 0,pre-check = 0 Pragma:no-cache

...so IE won't store the file in the Temporary Internet Files folder. However the mechanism used to directly 'Open' a file from the browser in IE often requires it to be opened from inside Temporary Internet Files. Directly opening a file from a browser is generally unreliable, especially in IE; 'Save as' works better.

...所以IE不会将文件存储在Temporary Internet Files文件夹中。但是,用于在IE中直接从浏览器“打开”文件的机制通常需要从Temporary Internet Files中打开它。直接从浏览器打开文件通常是不可靠的,尤其是在IE中; “另存为”效果更好。

Consider replacing the cachebusting headers with an alternative method, such as add a '?randomstring' parameter to the URL. Also consider adding a "Content-Disposition: attachment; filename=..." header, which will stop a plug-in trying and failing to display the file in the browser UI.

考虑使用替代方法替换cachebusting标头,例如向URL添加“?randomstring”参数。还要考虑添加“Content-Disposition:attachment; filename = ...”标题,这将阻止插件尝试并且无法在浏览器UI中显示该文件。

#2


I think I've solved the problem.

我想我已经解决了这个问题。

The problem is not on the server-side but on the client-side. The generated PDF is being displayed in a popup-window (javascript: window.open) and IE7 chokes on it.

问题不在服务器端,而在客户端。生成的PDF显示在弹出窗口(javascript:window.open)和IE7上。

When I open a html-file in the popup which is redirecting to the PDF it works.

当我在弹出窗口中打开一个重定向到PDF的html文件时,它可以工作。