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

D-Laravel's sublime plug-in can be installed by Package Control.

Mac or Linux users can now install the D-Laravel alias package from Sublime3's package control. Through D-Laravel alias, we can execute artisan and composer commands in the container in an easier way. In the docker environment, do you want to use composer to install the package? You don’t need to enter the container, or set the ce alias of composer, and you can execute it directly in sublime.

dlaravel

How to start supervisor on D-Laravel

Since queue workers are a long-running program, we need a program manager supervisor to monitor whether the process on the Linux system is running continuously. For example, when the queue:work operation fails, the queue:work process can be automatically restarted. Fortunately, D-Laravel has a built-in supervisor, so you don't need to install it yourself to use it. This article briefly introduces how we start the supervisor in the container.

dlaravel

Use D-Laravel to build your own dedicated php fpm image.

D-Laravel has provided a built php image, if you need to adjust it yourself and build your own dedicated image is quite simple. 1. First, enter dockerfiles/fpm in D-Laravel, and select the PHP version you want to build, such as 7.2. The command is as follows...