Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在一个TCPDF单元格中使用两种颜色?_Php_Tcpdf - Fatal编程技术网

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

Php 如何在一个TCPDF单元格中使用两种颜色?,php,tcpdf,Php,Tcpdf,我有一个发票模板。我使用单元格将文本显示到框中 这是我的密码: $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,

我有一个发票模板。我使用单元格将文本显示到框中

这是我的密码:

$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);
我想在第二个单元格中使用两种文本颜色。 $ntitle应为黑色回声,$factornum应为红色

例如,输出必须如下所示:

编号:黑色1898,红色1898

如何在TCPDF中执行此操作

我查看了TCPDF示例。但我没有得到任何结果

$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);