【问题标题】:PHP FPDF changing font size in specific are onlyPHP FPDF 仅更改字体大小
【发布时间】:2021-01-30 13:48:42
【问题描述】:

我已将所有 pdf 的字体大小设置为 10,问题是如果我想在不改变整体字体大小的情况下更改 pdf 特定区域的字体大小,可以做到吗?看下面的代码,我想改变这些区域的字体大小 $pdf->SetXY(17, 80) ;

 <?php

 require_once('../../bus_partners/fpdf/fpdf/fpdf.php');
 require_once('../../bus_partners/fpdf/fpdi/fpdi.php');

 $pageCount   =  $pdf->setSourceFile('../../bus_partners/BIR-forms/2316.pdf') ;
 $tplIdx      =  $pdf->importPage(1, '/MediaBox');
                     
 $pdf->SetAutoPageBreak(false) ;
 $pdf->addPage('P', 'Legal') ;
 $pdf->useTemplate($tplIdx, 8, 12, 200, 320) ;


 // setting the font size for the whole page
 $pdf->SetFont('Arial');
 $pdf->SetFontSize(9);
 $pdf->SetTextColor(12, 12, 12);


 // Can I set the font size in this specific area only ?
 $pdf->SetXY(17, 80) ;
 $pdf->Write(0, $address_ee) ;



 ?>




 

【问题讨论】:

    标签: php fpdf


    【解决方案1】:

    就这样吧:

    <?php
    ...
      $pdf->SetFont('Arial', 'B', 14);
      $pdf->SetXY(17, 80) ;
      $pdf->Write(0, $address_ee) ;
    ...
    ?>
    

    您可以在这里看到 setFont 的设置: http://www.fpdf.org/en/doc/setfont.htm

    【讨论】:

      猜你喜欢
      • 2019-09-29
      • 2012-09-18
      • 2014-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-04
      • 2017-05-09
      相关资源
      最近更新 更多