Using html2pdf you can convert html
to jpg
:
<?php
require_once('html2_pdf_lib/html2pdf.class.php');
if(isset($_POST['snapshot'])){
$html = stripslashes($_POST['url']);
ob_start();
?>
<page style="font-size: 14px">
<?php
echo $html;
?>
</page>
<?php
$content = ob_get_clean();
ob_clean ();
try
{
$html2pdf = new HTML2PDF('P', 'A4', 'en');
$html2pdf->setDefaultFont('courier');
$html2pdf->writeHTML($content);
$file = $html2pdf->Output('temp.pdf','F');
//pdf creation
$im = new imagick('temp.pdf');
$im->setImageFormat( "jpg" );
$img_name = time().'.jpg';
$im->setSize(300,200);
$im->writeImage($img_name);
$im->clear();
$im->destroy();
//remove temp pdf
unlink('temp.pdf');
}
catch(HTML2PDF_exception $e) {
echo $e;
exit;
}
}