【问题标题】:Change text color in header in TCPDF更改 TCPDF 标题中的文本颜色
【发布时间】:2012-02-24 22:15:36
【问题描述】:

任何人都知道如何更改页眉和页脚中的文本颜色以及线条颜色? 在设置页眉/页脚之前简单地设置这两种颜色不起作用:

$pdf->SetTextColor(180);
$pdf->SetDrawColor(70);

谢谢。

【问题讨论】:

    标签: header pdf-generation footer tcpdf text-coloring


    【解决方案1】:

    好的,找到了, 我猜你必须更改 Header()Footer() 公共函数中的字体(在 tcpdf.php 中) 对于文本颜色查找:

    $this->SetTextColor(0, 0, 0); 
    

    在 Header() 和/或 Footer() 函数中,并根据自己的喜好进行更改。

    至于线条颜色,查找:

    $this->SetLineStyle(array('width' => 0.85 / $this->k, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(70, 70, 70)));
    

    并在最后更改“颜色”数组。

    干杯..

    【讨论】:

      【解决方案2】:

      或者你也可以这样做:

      通过扩展核心类并仅扩展其页脚功能:

      // Extend the TCPDF class to create custom Header and Footer
      class MYPDF extends TCPDF {
      // Page footer
      public function Footer() {
          //set text color
      $this->SetTextColor(255,0,0);
      
      }
      }
      
      // create new PDF document
      $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
      

      希望这会对某人有所帮助。

      【讨论】:

        猜你喜欢
        • 2017-07-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-12-24
        相关资源
        最近更新 更多