Template replacement field variables that are not provided to have default values


So I am trying to use Aspose Words Reporting Engine with data record from a map to do some field variable replacement in a docx. I will be receiving a map of the field variable names (map key) and replacement values (map value), but the problem is that I may not receive all variable names/values in the map. I am looking for a setting or way for Aspose to automatically fill in all field variables with a default value if not provided in the map. Or a way to get all the field variable names from the document.

Please see my attached zip that has sample code, input file, and successful output file and let me know what is the best way to achieve my desired output.


fieldReplacementTest.zip (26.0 KB)


Thanks for your inquiry. The ReportingEngine.Options property gets or sets a set of flags controlling behavior of this ReportingEngine instance while building a report. Please use this property as shown below to get the desired output.

ReportingEngine reportingEngine = new ReportingEngine();
Document document = new Document(inputStream);

Hi Tahir,

So at this time I am working with Alfresco Activiti that includes a prior version of Aspose Words (15.5.0). This version does not include the options property. Is there another work around in Aspose to achieve the same result? Is there any way to use document.getMailMerge().getFieldNames(); and use that to get the actual variable name visible in the document? Any other possible way of providing default values if some of the variable names are not provided?

Thank you again,


Thanks for your inquiry. Unfortunately, there is no workaround for this case. Please note that LINQ Reporting engine is different from mail merge. Please upgrade to the latest version of Aspose.Words for Java 18.5 to get the desired output.