【发布时间】:2016-07-08 18:42:02
【问题描述】:
我有一个 php 脚本,可以将 eclipse birt 报告中的 pdf 保存为 pdf。 我正在使用获取文件内容作为输入。 birt 报告 pdf 需要一些时间来创建。
我认为这是问题所在。
以下是脚本:
<?php
$rname = 'reportname';
$wname = $rname . '_' . date('d.m.Y') . '.pdf';
$pdf = file_get_contents("http://xxx.xxx.xxx.x:8080/Birt/run?__report=" . $rname . ".rptdesign&sample=my+parameter&__format=pdf");
file_put_contents('/tmp/report' . $wname, $pdf);
?>
有什么问题?
感谢您的帮助:)
【问题讨论】:
-
做了任何基本的调试,比如检查
$pdf是否真的包含pdf数据?检查来自file_get_contents()的返回值?你的任何代码都没有考虑到现实世界:事情失败了,你只是假设什么都不会。 -
问题是,什么都没有改变......大约。两周后,pdf 正在运行。
-
PHP 中 HTTP 调用的默认超时时间为 60 秒。如果生成 pdf 的时间比这更长,那么 file_get_contents 最终将没有数据。如果它变得更快,那么它会突然开始成功。无论如何,请参阅@Daniel Lichtenberg 的回答,了解如何覆盖该超时。