TCPDF set different headers for different pages in one document

The following worked for me,

class MYPDF extends TCPDF{
    function header1(){
        //print whatever the header 1 is
    }
    function Header2(){         
        if($this->page==1){
            //print header 1 and whatever the header 2 is
        }else{
            //print just header 2   
        }
    }
}

Strange. I'm having the same issue, but this worked in my older version of TCPDF version:4.8.009 and I noticed the issue when I upgraded to 5.9.149.

I compared the 2 and isolated the issue to the Header() function.

I could force it to allow me to change the header and accept it by running this:

$pdf->setHeaderTemplateAutoreset(true);