简体   繁体   中英

Change text color in FPDF for text within cell

I want to chnage the text colour for just the text "HACCP Bulker Check" in the below code:

$pdf->SetTextColor(255,0,0);
$pdf->MultiCell($cell_width * 2, $cell_height, "HACCP Bulker Check\nPre-loading foreign object free", 'TLR', 1);
$pdf->SetTextColor(0,0,0);

Is there a way to do this? The rest of the text needs to be black.

How about splitting the text?

$pdf->SetTextColor(255,0,0);
$pdf->MultiCell($cell_width * 2, $cell_height, "HACCP Bulker Check", 'TLR', 1);
$pdf->Ln();
$pdf->SetTextColor(0,0,0);
$pdf->MultiCell($cell_width * 2, $cell_heigt, "Pre-loading foreign object free", 'LR', 1);

You might need to adjust the cell widths. Note the changed border value for the second cell.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM