【问题标题】:How to add custom footer with styles in TCPDF如何在 TCPDF 中添加带有样式的自定义页脚
【发布时间】:2017-07-19 20:44:55
【问题描述】:

我正在使用 TCPPDF ,我正在尝试添加具有不同样式的自定义页脚,例如右侧 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');
}

【问题讨论】:

    标签: php css pdf footer tcpdf


    【解决方案1】:

    终于找到答案了,Footer已经接受了所有样式,我们将用不同的颜色解析动态内容。

    这里是解决方案

    $this->writeHTML($footertext, false, true, false, true);
    

    代替

    $this->writeHTMLCell(0, 0, '', '', $footertext, 0, 0, false,true, "L", true);
    

    我改变了 writeHTML 而不是 writeHTMLCell 它也接受页脚颜色。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-04
      • 2015-07-05
      • 2016-11-06
      • 2017-12-16
      相关资源
      最近更新 更多