Thanks Jason. I actually was trying to adapt the HeaderFooterCreate example, but the thing that isn't clear is how I create both footers.
It looks like you only get one HeaderPart, and one Hdr per part. I don't see how to add a Hdr without another HeaderPart.
So here's some code borrowed from the sample (which of course works) to add the first header
- Code: Select all
HeaderPart header1 = new HeaderPart();
header1.setJaxbElement(getHdr());
Relationship rel1 = wordprocessingMLPackage.getMainDocumentPart().addTargetPart(header1);
HeaderReference headerReference1 = objectFactory.createHeaderReference();
headerReference1.setId(rel1.getId());
headerReference1.setType(HdrFtrRef.DEFAULT);
//add header or footer references
sectPr.getEGHdrFtrReferences().add(headerReference1);
I cannot follow that with this
- Code: Select all
HeaderPart header2= new HeaderPart();
header2.setJaxbElement(objectFactory.createHdr());
Relationship rel2 = wordprocessingMLPackage.getMainDocumentPart().addTargetPart(header2);
HeaderReference headerReference2 = objectFactory.createHeaderReference();
headerReference2.setId(rel2.getId());
headerReference2.setType(HdrFtrRef.FIRST);
//add header or footer references
sectPr.getEGHdrFtrReferences().add(headerReference2);