对日语(utf8)的 HTML2PDF 支持不起作用 [英] HTML2PDF support for japanese language(utf8) is not working
问题描述
对于在 PHP 中生成的报告,我使用的是 HTML2PDF.
For report generation in PHP I am using HTML2PDF.
它适用于英语,但不能为日语提供适当的输出.
It works fine with English language but not giving proper output for Japanese language.
如何在 hHTML2PDF 库中设置 utg8 字符.
How can I set utg8 character in hHTML2PDF library.
有没有办法在 HTML2PDF 库中实现这一点.我得到了像???????????????"这样的输出而不是日语文本
Is there a way to achieve this in HTML2PDF library. I am gettign output like "???????????????" instead of Japanese text
在/var/www/html/html2pdf/locale 文件夹中,我找到了以下文件en.csv、fr.cvs、cs.csv、da.csv
In /var/www/html/html2pdf/locale folder following files I found en.csv, fr.cvs, cs.csv, da.csv
我们也能得到这样的日文文件吗.
Can we get such file for Japanese too.
下面是我的代码
<?php
$content = ob_get_clean();
// convert to PDF
require_once('Classes/library/html2pdf.class.php');
try {
$html2pdf = new HTML2PDF('P', 'A4', 'en');
$html2pdf->pdf->SetDisplayMode('fullpage');
// $html2pdf->pdf->SetProtection(array('print'), 'spipu');
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
$filename = $filename .'_'.date('Ymd');
$html2pdf->Output($filename.'.pdf','D');//,'D'
}
catch(HTML2PDF_exception $e) {
echo $e;
exit;
}
推荐答案
尝试使用指定字体而不是默认字体,试试这个
Try to use a specify fonts instead of the default, try this
<?php
$html2pdf = new HTML2PDF('P', 'A4', 'en', true, 'UTF-8');
$html2pdf->setDefaultFont('arialunicid0'); //add this line
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->writeHTML($content, false);
$html2pdf->Output('japan.pdf');
?>
参考:http://community.impresscms.org/modules/newbb/viewtopic.php?post_id=43474#forumpost43474
这篇关于对日语(utf8)的 HTML2PDF 支持不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!