I want to print the output(i.e. value of variable $matter) but I’m getting the error message mentioned above. I did lot of google for it and checked for spaces before and after php tags. But couldn’t get the solution. Please help me. Here is my code to print output using 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
//============================================================+
?>
Try instead of
ob_flush();withob_end_clean();