Pictures not appearing after MailMerge in Word Doc

I am currently tasked with generating letters of communication for different customers, and the mail merge process for text works just fine. However, I need to include Barcodes in the margins of each page so that the printer system can identify what is being generated. I have managed to generate the barcodes (ECC-200 Datamatrix type) using another package which leaves me with a .png file.
The issue arises when I try to insert that .png into the document via Merge Fields. I have added the “Picture:” prefix to the field like so:
Gembox1

I tried both using the Picture Prefix and the INCLUDEPICTURE with an embedded Merge Field, but to no avail. I am aware that the Picture Prefix was only introduced in Gembox.Document 2.9 so I upgraded my version from 2.5 to 2.9 using the Free version to test, but the issue still persists.
The path that I pass to the Merge Field looks like so: “D:\Git\Database\STSM Central Print\STSM Central Print\Barcodes\testBarcode.png”.
I also tried to format it without escape characters like this: @“D:\Git\Database\STSM Central Print\STSM Central Print\Barcodes\testBarcode.png”

When it comes to executing the Mail Merge inside the C# Code I have also tried multiple approaches:
doc.MailMerge.Execute(new { barcodeField1 = barcodePath });
In the above example I tried to execute it where I set the value of the field equal to the path to the image.

public string barcodeField1 { get { return “D:\Git\Database\STSM Central Print\STSM Central Print\Barcodes\testBarcode.png”; } }

doc.MailMerge.Execute(comms);
In the above example I tried to set the value inside a class, then in a different part of the program I call the execute on an instantiation of that class in the hope that the field gets a picture inserted while all the other fields get (sucessfully) inserted, but again it doesn’t work.

I toyed around with using RangeStart and RangeEnd to specify the field but I would get a “Top Level Mail Merge cannot be found” type exception.

I am at my wits end trying to get this to work so any help would be appreciated, I will respond with further details where necessary.

Hi Kevin,

This field:

{ MERGEFIELD Picture:barcodeField1 \* MERGEFORMAT }

Should have been successfully merged with this data source:

doc.MailMerge.Execute(new { barcodeField1 = barcodePath });

Here is a sample project that demonstrates this:
https://www.gemboxsoftware.com/temp/MergePicture.zip
Try running that project, does it work for you?

Anyway, to investigate the issue that you have, please create a small Visual Studio project that reproduces the problem and we’ll take a look at it.

Regards,
Mario

Hi Mario,

First of all thank you very much for the response. I was able to get the issue sorted finally. I copy pasted the MergeField you provided and added it to my own word document opting to keep the source formatting. I’m not sure if there was any difference but at least I was sure the prefix had been added correctly.

The big thing that made a difference was when I set the .png files Copy to Output Directory property from 'Do not copy" to ‘Copy if newer’. After this the .png was successfully merging into the document!
Its always some tiny detail that trips you up.

Thanks again for the support,
Kevin