Free Support Forum - aspose.com

Aspose Words Mail Merge Issue with changing form size for a mailmerge token

I am in the process of evaluating this product for a large Insurance Company. We need to create Documents that can be filled in with data base data using Word mail merge fields. The mail merge works find but I need the capability to change the Font settings, especially size. The DocumentBuilder method getFont().setSize(6) should change the font size to 6 until it is changed to something else. I put in traces to make sure that the call MailMergFontProcessing was called and executed properly and it is. I am using the evaluation jar for Java 5. According to your documentation the following call back class should do the trick but it does not. The mail merge works propertly but does not adjust the font size or color. I am including the template with the word mail merge fields and the output of the mail merge.

package ams.demo;
import java.awt.Color;

import com.aspose.words.IFieldMergingCallback;
import com.aspose.words.FieldMergingArgs;
import com.aspose.words.ImageFieldMergingArgs;
import com.aspose.words.DocumentBuilder;

final class MailMergeFontProcessing implements IFieldMergingCallback{
///


/// Called for every merge field encountered in the document.
/// We can either return some data to the mail merge engine or do something
/// else with the document. In this case we modify cell formatting.
///

private DocumentBuilder mBuilder = null;;
private String previousFieldName = “”;
public void /IFieldMergingCallback./fieldMerging(FieldMergingArgs args) throws Exception
{
String fieldName = null;
try {
if (mBuilder == null)
{
System.out.println(“Trying to get mBuilder”);
mBuilder = new DocumentBuilder(args.getDocument());
if (mBuilder == null)
{
System.out.println(“mBuilder is null”);
}
else
{
System.out.println(“mBuilder is not null”);
}
}
}
catch (Exception e)
{
System.out.println("Error getting DocumentBuilder: " + e.getMessage());
throw e;
}
fieldName = args.getFieldName();
if (fieldName.equals(previousFieldName))
{
mBuilder.getFont().setSize(6);
mBuilder.getFont().setSizeBi(6);
mBuilder.getFont().setColor(Color.RED);
System.out.println("Red Font Size now set to: " + mBuilder.getFont().getSize());
System.out.println(“Second Callback previousName: " + previousFieldName + " name” + fieldName);
}
else
{
previousFieldName = fieldName;
System.out.println("fieldName is : " + fieldName);

System.out.println("mBuilder returned Font with Font Size: " + mBuilder.getFont().getSize());
if (fieldName.equals(“InsuringCompany”))
{
mBuilder.getFont().setSize(6);
mBuilder.getFont().setSizeBi(6);
mBuilder.getFont().setColor(Color.RED);
System.out.println("Red Font Size now set to: " + mBuilder.getFont().getSize());
}
else
{
mBuilder.getFont().setSize(12);
mBuilder.getFont().setSizeBi(12);
mBuilder.getFont().setColor(Color.BLACK);
System.out.println("Black Font Size now set to: " + mBuilder.getFont().getSize());
}

}
}

public void /IFieldMergingCallback./imageFieldMerging(ImageFieldMergingArgs args) throws Exception
{
// Do nothing.
}
}

Hi there,

Thanks for your inquiry.

I have replied to you in your other thread here: <A href="</A></FONT></P> <P><FONT face=Arial>Thanks,</FONT></P>