We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Mail Merge with multiple picture switches

We have a scenario where we receive some data in upper case. I would like to convert that to Title Case in the mail merge process by using two switches - \* Lower \* Caps

In my tests the first switch seems to be ignored and doing a Caps on upper case doesn't do anything.

Is this possible?

Update: I found a thread regarding using the MergeField event. That could be an option. How can I extract the switches from the MergeFieldEventArgs?

Update2: The node text below contains the switches. are there alternate/better ways to handle this.
Run node = e.Field.Start.NextSibling as Run;
Console.WriteLine(node.Text);

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Actually, you do not need two switches. You need only \* Caps switch in your case. But currently, there is an issue with this switch in Aspose.Words. I linked your request to the appropriate issue. You will be notified as soon as it is resolved.

As a workaround, you can try converting text to lowercase during mail merge. For example see the flowing code:

public void Test001()

{

Document doc = new Document(@"Test001\in.doc");

doc.MailMerge.MergeField += MailMerge_MergeField;

doc.MailMerge.Execute(new string[] {"test"}, new object[] {"THIS IS UPPER CASE TEXT"});

doc.Save(@"Test001\out.doc");

}

void MailMerge_MergeField(object sender, Aspose.Words.Reporting.MergeFieldEventArgs e)

{

e.Text = e.FieldValue.ToString().ToLower();

}

Hope this helps.

Best regards.

"As a workaround, you can try converting text to lowercase during mail merge. For example see the flowing code:"

That's actually what I did, but I need to be able to format it only for a given instance. e.g values are in upper case. In one place of the document I need to make them Title Case, but in another I need to leave it with the original casing.

Just so that I understand you correctly. Will Aspose be able to format "UPPER CASE" to "Upper Case" with the only the "\ * Caps" switch specified? It was my understanding that the \ * Caps switch does not inspect the full string, but only the first character.
If yes, do you have any time frame for this?

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank for your inquiry. You can use the following code to determine if field code contains \* Caps switch:

public void Test001()

{

Document doc = new Document(@"Test001\in.doc");

doc.MailMerge.MergeField += MailMerge_MergeField;

doc.MailMerge.Execute(new string[] {"test"}, new object[] {"THIS IS UPPER CASE TEXT"});

doc.Save(@"Test001\out.doc");

}

void MailMerge_MergeField(object sender, Aspose.Words.Reporting.MergeFieldEventArgs e)

{

// Get field code.

string fieldCode = e.Field.GetFieldCode().ToLower();

// Check if field code conating \* Caps switch. if so convert strign to lower case.

if(fieldCode.Contains(@"\* caps"))

e.Text = e.FieldValue.ToString().ToLower();

}

When MS Word process \* Caps switch, it converts string to lowercase first and then the first letters of each word to upper. Aspose.Words currently, just converts all first letters to uppercase. We will resolve this issue in one of future versions, but currently, I cannot give you any estimate. But I think the suggested workaround will satisfy your needs.

Best regards.

Excellent. Thank you!

The issues you have found earlier (filed as 4126) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(10)