1

I'm trying to generate a seperate footer for the last page using paged.js. The total number of pages is dynamic.

I already tried named page method but couldn't succeed because it generated extra empty page at the last although it gave the correct final page footer at the last.

Does anyone can help me on this?

Chanaka NZ
  • 127
  • 1
  • 8

1 Answers1

1

Currently, Paged.js doesn't have a selector for the last page like :last.

From your question, I understand you intend to target the last page that has content. Your named page method doesn't work because named pages rely on a class to call them, and that class has to be added on an element or section which would be on a different page layout. You would have to manually see how much of the text is on the last page and put it in a div with a named page class for this approach to work.

I suspect the only other way to do it for now is to generate the book, manually see how many pages there are and type it in the @page :nth() pseudoclass.

Context: I attempted to set a rule with @page :nth(counter(pages)) but the counter seems to work only inside curly braces. This caused paged.js to fail.

delyodobrev
  • 35
  • 2
  • 6
  • Thanks for the explanation. But unfortunately there is no way to calculate number of pages other than counter(pages) which can't be used in this case. – Chanaka NZ Apr 03 '23 at 02:53
  • What you can try to do is create a js script to do what you want on the last rendered ´.pagedjs_margin-bottom´ using .last() in jquery and make sure to load the script after all other scripts are completed. This makes sure paged.js outputs something you can then treat how you want. I haven't tried it though – delyodobrev Apr 03 '23 at 16:22