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:
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.