Hi,
I have written java class to use word document template to generate word document. Please find the program below, which runs without error but the generated word document is not replacing the fieldname.
Could any one help to rectify the issue?
public static void main(String[] args) throws Exception {
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(
new java.io.File("FAX.docx"));
List<Map<DataFieldName, String>> data = new ArrayList<Map<DataFieldName, String>>();
Map<DataFieldName, String> map = new HashMap<DataFieldName, String>();
map.put( new DataFieldName("GREETINGLINE"), "Daffy duck");
//map.put( new DataFieldName("SubTitle"), "Plutext");
//map.put(new DataFieldName("Kundenstrasse"), "Bourke Street");
data.add(map);
//map = new HashMap<DataFieldName, String>();
//map.put( new DataFieldName("Kundenname"), "Jason");
//map.put(new DataFieldName("Kundenstrasse"), "Collins Street");
// data.add(map);
System.out.println(XmlUtils.marshaltoString(wordMLPackage.getMainDocumentPart().getJaxbElement(), true, true));
WordprocessingMLPackage output = org.docx4j.model.fields.merge.MailMerger.getConsolidatedResultCrude(wordMLPackage, data);
System.out.println(XmlUtils.marshaltoString(output.getMainDocumentPart().getJaxbElement(), true, true));
output.save(new java.io.File("mergefield1-OUT.docx") );
}