简体   繁体   中英

FPDF has already been output using FPDF in Yii framework

i have problem with FPDF in Yii Framework, i wan't to show number read as text

SATU JUTA TIGA RATUS RIBU RUPIAH FPDF error: Some data has already been output, can't send PDF file

$a = array ($jmltagihan, $jmltagihan1, $jmltagihan2, $jmltagihan3);
$b = array_sum($a);
$c = number_format($b,2,',','.');
Yii::import("application.components.Terbilang");
$terbilang = new Terbilang();
$terbilang->rupiah($b);

Try cleaning the buffer directly before you output the pdf:

while(@ob_end_clean()) {}
$a = array ($jmltagihan, $jmltagihan1, $jmltagihan2, $jmltagihan3);
$b = array_sum($a);
$c = number_format($b,2,',','.');
Yii::import("application.components.Terbilang");
$terbilang = new Terbilang();
$terbilang->rupiah($b);

If this doesn't work try moving the while(@ob_end_clean()) {} more and more to the bottom of your code.

Explanation: Frameworks often have rendered layout and stuff already at this point so you need to clean all the buffer levels with ob_end_clean() so the pdf won't get corrupted.

Some data has already been output, can't send PDF file .

This kind of error happens when you have another error before your code. Since errors also cause output to be sent to the screen, (like a warning or a notice, even), you can't send anything else.

Try commenting out the part where you actually send the PDF file and you'll probably some other error before that. You can then correct (or suppress) that and you'll be able to send your PDF file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM