Home > Article > Backend Development > Yii integrated HTML2PDF
http://html2pdf.fr/en/default (On the homepage of the class library, click on github at the top to download the class library)
After downloading, use it in Yii. Since its file structure does not comply with Yii's automatic loading method, we load it manually. In the Yii directory structure, modify backend/web/index.php and add $vendorDir = dirname(dirname(__DIR__)) . '/vendor';
$application = new yiiwebApplication($config);
Yii::$classMap ['HTML2PDF'] = $vendorDir . '/html2pdf/html2pdf.class.php'; // Add this class before starting yii
$application->run();
Usage: somewhere in yii In the controller,
use HTML2PDF;
....
try
{
$html2pdf = new HTML2PDF('P','A4','en', true, 'UTF-8', array(15, 5, 15, 5));
$html2pdf->setDefaultFont('javiergb'); // This is a Chinese font library, in (webERP/includes/tcpdf/fonts/ directory) webERP needs to be downloaded manually, http: //sourceforge.net/projects/web-erp/
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->writeHTML($pdfcontent);
$filename = $orderId . '. pdf';
$html2pdf->Output($filename);
}
catch(HTML2PDF_exception $e) {
echo $e;
exit;
}
The last PDF to HTML website http://www .htmlpublish.com/convert-pdf-to-html/
Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above introduces Yii's integration of HTML2PDF, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.