AddPage()
in tcpdf automatically calls Header and Footer. How do I eliminate/override this?
You can also delete a header from a single page. Go to Insert > Header or Footer, and then select Remove Header or Remove Footer.
On the Insert tab, in the Text group, click Header & Footer. Excel displays the worksheet in Page Layout view. To add or edit a header or footer, click the left, center, or right header or footer text box at the top or the bottom of the worksheet page (under Header, or above Footer).
Click or tap where you want to start a new page without the header or footer. Go to Layout > Breaks > Next Page to create a section break. Double-click the header or footer area (near the top or bottom of the page) to open the Header & Footer tab. Select Link to Previous to turn off the link between the sections.
Use the SetPrintHeader(false)
and SetPrintFooter(false)
methods before calling AddPage()
. Like this:
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'LETTER', true, 'UTF-8', false); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); $pdf->AddPage();
A nice easy way to have control over when to show the header - or bits of the header - is by extending the TCPDF class and creating your own header function like so:
class YourPDF extends TCPDF { public function Header() { if (count($this->pages) === 1) { // Do this only on the first page $html .= '<p>Your header here</p>'; } $this->writeHTML($html, true, false, false, false, ''); } }
Naturally you can use this to return no content as well, if you'd prefer to have no header at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With