简体   繁体   English

如何在一个TCPDF单元中使用两种颜色?

[英]How to use two color in one TCPDF Cell?

I have an invoice template. 我有发票模板。 i used Cell for showing text into box. 我用单元格显示文本到框中。

here is my code: 这是我的代码:

$ntitle = 'No:';
$factornum = '1898';
$startheader = 15;
$pdf->SetXY($startheader, 4);
$pdf->Cell(50, 0, 'Date: '.date("Y-m-d"), 1, 1, 'C', 0, '', 1);
$pdf->SetXY($startheader, 12);
$pdf->SetTextColor(255, 0, 0);
$pdf->Cell(50, 0,  $ntitle . $factornum, 1, 1, 'C', 0, '', 1);
$pdf->SetTextColor(0, 0, 0);

I want to use two text color in second cell. 我想在第二个单元格中使用两个文本颜色。 $ntitle should be echo in black and $factornum in red $ ntitle应该用黑色回显,$ factornum用红色

For example, output must be like: 例如,输出必须类似于:

No: (with black color) 1898 (with red color) 否:(黑色)1898(红色)

How can I do this in TCPDF? 如何在TCPDF中执行此操作?

I checked TCPDF examples. 我检查了TCPDF示例。 but I did not get any results 但我没有得到任何结果

$ntitle = 'No:';
$factornum = '1898';
$startheader = 15;
$pdf->AddPage();
$pdf->SetXY($startheader, 4);
$pdf->Cell(50, 0, 'Date: '.date("Y-m-d"), 1, 1, 'C', 0, '', 1);
$pdf->SetXY($startheader, 12);
$pdf->SetTextColor(255, 0, 0);
//$pdf->Cell(50, 0,  $ntitle . $factornum, 1, 1, 'C', 0, '', 1);
$pdf->SetFillColor(255, 255, 255);
$pdf->writeHTMLCell(50, '', '', '', '<span style="color:#000">'.$ntitle.'</span>' . $factornum, 1, 1, 'C', 0, '', 1);
$pdf->SetTextColor(0, 0, 0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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