Free Support Forum -

INCLUDEPICTURE does not display the image using .NET | Mail Merge

I’m in the process of implementing a server-side mail merge for our clients using Aspose. So far I’ve been very pleased with its near-parity with MS Word, especially compared to other similar products.

However, I’ve run into a small issue regarding INCLUDEPICTURE fields: When Aspose does the merge, it formats those fields and adds a “* MERGEFORMATINET” field format to the end even though it doesn’t exist on the original field.

This is a small problem for us because that format flag seems to cause Word to stretch the image to the bounding box instead of leaving it with its original height/width ratio. (I guess MERGEFORMATINET is not the default for MS Word if no format is specified.)

For example, this:

{ INCLUDEPICTURE "{IF TRUE "A:\\{ MERGEFIELD FolderName }\\{ MERGEFIELD Filename }.jpg" }"\d }

becomes this after merge:


I can see that the field is essentially re-written because the “\d” has also moved to the front, though that doesn’t really matter.

Is there any way to prevent this addition of the “MERGEFORMATINET” format flag when an INCLUDEPICTURE field is processed?



To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.


We have tested the scenario using the latest version of Aspose.Words for .NET 21.2 and have not found the shared issue. So, please use Aspose.Words for .NET 21.2.

We have used following code example to test your case. Please check the attached input Word document. (13.9 KB)

Aspose.Words.LoadOptions loadOptions = new Aspose.Words.LoadOptions();
loadOptions.PreserveIncludePictureField = true;
Document doc = new Document(MyDir + "input.docx", loadOptions);
string[] names = { "imagepath"  };
object[] paths = { @"C:\\temp\\image.jpg" };

doc.MailMerge.Execute(names, paths);

doc.Save(MyDir + "21.2.docx");


When you say you haven’t found the issue, I assume you are referring to the stretching of the image, not the addition of the “\* MERGEFORMATINET” which is clearly happening.

After some additional research, it seems to only be happening when referring to an image on one of my mapped network drives (it may also happen when pointing to an image URL, I don’t know).

I’ve attached an example solution per your instructions. Included there are the input doc and image with which I tested by placing the image on my P:\ drive, which for me is a mapped network drive.

In this example, the MERGEFORMATINET format flag causes the image to stretch, whereas removing that flag will make it look normal. (54.2 KB)


We have tested the scenario using the latest version of Aspose.Words for .NET 21.2.0 and have not found the shared issue. So, please use Aspose.Words for .NET 21.2.0.

@tahir.manzoor Did you take a look at the example project I attached? It’s using the latest version and the flag is being added.


We tested the scenario using the same application. Please make sure that the path of picture is correct and accessible to your application.

@tahir.manzoor I’ve made a video reproducing the issue if you would please take a look. This is using the sample project I attached earlier. If you can’t access the link, please let me know.!AhXkD17Jmwy-mS32xce3opg0K-Fj


Please check the attached output DOCX generated by using your application. Output (16.1 KB)

We have followed below steps to generate the document.

  1. Open the input Word document and change P to D drive. We do not have Drive with P name. So we put the image at D drive. step 1.png (21.8 KB)

  2. Execute application to generate the document. See the path of image. Step 2.png (19.1 KB)

  3. Press Alt + F9 to view the image. Step 3.jpg (108.5 KB)

This issue seems not related to MERGEFORMATINET.


After further investigation, we have reproduce this issue using following steps. We have logged this issue as WORDSNET-21865 and you will be notified via this forum thread once this issue is resolved.

  1. Put the image at D drive.
  2. Execute the application.
  3. In the input document. the image path is P:\<<mail merge field>>.
  4. Output document has image path as P:\sample-image.jpg.
  5. Change P to D (d:\sample-image.jpg) and update the field.
  6. Press Alt + F9 to view the image.
  7. The image is stretched.

Please put the image at local disk instead of network, test this case, and share your feedback.

@tahir.manzoor Yes, the image doesn’t stretch if it’s a local path, as I mentioned in an earlier post. I cannot alter this use case, however, as the template documents to be merged are created by our clients. The real issue, though, seems to be with the automatic adding of the MERGEFORMATINET flag, which Aspose is doing.

I appreciate you opening the issue and look forward to its resolution.


Thanks for sharing the detail. We will inform you via this forum thread once there is an update available on this issue.