i want to create an image from html, i couldn't use painty since it is outdated and no longer working and i want something similar. i have already tried to create image using GD library like this
<?php
$html_code = "<b> this is the body </b> ";
// Create the image
$img = imagecreate("300", "600");
imagecolorallocate($img,0,0,0);
$c = imagecolorallocate($img,70,70,70);
imageline($img,0,0,300,600,$c2);
imageline($img,300,0,0,600,$c2);
$white = imagecolorallocate($img, 255, 255, 255);
imagettftext($img, 9, 0, 1, 1, $white, "arial.ttf", $html_code);
// Display the image
header("Content-type: image/jpeg");
imagejpeg($img);
but it doesn't "compile" the html tags and prints them in the image as text.
Best Regards
the GD lib does not have the ablilty to render html-code and draw it on the image. if you want to draw bold text you need to use bold font, e.g. arialbd.ttf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With