page:last formatting last page
Hello, I have the need to change the margins and footer on the last page, just I don't know the total number of pages until the document is rendered.
Is there a selector ?
I managed to create the desired output with some JS, as it's the last page, I can append the footer and position it to the bottom with position:absolute; bottom:0;
and then remove page.js's bottom margins but I'm not sure if it will create any side effects.
class RemoveBottomMarginLastPage extends Paged.Handler
{
constructor( chunker, polisher, caller )
{
super( chunker, polisher, caller );
}
afterRendered( pages )
{
let lastPage = pages[pages.length - 1];
let pageBox = lastPage.pagebox;
pageBox.style.gridTemplateRows = "[header] var(--pagedjs-margin-top) [page] calc(var(--pagedjs-pagebox-height) - var(--pagedjs-margin-top)) [footer] 0";
}
}
Paged.registerHandlers( RemoveBottomMarginLastPage );
Thanks, Antonio