MailMerge with different heading style


I’m creating a word document with mailmerge.
I’ve to apply to a specific field different heading style (h1, h2, h3, ecc) base on parameter. I’ve tried to insert some html tag (<b> for example) but isn’t working.

Someone can help me?**


Hi Alessandro,

Thanks for your inquiry. You can achieve this by implementing IFieldMergingCallback interface. Please see following example:

private class HandleMergeFields : IFieldMergingCallback
    void IFieldMergingCallback.FieldMerging(FieldMergingArgs e)
        if (e.DocumentFieldName.StartsWith("<h1"))
            DocumentBuilder builder = new DocumentBuilder(e.Document);
            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
            e.Text = "";
    void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs e)
        // Do nothing.

I hope, this helps.

Best regards,