php - How to set 2 different color for different texy in FPDF -


how set 2 different colors in fpdf??

i have tried code below

$pdf=new fpdf();                      $pdf->addpage('p', 'a5'); $pdf-> setmargins(25, 50); $pdf->settextcolor(91,137,42);  $pdf->setfont('times','',10); $pdf -> text (60,  37,  'title' );  $pdf->settextcolor(0,0,0); $pdf->setfont('times','',15); $pdf -> text (60,  37,  'invoice' ); 

but tests displaying single color.

any solution this?

i made minimal working example code:

<?php require('fpdf/fpdf.php');     $pdf=new fpdf();  $pdf->addpage('p', 'a5');  $pdf->setmargins(25, 50);  $pdf->settextcolor(91,137,42);  $pdf->setfont('times','',10);  $pdf->text (60,  27,  'title' );  $pdf->settextcolor(99,0,0);  $pdf->setfont('times','',15);  $pdf->text (60,  57,  'invoice' );     $pdf->output('test.pdf'); 

when holding generated document open (okular test.pdf), changing color values , re-running code can see document getting updated , colors change. code works expected.


considering first version of question , comments imagine issue getting text color in header of page? works expected if follow documentation:

<?php require('fpdf/fpdf.php');  class mypdf extends fpdf {   function header() {     $this->setfont('arial','b',15);     $this->settextcolor(0, 120, 120);     $this->cell(80);     $this->cell(30,10,'page title',1,0,'c');     $this->ln(20);   } }  $pdf=new mypdf(); $pdf->addpage('p', 'a5'); $pdf->setmargins(25, 50); $pdf->settextcolor(91,137,42); $pdf->setfont('times','',10); $pdf->text (60,  27,  'heading' ); $pdf->settextcolor(99,0,0); $pdf->setfont('times','',15); $pdf->text (60,  57,  'invoice' ); $pdf->output('test.pdf'); 

note in case text color has set in header() function, not later, when create page features header...

this resulting document, can see colors: enter image description here


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -