I have a C# application which makes use of Aspose to execute a mail merge and generate a qr code on the resulting document. When I execute the merge and view the resulting document, in the location where the qr code should be I see an error message which states
Error! Bar code generator is not set.
This is the code that I am using to execute the mail merge:
System.Data.DataTable dt = _repoForm.GetProtestCasesTempate(modelList, CertificationDate, SignedBy);
Aspose.Words.License license = new Aspose.Words.License();
license.SetLicense("Aspose.Total.xxxxxx.lic");
Aspose.Pdf.License oPdfLicense = new Aspose.Pdf.License();
oPdfLicense.SetLicense("Aspose.Total.xxxxxx.lic");
Aspose.BarCode.License oBarCodeLicense = new Aspose.BarCode.License();
oBarCodeLicense.SetLicense("Aspose.Total.xxxxxx.lic");
MemoryStream finalOutStream = new MemoryStream();
Aspose.Words.Document retainerDoc;
string PathToTemplate = "";
if (dt.Rows.Count > 0)
{
IEnumerable<letter_templates> TemplatePath = _repo.FetchLetterTemplates("Protest");
foreach (var item in TemplatePath)
{
PathToTemplate = item.full_file_path;
}
Aspose.Words.Document template = new Aspose.Words.Document(PathToTemplate);
MemoryStream outStream = new MemoryStream();
template.FieldOptions.BarcodeGenerator = new CustomBarcodeGenerator();
template.MailMerge.Execute(dt);
template.Save(outStream, Aspose.Words.SaveFormat.Docx);
retainerDoc = new Aspose.Words.Document(outStream);
retainerDoc.Save(finalOutStream, Aspose.Words.SaveFormat.Pdf);
finalOutStream.Seek(0, SeekOrigin.Begin);
}
This is what my word docx file looks like:
And this is what I get when I execute the code:
The section where the 2 merge fields are in the bottom right corner where I want to put the qr code is contained within a text box. Could the size of the text box be restricting the processes ability to generate the qr code?
I can not figure out why I am getting a bar code generator is not set error message.
Any help is greatly appreciated.


Aspose.Words does not render DISPLAYBARCODE fields itself. To render such fields you should specify a custom barcode generator. For example see Aspose.Words documentation: https://reference.aspose.com/words/net/aspose.words.fields/fieldoptions/barcodegenerator/
The code should look like this:
Where
CustomBarcodeGeneratorisIBarcodeGeneratorimplementation. For example here is an implementation using Aspose.Barcode, but you can use any other barcode generator:and Github: https://github.com/aspose-words/Aspose.Words-for-.NET/blob/b0f89864f49794ab15f264e35d41856b667143dd/Examples/ApiExamples/ApiExamples/CustomBarcodeGenerator.cs