Belmark Caday
Belmark Caday

Reputation: 1683

How to set the header background color in TCPDF?

Guys how do I set the background color of a header in TCPDF?

I have tried this one. Im quite new to TCPDF sorry:

function Header () {
  $this->setFillColor();
  $this->Rect();
}

I ended up with no header and a brown pdf page.

Upvotes: 2

Views: 7587

Answers (1)

KTB
KTB

Reputation: 367

You can set the fill color direct in the rect method. This example draws a green header:

public function Header() { $this->Rect(0, 0, 2000, 20,'F',array(),array(20, 255, 100)); }

TCPDF has the best documentation in the code itself. Have a look at the rect() parameters:

  • $x (float) Abscissa of upper-left corner.
  • $y (float) Ordinate of upper-left corner.
  • $w (float) Width.
  • $h (float) Height.
  • $style (string) Style of rendering. See the getPathPaintOperator() function for more information.
  • $border_style (array) Border style of rectangle.
  • $fill_color (array) Fill color. Format: array(GREY) or array(R,G,B) or array(C,M,Y,K) or array(C,M,Y,K,SpotColorName). Default value: default color (empty array).

Source: http://www.tcpdf.org/doc/code/classTCPDF.html#a8fc7b86c255aeb0f14d281bdaeb2015c

Upvotes: 7

Related Questions