How to convert a php page in to jpeg file and to download
14,768
Solution 1
You will need an HTML renderer for this. There exists a few such renderers, but most of them requires an X server on your web server, so check out Xvfb to run a framebuffer device without a screen.
Solution 2
GD does not do this natively, you can render a picture from your screen though but that is as far as it goes. I had painty in my links with a description of html to jpg php conversion.
Solution 3
You need to internally render the page. You can find possible solutions here.
Author by
Mohan Ram
H.R. Mohan Ram, Software Engineer III, Bank of America Email: [email protected] Mobile: (+91)9578352644 / (+91)8806199976
Updated on June 04, 2022Comments
-
Mohan Ram almost 2 years
I am trying to convert a web page into jpeg image file. i had used following codes.
<?php //put your html code here $html_code = " <html> <head> <title>My test title</title> <style> body { font-family:verdana; font-size:11px; color:black } </style> </head> <body> this is the body </body> </html>"; // Create the image $img = imagecreate("300", "600"); imagecolorallocate($img,0,0,0); $c = imagecolorallocate($img,70,70,70); imageline($img,0,0,300,600,$c); imageline($img,300,0,0,600,$c); $white = imagecolorallocate($img, 255, 255, 255); imagettftext($img, 9, 0, 1, 1, $white, "VERDANA.TTF", $html_code); // Display the image header("Content-type: image/jpeg"); imagejpeg($img); ?>
Question: Is there any library to convert html page into image ?