I'm writing a utility which dynamically generates an HTML page in a certain document structure. The body consists of a number of div
's stacked on top of each other, each holding certain content (as a sort of list). Each of these content div
's may be a variable height, especially depending on how wide the printer page is.
Here's a sample of the produced HTML:
<html>
<head>
<title>Page Title</title>
<style>
(Dynamically generated styles)
</style>
</head>
<body>
<div id="divMain">
<div id="divHeader">
<div id="divTitle">Page Title</div>
<div id="divSubTitle">Subtitle</div>
</div>
<div id="divContent">
(Dynamically generated content div's)
</div>
</div>
</body>
</html>
This page is only plain HTML with CSS, and needs to work when a user double-clicks on this HTML file on their own computer, not hosted from a site. Therefore, there is no script in this page.
Now, once I have produced this HTML, my intention is to print it (or save as PDF). When it's printed, each printed page needs to have a custom header and footer inserted. As mentioned above, each content div
could be any variable height, and could change if the printing width changes.
How do I insert my own header/footer into each printed page?