I want to convert html code to image on run of PHP code through CLI
<div id="canvas" style="background-color: white;">
<table width="340px" style="340px;" >
<tbody>
<tr>
<td><img src="header.jpeg"></td>
</tr>
<tr></tr>
<tr>
<td style="">
Dear , sss<br>
Sincerely,<br>
ameeth </td>
</tr>
<tr> </tr>
<tr>
<td><img src="footer.jpeg"></td>
</tr>
<tr> </tr>
</tbody>
</table>
I tried html2canvas
, it works on browser mode, but I need to run this as cron. Can someone show how to be executed through CLI?
I usually use mPDF or tcpdf. If you want to save a page in pdf using mpdf, get the html code, then:
include(dirname(__FILE__)."/tools/mpdf/mpdf.php");
$mpdf=new mPDF('c');
$mpdf->setFooter('{PAGENO}/{nb}');
$mpdf->WriteHTML($html);
$content = $mpdf->Output('', 'S');
file_put_contents( 'filename'.pdf' , $content);