Hi,
You can not use the same code you use in your main code. Again this is because header/footer are
not rendered inside the same document as the main document. As such while your main doucment has document.location, your header/footer does not have that. This means any code relying on that won't work. So you will need to rewrite that part of the code.
The other factor you must consider is anything you put in your header/footers are
repeated during rendering. So for example, if your header HTML is as the following and your document is 3 pages long:
Code: HTML/ASPX
<p id="header">header</p>
Then during the rendering the process, the browser engine will render the following HTML:
Code: HTML/ASPX
<p id="header">header</p>
<p id="header">header</p>
<p id="header">header</p>
As you see the header HTML is repeated 3 times because the document has 3 pages. Obviously you would run into problems if you have JavaScript code that relies on id "header" since now you have three of them.
Because of this it is
not a good idea to use JavaScript in header/footer (remember your JavaScript code will be repeated as well, which can cause additional problems for you). If you must dynamically generates header/footer HTML, genearate it in your C# code and then set HtmlToPdf.HeaderHtmls/FooterHtmls directly:
https://www.essentialobjects.com/doc/eo.pdf.htmltopdfoptions.headerhtmlshttps://www.essentialobjects.com/doc/eo.pdf.htmltopdfoptions.footerhtmlsThanks!