by Devin Yang
(This article was automatically translated.)

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.
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

Tags: dlaravel

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


dlaravel

How to directly execute the php artisan of different projects in the container on the host.

This article is the application teaching of D-Laravel, how to directly execute php artisan in the container on the host side. After customizing the alias, you can directly execute php artisan in the contianer in the project folder on the host side. alias a="../../artisan.sh"

dlaravel

D-laravel has added the recommended opcache.ini settings

The latest version of D-Laravel has added opcache's recommended settings. The enabling method is very simple, please execute it in the D-Laravel directory.