Show various footers on the first and subsequent pages with pisa / xhtml2pdf

I'm having trouble getting the footer to appear as one frame on the first page of Pisa's document and as another frame on every other page. I tried to adapt the idea of โ€‹โ€‹lastPage from here , but no luck.

Can this be done? <pdf:nextpage /> does not seem right here, as the document has a long table that can (or cannot) flow through several pages. <pdf:nextframe /> plus the border with the first page looks promising, although I'm not sure how to use it.

Currently I (short for short):

 <style type="text/css"> @page { margin: 1cm; margin-bottom: 2.5cm; @frame footer { -pdf-frame-content: footerFirst; -pdf-frame-border: 1; bottom: 2cm; margin-left: 1cm; margin-right: 1cm; height: 1cm; } @frame footer { -pdf-frame-content: footerOther; bottom: 2cm; margin-left: 1cm; margin-right: 1cm; height: 1cm; } </style> 
 <body> <table repeat="1"> <!-- extra long table here --> </table> <div id="footerContent">This is a footer</div> <!-- what goes here to switch frames after the first page? --> <div id="footerOther"></div> </body> 

This places the same footer on each page. I need the same space remaining on each consecutive page, but without the content in the frame.

+4
source share
1 answer

You can define additional layouts by name, and then tell xhtml2pdf to explicitly switch using the nexttemplate tag. I did this very recently so that there is no title on the first page, but to show it on all subsequent pages.

You should change your @page definition to two different pages, possibly like this:

 <style type="text/css"> @page { margin: 1cm; margin-bottom: 2.5cm; @frame footer { -pdf-frame-content: footerFirst; -pdf-frame-border: 1; bottom: 2cm; margin-left: 1cm; margin-right: 1cm; height: 1cm; } } @page innerpages { margin: 1cm; margin-bottom: 2.5cm; @frame footer { -pdf-frame-content: footerOther; bottom: 2cm; margin-left: 1cm; margin-right: 1cm; height: 1cm; } } </style> 

Then in your html, where you want to switch to another layout, use a tag like this:

 <pdf:nexttemplate name="innerpages"/> 

The next page (and subsequent pages, until you change the template again) will use the innerpages layout with your "other" footer.

+5
source

Source: https://habr.com/ru/post/1392133/


All Articles