我有一个以PDF格式生成的BIRT报告。该报告将从Web浏览器打开。但是,在Adobe Reader中打开文件时,出现以下错误消息:
Adobe Reader could not open 'test.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).
当我从命令行运行完全相同的代码(从Schedule()和Search()调用)时,我得到相同的报告,但Adobe Reader能够打开它。这里是我用来从浏览器中读取文件的代码:
require "Search.php";
require "Schedule.php";
Schedule( $_POST['period'], mktime(23, 59, 59, $_POST['month'] + 1,
$_POST['day'] + 1, $_POST['year']) );
Search( $param1, $param2, $param3, $param4 );
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="test.pdf"');
readfile('/home/web/test.pdf');
?>Schedule()和Search()都已经过测试,并且不应该引起任何问题。由于我还是PHP新手,有什么我缺少的东西我还不知道?任何有关这个问题的帮助,不胜感激。
-rusty
更新:事实证明,我发现一个cron作业更新被调用的文件。这更新了文件无用,并已被修复。