6

How to remove line below header and above $html in TCPDF?

http://www.tcpdf.org/examples/example_001.pdf

tcpdf.org/examples.php (examples with PDF ang PHP code!)

in this example this is line below http://www.tcpdf.org and above Welcome to TCPDF. How can i remove this?

Leo Delkin
  • 63
  • 1
  • 1
  • 4
  • Possible duplicate of [PHP TCPDF remove header's bottom border](https://stackoverflow.com/questions/7950493/php-tcpdf-remove-headers-bottom-border) – Xavi Montero May 01 '19 at 16:06

5 Answers5

28

As shown on the tcpdf website - examples in exemple 002 there is no header and here is the php code example.

The "magic" is done by this code:

// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);

and that is it! Hope it helps

4

You can remove it by subclassing TCPDF class, and overriding the methods Header() and Footer():

class MyTCPDF extends TCPDF
{
   public function Header()
   {
      // NOP! Overrides default header
   }
   public function Footer()
   {
      // NOP! Overrides default footer
   }
}
Alberto Arena
  • 344
  • 3
  • 12
3

I V tried writing this code,^_^

it works for both header & footer.

$pdf->setPrintHeader(false);

$pdf->setPrintFooter(false);

hello me
  • 31
  • 1
3

While I prefer the chosen answer by jnhghy - Jantea Alexandru, the following is an alternative way to do it if you just need something quick:

Change the following code:

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 058', PDF_HEADER_STRING);

to

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 058', PDF_HEADER_STRING, array(0,0,0), array(255,255,255));

This simply sets the color of the line to white (the background color of the page). The first array of colors is for the header text color, the second array of colors is for the header line color.

kojow7
  • 10,308
  • 17
  • 80
  • 135
-1

We can edit tcpdf.php file,

From:

protected $header_line_color = array(0,0,0); 

To :

protected $header_line_color = array(255,255,255);

That's it.

HebeleHododo
  • 3,620
  • 1
  • 29
  • 38
  • 3
    I recommend not editing the tcpdf.php file unless you absolutely need to. If a user ever upgrades their version of tcpdf their changes will need to be re-implemented. I have posted an alternate solution that has the same effect as yours but does not change the library file. – kojow7 Mar 01 '17 at 18:05