When a mail template (.doc/.docx) is opened and saved to disk using the html option with Aspose, is there a way to maintain the merge fields if that html file was convered back to a document. (or is that info lost - just text etc is saved) Say we wanted to allow a user to edit the template as html first in a browser (without word), so we convert doc to html, allow edit, then save html back to doc and do the mail merge. Just wondering if this is possible.
Can we use aspose to create a mail merge template using DocumentBuilder? (insert mail merge fields etc)
Thanks for your request. You can use the same technique as described here:
But with the new versions of Aspose.Words you will have to modify code a little. You should use IReplacingCallback instead of ReplaceEvaluator:
Is there any chance to get an up to date version of this for java to test, it seems to be very old so I’m assuming a lot has changed.
Thanks for your request. You can download the latest version of Aspose.Words for Java from here:
If you want to test Aspose products without the evaluation version limitations, you can request a 30-day Temporary License. Please refer to
I’m using the latest jar file and have a 30 day trial, what I want is an up to date java code to implement this technique?
Thanks for your inquiry. I think in this case you should just change your code to use IReplacingCallback instead of ReplaceEvaluator. Please see the following link for more information:
Please let me know in case of any issues. I will be glad to help you.
How do I get this value now (from previous old sample)?
string fieldName = e.Match.Groups["FieldName"].Value;
Do I use
String fieldName = e.getMatch()?
Also I get a pattern exception on this
doc.getRange().replace(Pattern.compile("«(?.*?)»"), new KeepMergefields(), false);
Can you help. I need to implement the technique in Java, I need something quick so we can test some files.
Thanks for your request. You should modify your pattern as shown below because in java you cannot use named groups:
doc.getRange().replace(Pattern.compile("«(.*?)»"), new KeepMergefields(), false);
Then you can access group value by index:
String fieldName = e.getMatch().group(1).toString();
Really appreciate that, thanks.