Hi Grendel,
Thanks for your inquiry. You may write Mergefield code in your document as following. Hopefully it will help you to accomplish the task. However, if there is any difference in your requirements and our understanding, then please share your sample input and expected output Word documents here. We will further look into it and will guide you accordingly.
com.aspose.words.Document doc = new
com.aspose.words.Document(“in.docx”);<o:p></o:p>
DocumentBuilder builder = new
DocumentBuilder(doc);
for
(com.aspose.words.Field field: doc.getRange().getFields())
{
if (field.getType() ==
FieldType.FIELD_MERGE_FIELD)
{
builder.moveToField(field, true);
String name = field.getFieldCode();
builder.write(name);
}
}
doc.save("E:/Data/MergeField_text.DOCX");
Best Regards,