未被捕获的例外'例外'消息' FPDF错误:已输出一些数据

时间:2016-04-07 07:37:57

标签: php wordpress pdf pdf-generation

我想在wordpress中提交表单时创建一个pdf文件。 我使用的是FDPF,代码是

    <?php 
    /* Template Name: FORM TEST */ 

    get_header(); 
    /*** USE THE NEW HEADER FUNCTION **/
    WpkPageHelper::zn_get_subheader();

    if(isset($_POST['confirm'])){ 
        $fullname = $_POST['fullname'];
        $fathername = $_POST['fathername'];
        $dob = $_POST['dob'];
        $wpdb->insert( 
            'tck_customer', 
            array( 
                'name' => $fullname, 
                'fname' => $fathername 
            ), 
            array( 
                '%s', 
                '%s' 
            ) 
        );
?>
<?php
ob_start();
require(STYLESHEETPATH.'/fpdf/fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
ob_clean();
flush();
$pdf->Output();
ob_end_flush(); 
?>
<form>
     FORM STUFFS
</form>

但是当我提交代码时,这给了我错误。 错误:

Fatal error: Uncaught exception 'Exception' with message 'FPDF error: Some data has already been output, can't send PDF file (output started at /home4/q0i4l0g2/public_html/tck/wp-content/themes/kallyas/header.php:2)' in /home4/q0i4l0g2/public_html/tck/wp-content/themes/kallyas-child/fpdf/fpdf.php:271 Stack trace: #0 /home4/q0i4l0g2/public_html/tck/wp-content/themes/kallyas-child/fpdf/fpdf.php(1053): FPDF->Error('Some data has a...') #1 /home4/q0i4l0g2/public_html/tck/wp-content/themes/kallyas-child/fpdf/fpdf.php(1000): FPDF->_checkoutput() #2 /home4/q0i4l0g2/public_html/tck/wp-content/themes/kallyas-child/form-test.php(33): FPDF->Output() #3 /home4/q0i4l0g2/public_html/tck/wp-includes/template-loader.php(89): include('/home4/q0i4l0g2...') #4 /home4/q0i4l0g2/public_html/tck/wp-blog-header.php(16): require_once('/home4/q0i4l0g2...') #5 /home4/q0i4l0g2/public_html/tck/index.php(17): require('/home4/q0i4l0g2...') #6 {main} thrown in /home4/q0i4l0g2/public_html/tck/wp-content/themes/kallyas-child/fpdf/fpdf.php on line 271

我该如何解决这个问题?

0 个答案:

没有答案