Hi
We need some feedback on what is normally done to introduce barcode fonts into Word such that they are displayed when associating a font with a MailMerge field. If this can be done, will the aspose MailMerge operation be able to automatically encode the MailMerge data value as that bar code? I’m hoping we shouldn’t have to programmatically build the barcode image and insert it into the aspose document.
Thanks –
bob kells
Hi Bob,
Thanks for your inquiry. I think, in this case,you just need to specify the font name as follows:
Document doc = new Document(@"C:\Temp\input.docx");
doc.MailMerge.FieldMergingCallback = new HandleBarCodeMergeFields();
doc.MailMerge.Execute(new string[] { "barCodeField" }, new object[] { "test data" });
doc.Save(@"C:\Temp\out.docx");
private class HandleBarCodeMergeFields : IFieldMergingCallback
{
void IFieldMergingCallback.FieldMerging(FieldMergingArgs args)
{
if (args.FieldName.Equals("barCodeField"))
{
DocumentBuilder builder = new DocumentBuilder(args.Document);
builder.MoveToMergeField("barCodeField");
builder.Font.Name = "Your bar code font name";
builder.Write(args.FieldValue.ToString());
}
}
void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs e)
{
// Do nothing.
}
}
PS: Sample input/output documents are attached.
Best regards,