首页 文章

FPDF错误“已输出一些数据”

提问于
浏览
1

我正在使用FPDF并尝试使用以下代码输出测试页:

<?php
require('fpdf/fpdf.php');

$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>

我在互联网上搜索了很多,但他们总是说我必须使用更新的版本或其他对我的项目不起作用的东西 .

这是完整的错误:

致命错误:未捕获异常:FPDF错误:某些数据已经输出,无法发送PDF文件/Applications/XAMPP/xamppfiles/htdocs/BusinessAnwendungen/fpdf/fpdf.php:271堆栈跟踪:#0 / Applications / XAMPP / xamppfiles / htdocs / BusinessAnwendungen / fpdf / fpdf.php(1051):FPDF->错误('某些数据有...')#1 /Applications/XAMPP/xamppfiles/htdocs/BusinessAnwendungen/fpdf/fpdf.php (987):FPDF - > _ checkoutput()#2 /Applications/XAMPP/xamppfiles/htdocs/BusinessAnwendungen/sites/bestellung_abschluss.php(8):FPDF-> Output()#3 / Applications / XAMPP / xamppfiles / htdocs / BusinessAnwendungen /sites/main.php(86):include('/ Applications / X ...')#4 /Applications/XAMPP/xamppfiles/htdocs/businessanwendungen/index.php(18):include('/ Applications / X. ..')#5 在第271行的/Applications/XAMPP/xamppfiles/htdocs/BusinessAnwendungen/fpdf/fpdf.php中抛出

如果有人可以帮助我,我会很高兴 .

1 回答

  • 0

    试试这个

    <?php
    require('fpdf/fpdf.php');
    ob_end_clean(); //    the buffer and never prints or returns anything.
    ob_start(); // it starts buffering
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',16);
    $pdf->Cell(40,10,'Hello World!');
    $pdf->Output();
    ob_end_flush(); // It's printed here, because ob_end_flush "prints" what's in
                  // the buffer, rather than returning it
                  //     (unlike the ob_get_* functions)
    ?>
    

相关问题