views:

514

answers:

2

Is there a free (or commercial) PHP library which would help me convert a piece of HTML to image?

I googled it but haven't found anything.

thanks in adv

+1  A: 

Try this and let us all know :)

codaddict
Thank you!! A lot. I'm going to dive into code, right now...
Goran
A: 

if you use the gd library you can use imagettftext function http://php.net/manual/en/function.imagettftext.php to generate images based on text.

You can follow the installation instructions for GD library at http://www.php.net/manual/en/image.installation.php

For example

 $htmlstring = "<h1>Test</h1>; 
            $image = imagecreatefrompng("../images/image.png"); //create image



            $black = imagecolorallocate($image, 0, 0, 0); // set colour of text


            $font = 'CALISTBI.TTF'; // set the font (any true type font path on the server)


            imagettftext($image, 19, 1, 36, 23, $black, $font, $htmlstring);
Shaun Hare
I think bzabhi is after a script to render some html and return an image of the output
adam