I faced an error when exporting PDF file:
TCPDF ERROR: Some data has already been output, can't send PDF file
and found the answer:
//Change To Avoid the PDF Error

  ob_end_clean();

//just before
$pdf->Output($filename, $output_dest);