Skip to content
Advertisement

PHP FPDF changing font size in specific are only

I have set font size for over all pdf to 10, Question is if I want to change the font size for the specific area of pdf without changing the font size over all, can it be done? See below code, I want to change the font size in these area $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) ;



 ?>




 

Advertisement

Answer

Just do it like this:

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

You could see the setting for setFont in here: http://www.fpdf.org/en/doc/setfont.htm

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement