I am trying to add following HTML table to an image and then download it as an .jpg file but instead it giving me white image which is given in $dir
. Please have a look and guide what i am missing or what is wrong with this code
$dir = "../images/white.jpg";
$text = "tableHTML";
imagettftext($dir, 20, 0, 10, 20, $text);
imagepng($dir);
//$name = './img/ok.png';
header('Pragma: public');
header('Cache-Control: public, no-cache');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($dir));
header('Content-Disposition: attachment; filename="' . basename($dir) . '"');
header('Content-Transfer-Encoding: binary');
readfile($dir);
the output image.jpg would be like this
Sr # | ID | Bar Code | Notes
1 | 1261 | |||||||| | Test
2 | 6781 | |||||||| | test
3 | 8895 | |||||||| | test
4 | 5578 | |||||||| | test
5 | 1123 | |||||||| | test
*test data