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