We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Mail Merge Image as Behind Text

how can I insert image as behind text using mail Merge
below my code

doc.MailMerge.Execute(new string[] { “SIG” }, new object[] { unitUser.Sig });
doc.Save(dstStream, SaveFormat.Docx);

@AhmedZo

You can implement IFieldMergingCallback interface and use ImageFieldMergingArgs.Shape property as shown below to achieve your requirement. Hope this helps you.

private class ImageBehindText : IFieldMergingCallback
{
    void IFieldMergingCallback.FieldMerging(FieldMergingArgs args)
    {
    }

    void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs args)
    {
        Shape shape = new Shape((Document)args.Document, ShapeType.Image);
        shape.WrapType = WrapType.None;
        shape.BehindText = true;
        shape.ImageData.SetImage(args.FieldValue.ToString());
        args.Shape = shape;
    }
}
Document doc = new Document(MyDir + "input.docx");
doc.MailMerge.FieldMergingCallback = new ImageBehindText();
doc.MailMerge.Execute(new string[] { "image" }, new object[] { MyDir + "image.png" });
doc.Save(MyDir + "21.10.docx");