Reputation: 4924
I am trying to set a conditional statement where a footer is set or not.
if($data['voucher']===0){
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->AddPage();
$pdf->SetXY(0, 10);
$pdf->create_invoice();
}
//CUSTOM CONTENT
//END
$pdf->setPrintHeader(true);
$pdf->setPrintFooter(true);
But the footer is still set. However if I set
$pdf->setPrintHeader(true);
the header is set but footer doesn't react.
The Header()
and the Footer()
functions - are defined in an extended class.
Upvotes: 0
Views: 1748
Reputation: 492
Headers and footers aren't printed until the page is ended, which is normally called when you add a new page with Addpage(); So you should end the page manually and then turn headers/footers back on.
if($data['voucher']===0){
$pdf->AddPage();
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetXY(0, 10);
$pdf->create_invoice();
$pdf->Endpage(); //END THE PAGE AND TURN HEADERS/FOOTERS BACK ON
$pdf->setPrintHeader(true);
$pdf->setPrintFooter(true);
}
//CUSTOM CONTENT
//END
$pdf->Addpage(); // Any new page created now will again have headers footers
Upvotes: 3