SetTextColor()

		
		SetTextColor(int r [, int g, int b])

Defines the color used for text. It can be expressed in RGB components or gray scale. The method can be called before the first page is created and the value is retained from page to page.

r

Value between 0 and 255.

g

Green component (between 0 and 255).

b

Blue component (between 0 and 255).

Here is an Example -

	
	$str = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do";
	$pdf->setTextColor(103, 58, 183);
	$pdf->MultiCell(0, 10, $str, 1, 'J');

The above example gives the following output -

SetFillColor()

	
	SetFillColor(int r [, int g, int b])

Defines the color used for all filling operations (filled rectangles and cell backgrounds). It can be expressed in RGB components or gray scale. The method can be called before the first page is created and the value is retained from page to page.

r

Value between 0 and 255.

g

Green component (between 0 and 255).

b

Blue component (between 0 and 255).

You can set the color to Cell() or MultiCell() methods. But you cannot set color to Write() method. It means methods which accepts fill arguments, only those can have background and border color.

To make SetDrawColor() and SetFillColor() effective, you must provide the fill value to true in Cell() or MultiCell() method.

Consider the following example -

	$pdf = new FPDF();
	$pdf->SetTextColor(255, 255, 255);
	$pdf->SetFillColor(0, 80, 180);
	// Fourth Page --
	$pdf->AddPage();
	$pdf->SetFont('Arial','B',16);
	$pdf->Cell(0, 10, "Hello Santanu", 1, 1, 'C', true);

	$pdf->Output('helo.pdf', 'D');

The above code produce the following output -

SetDrawColor()


	SetDrawColor(int r [, int g, int b])

Defines the color used for all drawing operations (lines, rectangles and cell borders). It can be expressed in RGB components or gray scale. The method can be called before the first page is created and the value is retained from page to page.

r

Value between 0 and 255.

g

Green component (between 0 and 255).

b

Blue component (between 0 and 255).

Consider the following example -

		$pdf->AddPage();
		$pdf->SetFont('Arial','B',16);
		$pdf->SetFillColor(0, 80, 180);
		$pdf->SetDrawColor(255, 0, 0);
		$pdf->SetTextColor(103, 58, 183);
		$pdf->Cell(0, 10, "Hello Santanu", 1, 1, 'C' ,true);

The above example produce the following output -

Notice the use of SetFillColor() before using SetDrawColor() method? It is mandatory to use SetFillColor() before drawing any cell. Otherwise the fill color will be black by default.