I have a requirement to update the header on first page of a .docx file.
This can be achieved using:
SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
headerReference = objectFactory.createHeaderReference();
headerReference.setId(relationship.getId());
headerReference.setType(HdrFtrRef.FIRST);
sectPr.getEGHdrFtrReferences().add(headerReference);
But the above doesn't work unless Title page is set to true.
BooleanDefaultTrue boolanDefaultTrue = new BooleanDefaultTrue();
sectPr.setTitlePg(boolanDefaultTrue);
When the above is done, footer on first page of document is replaced by some junk (perhaps default) footer.
If I set headerReference.setType(HdrFtrRef.DEFAULT), the footer is not replaced but this leads to header on all pages.
Could someone please help me with a solution to update only first page header without disturbing the footer in a word doc with multiple pages.
Thanks.