简体   繁体   English

已经在Yii框架中使用FPDF输出了FPDF

[英]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 我在Yii Framework中遇到FPDF的问题,我不会显示数字为文本

SATU JUTA TIGA RATUS RIBU RUPIAH FPDF error: Some data has already been output, can't send PDF file SATU JUTA TIGA RATUS RIBU RUPIAH FPDF错误:已经输出了一些数据,无法发送PDF文件

$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: 在输出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. 如果这样做不起作用,请尝试将while(@ob_end_clean()) {}越来越多地移到代码底部。

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. 说明:框架通常已经渲染了布局和内容,因此您需要使用ob_end_clean()清理所有缓冲区级别,以免pdf损坏。

Some data has already been output, can't send PDF file . 一些数据已经输出,无法发送PDF文件

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. 尝试注释掉实际发送PDF文件的部分,在此之前您可能会遇到其他错误。 You can then correct (or suppress) that and you'll be able to send your PDF file. 然后,您可以对此进行更正(或取消显示),然后便可以发送PDF文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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