How to push a section of text down the final page when generating a PDF

I need to add a Terms & Conditions clause to a Quotes PDF. However, I want this clause to be pushed down to be contiguous with the footer on the last page of the quote. This should be dynamic, and depends on the number of preceding line items, as to whether a page break is required or not, to avoid the Ts & Cs overlapping with either the line items or the footer.

I’ve tried various approaches to pushing the final div (the Ts & Cs) in the template body down the page to sit just above the template footer. but none of them avoid overlapping with other content such as line items or the footer.

I hope someone has encountered this before and knows how to do it. Otherwise I’d have to share my various coding attempts here in the hope of finding a collaborative solution to at least one of them.

I would try something like this:

Note that the approach is a bit different. You use a normal footer for every page, and then a different footer for the last page. This should ensure (though I’ve never tried it) that it appears near the bottom (it’s part of the bottom, so…), and that there is space for it (if there isn’t, it will cause a page break and an extra page - I expect).