-1

我想打印输出(即变量 $matter 的值),但我收到了上面提到的错误消息。我为它做了很多谷歌,并检查了 php 标签前后的空格。但无法得到解决方案。请帮我。这是我使用 tcpdf 打印输出的代码:

<?php
    ob_start();
  require_once("../../includes/application-header.php");

  // Include tcpdf liabrary
  require_once OCN_ROOT."/core/extention/tcpdf/config/lang/eng.php";
  require_once OCN_ROOT."/core/extention/tcpdf/tcpdf.php";


    define ('PDF_MARGIN_TOP', 22); 
    define ('PDF_HEADER_TITLE', 'This is Heading');
    define ('PDF_HEADER_STRING', $head_string);
    define ('PDF_CREATOR', PAGE_TITLE); 

    // create new PDF document
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

    // set document information
    $pdf->SetCreator(PDF_CREATOR);
    $pdf->SetAuthor(PDF_CREATOR);
    $pdf->SetTitle('TCPDF Example');

    // set default header data
    $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);

    // set header and footer fonts
    $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

    // set default monospaced font
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

    //set margins
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

    //set auto page breaks
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

    //set image scale factor
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

    //set some language-dependent strings
    $pdf->setLanguageArray($l);

    // ---------------------------------------------------------

    // set font
    $pdf->SetFont('helvetica', '', 10);

    // add a page
    $pdf->AddPage();

    $matter = <<<EOD
         <h1>HTML Example</h1> 
EOD;

    $pdf->writeHTML($matter, true, false, true, false, '');

    // reset pointer to the last page
    $pdf->lastPage();

    // ---------------------------------------------------------
    ob_flush();
    //Close and output PDF document
    $pdf->Output('example_061.pdf', 'I');

    //============================================================+
    // END OF FILE                                                
    //============================================================+
?>
4

1 回答 1

12

尝试而不是ob_flush();ob_end_clean();

于 2012-12-17T12:04:40.157 回答