I tried to use MPDF library for generating PDF.
try {
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('Hello World');
// Other code
$mpdf->Output("1.pdf", 'D');
} catch (\Mpdf\MpdfException $e) { // Note: safer fully qualified exception name used for catch
// Process the exception, log, print etc.
echo $e->getMessage();
}
And I get this error message.
Data has already been sent to output, unable to output PDF file
I used ob_end_clean() but not working. I used all answers in this question but nothing works for me. TCPDF & mPDF error: Some data has already been output to browser, can't send PDF file