Jump to content

Can I turn HTML into a JPEG with PHP???


poleposters

Recommended Posts

This might sound like an odd question.

 

I want my users to be able to create a restaurant menu to include on their profile pages. I want to make things easy for them and create the menu online, since I doubt many of them would be able to create an image themselves even using paint(sounds silly, but most people have no idea!)

 

So I am investigating whether it is possible to "print"  a HTML page(complete with syle) to a JPEG using PHP.

 

The reason I need a jpg is becaue I am using a flash/php pageflip book.

 

If anyone can tell me if this is possible, and if so , point me in the right direction, that would be great!

 

And if anyone has any alternative methods to achieve this, I would appreciate any suggestions.

 

Cheers!

Link to comment
Share on other sites

Well, you can create images on the fly with the GD library:

 

www.php.net/gd

 

To make them look like an HTML page would either take a lot of effort to parse the HTML page and determine what it's supposed to like, or it might be possible to use this function:

 

imagegrabwindow()

 

The above function is only supported with a PHP version of 5.2.2 or higher, and a window machine. It should be possible to save the HTML the user generates, then use that function to take a screenshot of it. Finally, you could use the gd library functions to create an image.

 

 

 

 

Link to comment
Share on other sites

This is pretty hard to do. Basicly you need a web browser or other HTML rendering program installed on the server and have the PHP script run that rendering program, and return the result.

 

As for doing it all in PHP, it's pretty much impossible, unless you were to write a complete HTML renderer in PHP. ( Way too hard!!! )

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.