Hi,
in our application we have implemented mail merge such that, if the merge field name starts with “html_”, the merge is done using html format in this way:
public void fieldMerging(FieldMergingArgs fma) throws Exception {
// Se il nome del campo inizia con "html_" assumo sia formattato HTML
if (
fma.getDocumentFieldName().startsWith("html_")
&& fma.getFieldValue() != null
&& Strings.isValid(fma.getFieldValue().toString().trim())
) {
// effettuo inserimento tramite un DocumentBuilder
com.aspose.words.DocumentBuilder builder = new com.aspose.words.DocumentBuilder(fma.getDocument());
builder.moveToMergeField(fma.getDocumentFieldName());
builder.insertHtml(fma.getFieldValue().toString(), true);
// e annullo il testo effettivamente già inserito
fma.setText("");
return;
}
}
However, if the field contains any \b
or \f
switches, to insert text before or after the field when not empty, those are lost.
Is there a way to do the html merge while applying also \b
and/or \f
switches, with their own format if set?