New version Dompdf installation
Version is 6 beta
Dompdf Download:
Https://github.com/dompdf/dompdf
Php-font-lib Download:
Https://github.com/PhenX/php-font-lib
1. The new dompdf appears to have no php-font-lib by default and is then placed in the Dompdf\lib\php-font-lib directory after downloading.
2. Check/install new fonts, Chinese fonts recommended to use Google's Droidsansfallback, only more than 3MB.
(1) Modify the dompdf_config.inc.php configuration file before installing the font
def ("Dompdf_admin_username", "yourname");
def ("Dompdf_admin_password", "YourPassword");
User name, which is required when installing fonts.
(2) Check if the dompdf_config.inc.php contains php-font-lib path configuration, make sure the system can find the font.php
Require_once (Dompdf_lib_dir. "/php-font-lib/src/fontlib/font.php");
Add to the configuration file.
(3) browser enters dompdf/www/fonts.php for font installation
Four fonts, normal, bold, italic, etc., installed each.
Include ' dompdf6/dompdf_config.inc.php ';
$html = <<
END;
$html = file_get_contents (' pdf.html ');
There are several ways to reference a template.
$html =
// ''.
// '
Put your HTML here, or generate it with your favourite '.
' Templating system.
A second look at the support Chinese no?
'.
// '';
$dompdf = new Dompdf ();
$dompdf->load_html (Utf8_decode ($html), ' UTF-8 ');
$dompdf->load_html ($html, ' UTF-8 ');
$dompdf->load_html ($html, ' GBK ');
$dompdf->render ();
$dompdf->stream ("sample.pdf");
If Chinese is not supported, add font definition to Chinese:
In the HTML template.
If there is no automatic line-wrapping in Chinese, use div to try. Support for table is not good.