Convert HTML to PDF using php
- First of all we need the supporting file so please download TCPDF
- Just create pdf.php file and copy the below code.
- The supporting file locate as the same folder or you just modify the link in above code as require_once(dirname(__FILE__).'/tcpdf/tcpdf.php');.
<?php
$url=parse_url($_SERVER['HTTP_REFERER']);
// Include the main TCPDF library (search for installation path).
require_once(dirname(__FILE__).'/tcpdf/tcpdf.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Sakthivel');
$pdf->SetTitle('talentcoders.blogspot.com Download pdf');
$pdf->SetSubject('Downloadable pdf');
$pdf->SetKeywords('PDF for invoice');
// set default header data
/*$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));*/
/*$pdf->setFooterData(array(0,64,0), array(0,64,128));*/
// set header and footer fonts