Kenny Wyland
Kenny Wyland

Reputation: 21890

dompdf: How to add header on every page except first?

I'm using dompdf to generate a PDF. I've grabbed the code from the dompdf website to add a Header to the pdf and it's working, but I would like to put the header on every page except for the first. Any suggestions?

Upvotes: 11

Views: 27244

Answers (3)

Memonic
Memonic

Reputation: 345

Same issue, explained by a DOMPDF Project Member

https://github.com/dompdf/dompdf/issues/347

Worked for me, my first page is a cover (no header no footer)

Upvotes: 0

user1231342435346354
user1231342435346354

Reputation: 47

Because when you set header, header will appear of every page of the document, you can use div element to hide header from first page. Div with white background color and z-index greater then header and you will put that div on the top of the page and set position exactly over first page header.

<div style="background-color: white; z-index: 2;"></div>

I have tested this and its worked. I wish this will help.

Upvotes: 5

Fabien M&#233;nager
Fabien M&#233;nager

Reputation: 140185

You can do this by inserting the header and footer elements after the elements that appear in the first page.

For example :

<style>
  .flyleaf {
    page-break-after: always;
  }

  .header, .footer {
    position: fixed;
  }

  .header {
    top: 0;
  }

  .footer {
    bottom: 0;
  }
</style>

<div class="flyleaf">
  Some big title
</div>

<div class="header">
  my header
</div>

<div class="footer">
  my footer blah, blah
</div>

<p>The content</p>

Edit: added the style tag

Upvotes: 18

Related Questions