Programmatic rendering of Header and footer content

Hi,

I am looking at integrating Collabora Online with a custom web application - so we have a requirement where the document header content needs to be rendered dynamically based on some values related to user context on our web app and document type too. Even logo can change case by case.

Anyone can help me with some pointers as to how this can be achieved -

Possibility of injecting a dynamically generated custom header and footer before print or save as is issued?