In the above sample, a header, footer and watermark are added to every exported page through the template option. Important to note is that the custom elements should be positioned and styled with CSS in order to appear at the start/end/center of the document (similar to the demo).
Additional information on customizing the PDF output is also available in the documentation: