新字体未在tcpdf中应用

时间:2015-02-20 06:28:07

标签: php fonts tcpdf

I have an HTML to convert into pdf using TCPDF library as below,

require_once('tcpdf/tcpdf_include.php');

// create new PDF document`enter code here`
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// convert TTF font to TCPDF format and store it on the fonts folder
$fontname1 = $pdf->addTTFfont('tcpdf/fonts/2C83A2_0_0.ttf', 'AzoWeb-Bold');
// use the font
$pdf->AddFont($fontname1, '', 14, '', false);
$html = '<div style="font-family: \'AzoWeb-Medium\';">Testing new fonts</div>';

//echo $html;exit; 
$pdf->AddPage();

// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');

//Close and output PDF document
$pdf->Output("example1.pdf", 'I');

字体未应用于HTML并返回字体定义文件的错误。 有人可以提供帮助吗?

1 个答案:

答案 0 :(得分:1)

使用SetFont(),

进行更新
// convert TTF font to TCPDF format and store it on the fonts folder
$fontname1 = $pdf->addTTFfont('tcpdf/fonts/2C83A2_0_0.ttf', 'AzoWeb- Bold',   '', 96);
// use the font
$pdf->SetFont($fontname1, '', 14, '', false);