Convert html to image.

The question was asked: 6 years 9 months ago   views: 5
0

Asking for your help in finding a php library for converting html + css to image, pgn,jpg,gif.

Asked: DigSil DigSil 21-06-2012 в 15:22:55
View here. May be you find something useful. - ReinRaus ReinRaus 21-06-2012 в 15:29:46
15 ways true, not php: mashable.com/2007/08/24/web-screenshots - sercxjo sercxjo 21-06-2012 в 22:27:56
@Alexander Fisenko - has access to the shell_exec? - Zowie Zowie 21-06-2012 в 22:37:50
Access shell_exet Have here found an interesting option code.google.com/p/wkhtmltopdf. if you have something like love to see - DigSil DigSil 22-06-2012 в 00:06:15
You need the image of the entire page (i.e., from the top to the bottom) or its part? - Zowie Zowie 22-06-2012 в 00:54:14

Answers   1

0

Here is an example conversion Html => PDF => PNG / JPEG

$html_content = '<p>Hello World</p>';

$html2pdf = new HTML2PDF('P', 'A4');
$html2pdf->writeHTML($html_content);
$file = $html2pdf->Output('temp.pdf','F');

$im = new imagick('temp.pdf');
$im->setImageFormat( "jpg" );
$img_name = time().'.jpg';
$im->setSize(800,600);
$im->writeImage($img_name);
$im->clear();
$im->destroy();

In the beginning, do not forget to connect the library HTML2PDF or mPDF

Answered: Roman Kozin Roman Kozin 28-01-2016 в 10:44:34