I've looked at your document.
The behaviour is as described by Cindy:
When you switch views, or a document is updated, fields in the document header/footer will be updated automatically; this is not the case for all fields in the document body. Since the text you assigned to the merge fields was not coming from a linked data source, when the fields in the header/footer updated at printing, they reset. The fields in the document body did not update, so the text was retained.
See
https://social.msdn.microsoft.com/Forum ... um=oxmlsdkA workaround is to remove the MERGEFIELDs in the header and footer.
docx4j's MailMerger contains:
Using java Syntax Highlighting
protected static OutputField fieldFate
= OutputField.
REMOVED;
/**
* What to do with the MERGEFIELD in the output docx.
*
* Default is REMOVED.
*
* KEEP_MERGEFIELD will allow you to perform
* another merge on the output document.
*
* The AS_FORMTEXT options convert the MERGEFIELD to a FORMTEXT field.
* This is convenient if you want users to
* be able to edit the field, where editing is restricted
* to forms.
*
* @param fieldFate
*/
public static void setMERGEFIELDInOutput
(OutputField fieldFate
) {
MailMerger.
fieldFate = fieldFate
;
}
public enum OutputField
{
DEFAULT,
REMOVED,
KEEP_MERGEFIELD,
AS_FORMTEXT_REGULAR
;
// AS_FORMTEXT_TYPED,
// AS_FORMTEXT_TYPED_FORMATTED;
}
Parsed in 0.015 seconds, using
GeSHi 1.0.8.4
So you want setMERGEFIELDInOutput(OutputField.REMOVED), which is the default. Are you setting it to something different?