我想要它,这样说白色的文本将使用 SetTextColor 作为白色,而橙色使用橙色。
$pdf->SetTextColor(255,255,255);
$pdf->Cell(50,0,'WHITE ORANGE ORANGE WHITE',0,1,'C');
如何影响“ORANGE”字词使用橙色文本颜色?
最佳答案
可以通过一些小技巧来实现。我只是让它打印 2 个单元格,一个叠在另一个单元格上,如下所示:
//Setting the text color to black
$pdf->SetTextColor(0,0,0);
//Printing my cell
$pdf->SetFont('Arial','B');
$pdf->Cell(55,5,"Black Text ",1,0,'C');
$pdf->SetXY($coordXbase,$coordY);
//Setting the text color to red
$pdf->SetTextColor(194,8,8);
//Printing another cell, over the other
$pdf->SetFont('Arial','B');
//Give some space from the left border, and print the red text after the black text that is in the cell behind this one.
$pdf->Cell(55,5," Red Text",0,0,'C');
$pdf->SetXY($coordXbase,$coordY);
//Setting the text color back to back, in the next cells.
$pdf->SetTextColor(0,0,0);
结果是这样的:
因为我有点匆忙,我没有时间创建一些函数来帮助解决这个问题,但这将是一个很好的起点 :)
P.S.:告诉你们是否找到更简单的方法。
关于php - FPDF:在单元格内更改文本颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14328848/