Free Support Forum - aspose.com

A question for mail merge event

public void example()
{
doc.MailMerge.MergeField += new MergeFieldEventHandler(HandleMergeField);
doc.MailMerge.Execute(fieldName,valueName);
}

public void HandleMergeField(object sender,MergeFieldEventArgs e)
{
..................
}


when a MailMerge field is encountered, MergeField will occurs. I wanna modify e.FieldValue's font's size and font's type, then expected font will display in correct position. How I can do it?

Any suggestion will be welcome.

That may be done by using DocumentBuilder in a MergeField event handler:

private void MailMerge_MergeField(object sender, MergeFieldEventArgs e)

{

DocumentBuilder builder = new DocumentBuilder(e.Document);

builder.MoveToMergeField(e.DocumentFieldName);

builder.Font.Size = 12;

builder.Font.Name = "Arial";

builder.Write((string)e.FieldValue);

e.Text = "";

}