-1

I have a word document with .docx extension. I want add header with some information and footer with page number in each page. I don not know how add header and footer on word document.

I am using Docx4j open source edition with Java.

anika
  • 63
  • 1
  • 6

1 Answers1

0

Start by looking at samples/HeaderFooterCreate.java

Basically you create the header and footer parts, and add them as rels of the MainDocumentPart. Then you reference these rels appropriately from the sectPr element.

For the actual content of your header/footer parts, I'd suggest you create a docx containing what you want in Word, then use the docx4j webapp or Helper AddIn to generate corresponding code.

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84