1)字體的偉大工程 首先,我複製我的Windows8 「宋體」 fonr從C :\ windows \ fonts到一個名爲「tnr」的tcpdf/fonts下的臨時目錄。有4個文件「times.ttf」,「timesbi.ttf」,「timesbd.ttf」,「timesi.ttf」。
2)然後從TCPDF /字體除去 「times.php」
3)重拍倍DEF字體和與此
// remake times
$fontpath1='../fonts/tnr/times.ttf';
$fontpath2='../fonts/tnr/timesbd.ttf';
$fontpath3='../fonts/tnr/timesbi.ttf';
$fontpath4='../fonts/tnr/timessi.ttf';
$fontname1 = $pdf->addTTFfont($fontpath1, 'TrueTypeUnicode', '', 96);
$fontname2 = $pdf->addTTFfont($fontpath2, 'TrueTypeUnicode', '', 96);
$fontname3 = $pdf->addTTFfont($fontpath3, 'TrueTypeUnicode', '', 96);
$fontname4 = $pdf->addTTFfont($fontpath4, 'TrueTypeUnicode', '', 96);
4)修飾的腳本添加新的雙(粗斜體)以4種方式打印字符串。大膽和斜體不起作用,但不知道如何重製它們。但是,粗體和粗體斜體可以起作用,並且您可以看到對比。
5)修改後的腳本
<?php
// Include the main TCPDF library (search for installation path).
require_once('tcpdf_include.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator('zzz');
$pdf->SetAuthor('zzz');
// set default font subsetting mode
//$pdf->setFontSubsetting(true);
// remake times
$fontpath1='../fonts/tnr/times.ttf';
$fontpath2='../fonts/tnr/timesbd.ttf';
$fontpath3='../fonts/tnr/timesbi.ttf';
$fontpath4='../fonts/tnr/timessi.ttf';
$fontname1 = $pdf->addTTFfont($fontpath1, 'TrueTypeUnicode', '', 96);
$fontname2 = $pdf->addTTFfont($fontpath2, 'TrueTypeUnicode', '', 96);
$fontname3 = $pdf->addTTFfont($fontpath3, 'TrueTypeUnicode', '', 96);
$fontname4 = $pdf->addTTFfont($fontpath4, 'TrueTypeUnicode', '', 96);
$pdf->AddPage();
$string="TỔNG HỢP";
$pdf->SetFont('times', '', 14, '', false);
$pdf->writeHTML('default ' . $string,true, 0, true, 0);
$pdf->SetFont('times', 'b', 14, '', false);
$pdf->writeHTML('bold ' . $string,true, 0, true, 0);
$pdf->SetFont('times', 'i', 14, '', false);
$pdf->writeHTML('italic ' . $string,true, 0, true, 0);
$pdf->SetFont('times', 'bi', 14, '', false);
$pdf->writeHTML('bold italic ' . $string,true, 0, true, 0);
//Close and output PDF document
$pdf->Output('test.pdf', 'I');
?>
看起來也許字體不支持「O」和「o」。如何這個其他SO帖子:http://stackoverflow.com/questions/9426983/creating-pdfs-using-tcpdf-that-supports-all-languages-especially-cjk – Angst