Page 1 of 1

Adding headers/footers to a document

PostPosted: Thu Jul 23, 2009 9:57 pm
by eford
I'm trying to puzzle through how to add a header/footer to a document. Thus far I've figured out the complicated stuff but I'm stuck with something that should be simple: where do I get the rId that I need for the HeaderReference? So far, it looks like my only option is to add the HeaderPart to the MainDocumentPart then getOwningRelationshipPart().getRelationships().getRelationship() and iterate through the list checking for a target whose partName matches my HeaderPart and then getId from that Relationship. This seems more difficult that it should be. I'm sure there's something simpler that I've overlooked. Any hints?

Re: Adding headers/footers to a document

PostPosted: Fri Jul 24, 2009 2:45 pm
by eford
I was right - I overlooked something simple. addTargetPart returns the Relationship so I can get the rId at that point. A night away from the code can bring fresh enlightenment.