首页 > 解决方案 > 显示缓冲区和 otput tfpdf 文件

问题描述

下面非常简化的一段代码显示了我的情况。

if($pdf_success) {
    echo 'Success! Your download is starting';
    
    ob_end_clean()
    
    $pdf->Output('D', 'filename.pdf');

} else {
    echo 'Failure! Try again with different parameters.';
}

这是问题所在:

如果我不use ob_end_clean()pdf 下载失败并显示以下消息:

Uncaught Exception: FPDF error: Some data has already been output, can't send PDF file (output started at .....

如果我使用它,pdf 下载/显示正确,但消息不显示...

Using firstob_end_flush()会显示消息,但会停止下载并显示相同的消息,而 usingob_end_clean()无济于事,但会出现消息:

PHP Notice:  ob_end_clean(): failed to delete buffer. No buffer to delete in ....

如何同时显示一条消息,然后成功开始下载???

谢谢。

标签: phpoutputfpdfoutput-buffering

解决方案


推荐阅读