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

Free Support Forum - aspose.com

Merge images using INCLUDEPICTURE fields

Hi again,

I wanted to ask this: can I use Aspose.Words to perform mailmerge of images using native “INCLUDEPICTURE” fields instead of Aspose “Image:” fields?

Ideally I’d use something like {INCLUDEPICTURE "{MERGEFIELD pathToImg}"}, would it work? If so what are the main differences from Aspose custom image mail merge fields?


Thanks for your inquiry. Yes, Aspose.Words does support the requested feature. We suggest you please set the value of LoadOptions.PreserveIncludePictureField property to true. This property is used to preserve the INCLUDEPICTURE field when reading Microsoft Word formats. Please check the following code snippet.

LoadOptions options = new LoadOptions();
options.PreserveIncludePictureField = true;

Document doc = new Document(MyDir + "in.docx", options);
doc.MailMerge.Execute(new string[] { "imagePath" }, new string[] { @"c:\\temp\\image.png" });
doc.Save(MyDir + "Out.docx");

Thanks for the info!

Is there an advantage in using “your” Image:xxx merge fields instead of “native” INCLUDEPICTURE?

What are the main differences?


Thanks for your inquiry. If you want to add images in the document using mail merge, please use Image:MyFieldName field name. The INCLUDEPICTURE field is used to insert picture in the document. Please check the members of ImageFieldMergingArgs class.