In php, I want to create pdf with tcpdf
. based on tutorials, I have to put html tags in a variable as string and then pass that variable to tcpdf
. like this:
$html = "<div>Hello World</div>";
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
But in a real world application, I want to do some foreach inside my html and create html tags from database data.
<div><?php foreach ($myData as $key => $value) {echo $value}; ?></div>;
But in this way, I get an error:
Some data has already been output to browser, can't send PDF file
What I have to do? in fact I want tp put a large html with php loops inside that completes that html inside a variable, and the pass that variable to tcpdf
whithout getting that error.