Hi,
I am converting our templates to use the "mustache" syntax.
I encountered a problem with the MoveToMergeField method.
Reading the following post we conclude that this method poses a problem if use in combination with mustaches.
"I have received response from our development team and like to share with you that "Moustache" fields have a limited support at the moment"
https://forum.aspose.com/t/60565
The GetFieldNames seems fixed in a later update of Word. But MoveToMergeField is still ignored
Can you confirm this please?
Is there a fix coming or do we need to emply a workaround?
Below is our code. It replace the string true/false with checkboxes
Regards, Tom
public class HandleMergeField : IFieldMergingCallback
{
private DocumentBuilder _mBuilder;
///
/// This handler is called for every mail merge field found in the document,
/// for every record found in the data source.
///
void IFieldMergingCallback.FieldMerging(FieldMergingArgs e)
{
if (_mBuilder == null)
_mBuilder = new DocumentBuilder(e.Document);
// We decided that we want all boolean values to be output as check box form fields.
if (e.FieldValue is String)
{
if ((string) e.FieldValue == "false" || (string) e.FieldValue == "true")
{
// Move the "cursor" to the current merge field.
_mBuilder.MoveToMergeField(e.FieldName);
// It is nice to give names to check boxes. Lets generate a name such as MyField21 or so.
string checkBoxName = string.Format("{0}{1}", e.FieldName, e.RecordIndex);
_mBuilder.InsertCheckBox(checkBoxName, (string) e.FieldValue != "false", 10);
return;
}
}