Jump to content

Show header only on 1st page of Pdf


Recommended Posts


This post is regarding PS 1.6

I am generating  invoices PDF, and the length of the invoice PDF is of 2 pages, and both the page have  header and footer, but I don't want header from 2nd page onwards for which I tried the following code in \tools\tcpdf\tcpdf.php inside Startpage method nearly on line 4094


if($this->numpages == 1)

It worked, and the header was not getting displayed from 2nd page onwards, but the issue is, it is still leaving margin space from the top of the 2nd page due to which a blank space is getting displayed on the 2nd page.
For Resolving I tried the following code on classes\pdf\PDFGenerator.php inside the writePage method. nearly on line 217

if($this->numpages == 1){

$this->setMargins(10, 40, 10);


But by this, all page are getting affected.

Any help will be appreciated. 

IN000009 (18).pdf

Share this post

Link to post
Share on other sites

  • 3 weeks later...
  • 3 years later...

I found a solution for this. 

// Page footer public function Footer() { if ($this->page == 1) { $this->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); } }

set margin back to normal on footer

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More