Home>Article>Backend Development> What to do if php dompdf Chinese garbled characters
##The operating environment of this tutorial: Windows 10 system, PHP version 8.1, DELL G3 computerphp dompdf Chinese garbled solution: 1. Open the front-end file; 2. Set "@font-face" {font-family:ttt;src: url(/static/font/simkai.ttf)}" refers to the Chinese font; 3. Delete "dompdf_font_family_cache.php".
What should I do if dompdf has Chinese garbled characters?
php exports pdf, Solution to garbled Chinese fonts in dompdf (especially garbled characters caused by code migration) dompdf\lib\fonts\dompdf_font_family_cache.php Remember that this file stores the cache generated by the font. If this file is overwritten during migration It will cause garbled code and it is difficult to find the error, believe me... dompdf is a tool for exporting html to pdf from php. It is very easy to use. Except for a few css3 attributes that are not supported, everything else is very good. Chinese needs to quote Chinese fonts. The specific method is briefly explained here: Code:$html = '测 测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试
##Need to explain:
10.@font-face
{
font-family:ttt;
src: url(/static/font/simkai.ttf)
}The ttf here is the font, and the location is placed under static/font. In HTML, you can directly use font-family:ttt; to reference it;
2. This is the file dompdf\lib \fonts\dompdf_font_family_cache.php
If you need to delete this when migrating the code, or change the name of the family.
Recommended study: "
PHP video tutorialThe above is the detailed content of What to do if php dompdf Chinese garbled characters. For more information, please follow other related articles on the PHP Chinese website!