Perhaps, lets the first start with static generation and then do the dynamic part.

Child templates are mostly producing HTML and have no impact on the pdf header or footer.
However, you can add to the page some hidden marks through child templates and later produce headers/footer based on these values. This can be achieved using pdf utils extension
This example mentioned in the docs could help