Generate PDF from Html is always difficult, because if you want a better look PDF then you must need to spend good amount of time of it. TCPDF is well known to us as a rich PDF library. No problem with it but HTML2PDF is some type of as layer over TCPDF which makes it better. It has great custom page header and footer support.
Below is a code snippet:
require_once(dirname(__FILE__) . '/../vendor/autoload.php');
try {
$html2pdf = new HTML2PDF('P', 'A4', 'en');
$html2pdf->setDefaultFont('Arial');
$html2pdf->writeHTML($html_content);
$html2pdf->Output('PdfName.pdf');
} catch (HTML2PDF_exception $e) {
echo $e;
exit;
}
You can download full example code from link below.
Click here to download.
Below are attached some screenshots:
Below is a code snippet:
require_once(dirname(__FILE__) . '/../vendor/autoload.php');
try {
$html2pdf = new HTML2PDF('P', 'A4', 'en');
$html2pdf->setDefaultFont('Arial');
$html2pdf->writeHTML($html_content);
$html2pdf->Output('PdfName.pdf');
} catch (HTML2PDF_exception $e) {
echo $e;
exit;
}
You can download full example code from link below.
Click here to download.
Below are attached some screenshots:
No comments:
Post a Comment