I'm building a webapp with CakePHP (not really germane, but anyway) whose mission is, among other things, to produce a single web page containing a bunch of content that's stored in the database (a collection of articles). I need to be able to print this document and include a simple header and footer for each page when the document is printed.
Additionally, I have no way of guaranteeing that the rendered length of a single item in the collection of articles will be less than that of a piece of paper, so I won't be able to bookend each article like so:
<?php echo $header; ?>
<?php echo $article; // etc. ?>
<?php echo $footer; ?>
The plus side here is that I'm going to be the only person printing this (and saving it as a PDF, actually), so any proposed solution won't be required to work with any arcane browsers that still happen to be around (IE6, etc.).
(Before you mark this question as a duplicate of this similar question, note that I'm not trying to work with IE6 and the individual bits of content I'm printing may well exceed a single printed page in length. As such, the table-based solution to that problem is not applicable here -- at least, as far as I can tell.)
If this is going to require me to do some funky arithmetic to break up a large contiguous block of content into approximately-sized "pages" (which would be delimited by the footer+pagebreak+header combination, obviously), I'm fine with that provided there isn't a more sane way to go about it.
Thank you in advance - please comment if you feel I could provide more information or otherwise make this situation easier to resolve.