PHP code example of html2pdf / html2pdf-2image
1. Go to this page and download the library: Download html2pdf/html2pdf-2image library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
html2pdf / html2pdf-2image example snippets
use \Html\Html2Pdf;
use \Html\Html2Image;
$html = '<html><head><title>export</title>......';
// or
// $html = file_get_contents('http://google.com');
// Pdf
$generator = new Html2Pdf('/usr/local/bin/wkhtmltopdf');
$options = ['header'=>'Centered header text','footer'=>'Left aligned footer text'];
$generator->getOutputFromHtml($html, $options)
// Image
$generator = new Html2Image('/usr/local/bin/wkhtmltoimage');
$options = ['format'=>'png','width'=>'300','height'=>'1000'];
$generator->getOutputFromHtml($html, $options)