How to modify header/footer in Aspose.Words for Java

I’ve downloaded a trial version of your Java Aspose.words library for possible purchase if it meets our requirements.

Basically, I need this library to add/update Header/Footer information in .doc files. So far, it seems to handle the basic tasks but I would like to add an image to the Footer as well as page numbers (to the Footer) for each page. For example, Page x of Y (e.g. Page 2 of 100). Is this possible?

We don’t have a lot of code examples yet, so you need to look at code examples for C# and essentially do the same in Java.

Here is the home page of the API Reference https://reference.aspose.com/words/net

To quickly insert something into a header/footer you can use DocumentBuilder.MoveToHeaderFooter and then other DocumentBuilder methods as shown in this example https://reference.aspose.com/words/net/aspose.words/documentbuilder/methods/movetoheaderfooter

To insert a field such as “page number x of y” you can use DocumentBuilder.InsertField https://reference.aspose.com/words/net/aspose.words.documentbuilder/insertfield/methods/1. You can insert a field in MS Word first, see what the field code looks like and then insert same using DocumentBuilder.InsertField. Please note however, that the result of the field (the actual page number or count of pages) will not be calculated by Aspose.Words. Aspose.Words cannot evaluate expressions inside MS Word document fields. You will need to open the document in MS Word, select all and press F9 for the fields to update and show actual page numbers.

We will translate all code examples into Java soon.