I am trying to retrieve value from merge field using Docx4j in java. Currenty I'm retrieving all the contents of the word document using:
WordprocessingMLPackage newWordMLPackage = WordprocessingMLPackage
.load(new java.io.File("C:/Users/admin/Desktop/test" + i + ".docx"));
MainDocumentPart documentPart = newWordMLPackage.getMainDocumentPart();
System.out.println(documentPart.getContent());
This returns a list of contents from the word document. What I'm currently getting is
MERGEFIELD lastName \* MERGEFORMAT himura
What I want is to get the value 'himura'
from the merge-field 'lastName'. How can I achieve this?
Thanks