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

How to set the external network IP to the Project on D-Laravel?

This video introduces how we assign Public Ip (public IP) to a specific Project in the D-Laravel environment. Whether it is the setting of the external production environment or the demo of your own project on the intranet, you can refer to the setting method of this video. In the video, although I used the external network IP of PPPoE dial-up to illustrate, we can also use the local network IP on our own computer if we change it. In this way, colleagues can connect to our D-Laravel Project.