We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exporting Hidden Mergefield Stuff as text


i am trying to get a full export of a word document to .txt.
If I press ALT+F9 I see the special MergeFields conditional coding. I’d like to have those (with the remaining document around them) saved to txt

Is there an easy way to achieve that?

Best regards,

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

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();





Best Regards,