mpdf不支持中文字体
mpdf not supporting chinese fonts
我正在使用 mpdf。当我尝试将中文单词写入 WriteHtml() 时,生成的 pdf 包含方框而不是那些字体。
require 'mpdf/mpdf.php';
$mpdf->allow_charset_conversion = false;
$pdf = $this->pdf->load();
$pdf->useAdobeCJK = true;
$pdf->SetAutoFont(AUTOFONT_ALL);
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8']);
$mpdf->SetHeader('|<h2>Booking Invoice</h2>|');
$mpdf->setFooter('{PAGENO}');
$mpdf->autoScriptToLang = true;
$mpdf->autoLangToFont = true;
$mpdf->SetDisplayMode('fullpage');
ob_start();
include "test.php";
$html = ob_get_contents();
ob_end_clean();
$mpdf->WriteHTML($html);
我试过mpdf 6.0及以上版本,还是一样的结果
请指教
谢谢。
尝试:
$mpdf->allow_charset_conversion = true;
$mpdf->charset_in='UTF-8';
我修复了,如果你有同样的错误,请检查这个
header('Content-Type: text/html; charset=UTF-8');
include("mpdf/mpdf.php");
$mpdf=new \mPDF('+aCJK','A4','','',15,10,16,10,10,10);
$mpdf->SetHeader('|Booking Invoice|');
$mpdf->setFooter('{PAGENO}');
ob_start();
include('cis.php');
$html = ob_get_contents();
?>
<?php
$html = ob_get_clean();
$html = iconv('UTF-8', 'UTF-8//IGNORE', $html);
$html = iconv('UTF-8', 'UTF-8//TRANSLIT', $html);
$mpdf->SetAutoFont();
$mpdf->autoScriptToLang = true;
$mpdf->autoLangToFont = true;
$mpdf->WriteHTML($html);
在创建对象时使用模式
$mpdf = new Mpdf(['mode' => 'UTF-8']);
并将你的 utf-8 内容写入其中
我正在使用 mpdf。当我尝试将中文单词写入 WriteHtml() 时,生成的 pdf 包含方框而不是那些字体。
require 'mpdf/mpdf.php';
$mpdf->allow_charset_conversion = false;
$pdf = $this->pdf->load();
$pdf->useAdobeCJK = true;
$pdf->SetAutoFont(AUTOFONT_ALL);
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8']);
$mpdf->SetHeader('|<h2>Booking Invoice</h2>|');
$mpdf->setFooter('{PAGENO}');
$mpdf->autoScriptToLang = true;
$mpdf->autoLangToFont = true;
$mpdf->SetDisplayMode('fullpage');
ob_start();
include "test.php";
$html = ob_get_contents();
ob_end_clean();
$mpdf->WriteHTML($html);
我试过mpdf 6.0及以上版本,还是一样的结果
请指教
谢谢。
尝试:
$mpdf->allow_charset_conversion = true;
$mpdf->charset_in='UTF-8';
我修复了,如果你有同样的错误,请检查这个
header('Content-Type: text/html; charset=UTF-8');
include("mpdf/mpdf.php");
$mpdf=new \mPDF('+aCJK','A4','','',15,10,16,10,10,10);
$mpdf->SetHeader('|Booking Invoice|');
$mpdf->setFooter('{PAGENO}');
ob_start();
include('cis.php');
$html = ob_get_contents();
?>
<?php
$html = ob_get_clean();
$html = iconv('UTF-8', 'UTF-8//IGNORE', $html);
$html = iconv('UTF-8', 'UTF-8//TRANSLIT', $html);
$mpdf->SetAutoFont();
$mpdf->autoScriptToLang = true;
$mpdf->autoLangToFont = true;
$mpdf->WriteHTML($html);
在创建对象时使用模式
$mpdf = new Mpdf(['mode' => 'UTF-8']);
并将你的 utf-8 内容写入其中