Change text color in header in TCPDF

15.7k views Asked by At

Anyone knows how to change a color of text in header and footer and also line color?? Simply setting these two colors before setting header/footer doesn't work with:

$pdf->SetTextColor(180);
$pdf->SetDrawColor(70);

Thanks.

2

There are 2 answers

0
atif On

or alternatively you can do it this way too :

By extending core class and extending just its footer function :

// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {
// Page footer
public function Footer() {
    //set text color
$this->SetTextColor(255,0,0);

}
}

// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

Hope this will help someone.

0
jazkat On

Ok, found it, I guess you have to change font in Header() and Footer() public functions (in tcpdf.php) For text color find:

$this->SetTextColor(0, 0, 0); 

in Header() and/or Footer() functions and change it to your liking.

As for line color, find:

$this->SetLineStyle(array('width' => 0.85 / $this->k, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(70, 70, 70)));

and change the 'color' array at the end.

cheers..