Published - 7 years ago ( Updated - 7 years ago )
During development, will it be necessary to output HTML to PDF? This video introduces how to output PDF on the screen through the mpdf library of php.
The video contains a simple Chinese display method and a custom ttf font description. (about 11 minutes)
Here, by the way, the syntax of common automatic paging is provided for reference:
In the environment I use, index.php is placed in the public folder, not in the same folder as the vendor.
So here you need to execute '/../vendor/autoload.php' to include, please include the autoload file according to your own environment.
The video contains a simple Chinese display method and a custom ttf font description. (about 11 minutes)
Here, by the way, the syntax of common automatic paging is provided for reference:
In the environment I use, index.php is placed in the public folder, not in the same folder as the vendor.
So here you need to execute '/../vendor/autoload.php' to include, please include the autoload file according to your own environment.
namespace Mpdf;
require_once __DIR__ . '/../vendor/autoload.php';
$style = file_get_contents('css/style.css');
ob_start();
echo '';
echo '';
include 'docs/test.php';
include 'docs/footer.php';
echo '';
$content = ob_get_clean();
$mpdf = new Mpdf();
// for reference
//$mpdf->SetHeader('Document Title');
//$mpdf->SetHeader('Document Title|Center Text|{PAGENO}');
//Footer page font, such as BI
$mpdf->defaultfooterfontstyle='I';
//Do not draw a line above the Footer page.
$mpdf->defaultfooterline=0;
// set the page center
$mpdf->SetFooter('|total {PAGENO} of {nb} pages|');
//Do not draw a line above the Footer
//$mpdf->autoLangToFont = true;
$mpdf->WriteHTML(nl2br($content));
$mpdf->Output();
The REPO download location of mpdf on GitHub : https://github.com/mpdf/mpdf
No Comment
Post your comment