Hey,
you can do something like this:
- Code: Select all
for (SectionWrapper section : wordMLPackage.getDocumentModel().getSections() {
if (section.getHeaderFooterPolicy() != null) {
section.getHeaderFooterPolicy().getDefaultHeader().variableReplace(yourContent);
section.getHeaderFooterPolicy().getDefaultFooter().variableReplace(yourContent);
}
}
I recommend doing a null check on the default header and footer object, and an isEmpty check on the content of these (!section.getHeaderFooterPolicy().getDefaultHeader().getContent().isEmpty()).