我正在使用TCPDF,我正在尝试添加具有不同样式的自定义页脚,例如右侧Customer Name:
颜色应为蓝色,左侧Approved By:
颜色应为绿色,页面底部显示页码。
我在 pdf 页面中尝试过这个
$html_content = "<table><tr><td>Customer Name:</td><td style='color:blue;'>Suneel</td><td>Approved By:</td><td style='color:green;'>Srinu</td></tr></table></hr>"
$tcpdf->xfootertext($html_content);
它有效,但不接受样式
在 TCPDF 类中
function Footer()
{
$year = date('Y');
$footertext = sprintf($this->xfootertext, $year);
$this->writeHTMLCell(0, 0, '', '', $footertext, 0, 0, false,true, "L", true);
$this->SetY(8);
// Set font
$this->SetFont('helvetica', 'I', 8);
// Page number
$this->Cell(0, 27, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
最后我找到了答案,页脚已经接受了所有样式,我们将解析不同颜色的动态内容。
这里是解决方案
$this->writeHTML($footertext, false, true, false, true);
代替
$this->writeHTMLCell(0, 0, '', '', $footertext, 0, 0, false,true, "L", true);
我已经更改了 writeHTML 而不是 writeHTMLCell 它也接受页脚颜色。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句