by Devin Yang
(This article was automatically translated.)

Published - 6 years ago ( Updated - 6 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

D-Laravel specific service restart

Normally, we use ./console restart to rebuild and execute contaiener. Sometimes, we have multiple services and don't want to restart all services at once, At this time, you can use ./console restart [servce name] to restart a specific service..

docker,dlaravel

D-Laravel 1.5.5 Change Notes

D-Laravel's fpm image was rebuilt using the official dockerfile of docker php before php 7.2.1. And so I can specify that the default owner of fpm is dlaravel, --with-fpm-user=USER Set the user for php-fpm to run as. (default: nobody) --with-fpm-group=GRP Set the group for php-fpm to run as.

nginx,dlaravel

How to configure HTTPS on nginx to get an SSL A+ score from Qualys

This article describes how to adjust the ssl settings of nginx so that the website can obtain an SSL report and get an A+ rating. Here I am using letsencrypt free credentials. As long as you use the official Docker nginx new version image preset by D-Laravel, you should be able to achieve the same effect as mine. You can check your host SSL settings through the following. https://www.ssllabs.com/ssltest/index.html