Cannot Handle Merge fields in the INCLUDEPICTURE

Hi,

We are trying to create merged document by inserting the image using INCLUDEPICTURE property.

We are not able to get the image in the merged document. Can you please advise on the same.
We are using aspose 15.5 version. below is the sample code which i have tried.

Document doc = new Document(@"C:\CM\TEST1.docx");
using (System.Data.DataTable mergeData = new System.Data.DataTable())
{
    mergeData.Columns.Add("DUM_SIGNATURE");
    mergeData.Rows.Add("Sample");
    doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveContainingFields;
    doc.MailMerge.Execute(mergeData);
    doc.Save(@"C:\CM\Merged.docx");
}

I have attached template,XML and image files for your reference.

Hi there,

Thanks for your inquiry. Please use LoadOptions.PreserveIncludePictureField to get or set whether to preserve the INCLUDEPICTURE field when reading Microsoft Word formats. The default value is false.

By default, the INCLUDEPICTURE field is converted into a shape object. You can override that if you need the field to be preserved, for example, if you wish to update it programmatically. Note however that this approach is not common for Aspose.Words. Use it on your own risk.

One of the possible use cases may be using a MERGEFIELD as a child field to dynamically change the source path of the picture. In this case you need the INCLUDEPICTURE to be preserved in the model.

Please use following code example to achieve your requirements and let us know if you have any more queries.

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

Document doc = new Document(MyDir + "TEST1.docx", options);
using (System.Data.DataTable mergeData = new System.Data.DataTable())
{
    mergeData.Columns.Add("DUM_SIGNATURE");
    mergeData.Rows.Add("Sample");
    doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveContainingFields;
    doc.MailMerge.Execute(mergeData);
    doc.Save(MyDir + "Out.docx");
}