Display buffer and otput tfpdf file

162 Views Asked by At

below VERY simplified piece of code showing the situation that I have.

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.';
}

and here is the problem:

if I don't use ob_end_clean() pdf download fails with the message:

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

If I use it, pdf downloads/displays correctly, but the message does not show...

Using first ob_end_flush() shows the message but stops the download with the same message, and using ob_end_clean() does not help but results with the message:

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

How to both display a message and after that start successfully the download???

Thanks.

0

There are 0 best solutions below