TCPDF ERROR: Some data has already been output, can't send PDF file

This error message is typically encountered when using the TCPDF library to generate a PDF file, and it indicates that some data (such as HTML or text) has already been sent to the browser before the PDF file is generated and sent. This can happen if there is any echo or print statement before the PDF generation code or if any whitespace before the opening PHP tag in the file. To resolve this issue, you can check your code for any echo or print statements before the PDF generation code, and remove them. Also, check for any whitespace before the opening PHP tag and remove it. You can also try to use ob_start() function before generating pdf and ob_end_clean() after pdf generation to clear the output buffer.

Watch a course Learn object oriented PHP