Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header and the Footer ONLY on the First Page? #522

Open
reinhardjung opened this issue Dec 10, 2019 · 3 comments · May be fixed by #525
Open

Header and the Footer ONLY on the First Page? #522

reinhardjung opened this issue Dec 10, 2019 · 3 comments · May be fixed by #525

Comments

@reinhardjung
Copy link

@reinhardjung reinhardjung commented Dec 10, 2019

Hi @ll

Does anybody know how to just use the Header and the Footer ONLY on the First Page?

So the Opposite of the page hideHeader="" :-(

AND/But the Page Numbers on every Page.

Thanx a lot 4 any help!

@reinhardjung reinhardjung changed the title Hi @ll Does anybody know how to just use the Header and the Footer on the First Page with https://github.com/spipu/html2pdf? So the Opposite of the <page hideHeader=""> :-( Thanx a lot!!!! Header and the Footer ONLY on the First Page? Dec 10, 2019
@reinhardjung

This comment has been minimized.

Copy link
Author

@reinhardjung reinhardjung commented Dec 10, 2019

I changed something about the Page, but then (somehow logical) the first page will be empty (with not Invoice-Positions) :-(

Bildschirmfoto 2019-12-10 um 03 45 32

This is how i wish it should be:
shouldbe

@marbetschar

This comment has been minimized.

Copy link

@marbetschar marbetschar commented Dec 10, 2019

@spipu trying to accomplish a similar thing: Two different layouts, one for the first page and another one for all subsequent pages. Unfortunately I don't know how much content I have beforehand - so I can't say whether the content needs more than one page or not.

Tried to get this done using one page layout containing a footer, which hides parts with css - depending on the page number [[page_cu]]: The css class names contain [[page_cu]], enabling me to distinguish between first or subsequent pages. Unfortunately this does not seem to work. The [[page_cu]] dependent css rules have no effect at all (code below).

What's the recommended approach here?

<style type="text/css">
<!--
.footer-primary { position:absolute; left:-1000px; } /* hide primary footer by default */
.footer-primary.footer-primary-1 { position:static; left:auto; } /* show primary footer on first page */
.footer-secondary.footer-secondary-1 { position:absolute; left:-1000px; } /* hide secondary footer on first page */
-->
</style>
<page backtop="30mm" backbottom="25mm" backleft="0mm">
<page_footer>
  <table border="1" style="width: 100%;" class="footer-primary footer-primary-[[page_cu]]">
  <tr>
  <td style="width: 100%; text-align: center;">
    <img style="width:400px;" src="'.$myFileFooter.'"/>
  </td>
  </tr>
  </table>
<table border="1" style="width: 100%;" class="footer-secondary footer-secondary-[[page_cu]]">
      <tr>
          <td style="width: 100%; text-align: right">
              Page <strong>[[page_cu]]</strong> of <strong>[[page_nb]]</strong>
          </td>
      </tr>
  </table>
</page_footer>

EDIT: Added css comments in code above.

marbetschar added a commit to marbetschar/html2pdf that referenced this issue Dec 10, 2019
This fixes spipu#522 by allowing the usage of the current page number within a css class name. By using this we are allowed to apply different styling depending on which page we are.
@marbetschar marbetschar linked a pull request that will close this issue Dec 10, 2019
@marbetschar

This comment has been minimized.

Copy link

@marbetschar marbetschar commented Dec 10, 2019

@spipu added pull request with needed change to fix footer styling for first/subsequent pages. Any chance this can be merged soon with a new release? Would be awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.