require_once('tcpdf/tcpdf.php'); $pdf = new TCPDF(); $pdf->AddPage(); $pdf->SetTextColor(255,0,0); $pdf->Cell(0, 10, 'Hello World', 0, 1); $pdf->Output();
require_once('tcpdf/tcpdf.php'); $pdf = new TCPDF(); $pdf->AddPage(); $pdf->SetTextColor(0,0,255); $pdf->SetFont('helvetica', '', 12); $pdf->Cell(0, 10, 'This text is size 12', 0, 1); $pdf->SetFont('helvetica', '', 16); $pdf->Cell(0, 10, 'This text is size 16', 0, 1); $pdf->SetFont('helvetica', '', 20); $pdf->Cell(0, 10, 'This text is size 20', 0, 1); $pdf->Output();In both examples, the SetTextColor() method is used to change the color of the text that is output to the PDF document. The first example sets the color to red, while the second example sets it to blue. The package library used in these examples is TCPDF.