【问题标题】:New font not applied in tcpdf新字体未在 tcpdf 中应用
【发布时间】:2015-04-21 18:31:51
【问题描述】:
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 中应用并返回字体定义文件的错误。 有谁可以帮忙吗?

【问题讨论】:

    标签: php fonts tcpdf


    【解决方案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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 1970-01-01
      • 2011-03-25
      相关资源
      最近更新 更多