Page numbers in Document Templates
Is there a page number variable that you can you when producing documents using a document template.
Yes, that's possible. You can see the explanation here.
Code works in both body and footers (and I assume also headers) btw.