Hello,
Hi Hiren,
Thanks for your inquiry. You can achieve your requirements by using one of following approaches.
1) Open your template document in MS Word and format the fields (set font style) according to your requirements and then use Aspose.Words to perform mail merge operation. You can also apply formatting to text using Aspose.Words. Please read following documentation link for your kind reference.
http://www.aspose.com/docs/display/wordsjava/Specifying+Formatting
2) Implement IFieldMergingCallback interface and set font style in IFieldMergingCallback.fieldMerging. Please check code example in following documentation link.
http://www.aspose.com/docs/display/wordsjava/How+to++Apply+Custom+Formatting+during+Mail+Merge
Hope this helps you. If you still face problem, please share following detail for investigation purposes.
- Please attach your input Word document.
- Please
create a standalone/runnable simple Java application that demonstrates the code (Aspose.Words code) you used to generate
your output document - Please attach the output Word file that shows the undesired behavior.
- Please
attach your target Word document showing the desired behavior. You can
use Microsoft Word to create your target Word document. I will
investigate as to how you are expecting your final document be generated
like.
us we’ll start our investigation into your issue.
Thanks for your response.
Hi Hiren,
Thanks for your inquiry. Please move the cursor to the mail merge field and write the mail merge field’s value as shown below.
public void fieldMerging(FieldMergingArgs e) throws Exception {
if (mBuilder == null){
mBuilder = new DocumentBuilder(e.getDocument());
}
if (e.getFieldName().equals(“investingnickname”) || e.getFieldName().equals(“investingbalance”) || e.getFieldName().equals(“Assets”)) {
mBuilder.getFont().setColor(Color.RED);
mBuilder.moveToMergeField(e.getFieldName(), false, false);
mBuilder.write(e.getFieldValue().toString());
}
}
If you still face problem, please share the detail requested in my previous post for investigation purposes. I will investigate the issue on my side and provide you more information.
Thanks a lot for your consistent help.
Hi Hiren,
Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.