AddPage(); $pdf->SetFont('Arial','B',16); // Set Font here // Set the color to red $pdf->SetTextColor(255, 0, 0); $pdf->Cell(40,10,'Hello World!'); $pdf->Output(); ?>
AddPage(); $pdf->SetFont('Arial','B',16); // Set Font here // Set the color to yellow $pdf->SetTextColor('#ffcc00'); // Hexadecimal Code of Yellow $pdf->Cell(40,10,'Hello World!'); $pdf->Output(); ?>In this example, we are setting the text color to yellow in the PDF file with the help of SetTextColor function using hexadecimal value. Package Library: FPDF is the package library used in both examples.