Hello,
You can add page numbers using addPageNumber. Please note that addHeader and addFooter methods add headers and footers in all sections of the DOCX. If you need to add headers and footers per section you can use addHeaderSection and addFooterSection methods.
Using template placeholders, you can replace existing placeholders with a WordFragment that includes page number content with replaceVariableByWordFragment. Or use insertWordFragment to add new contents in existing headers and footers without using template placeholders.
Page numbers can be added in the DOCX to be merged and in the merged DOCX output.
Regards.