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

Free Support Forum - aspose.com

Merge field setting "Title case" doesn't behave like it does in Word

Hello,

I posted this as a response to another message, but wanted to raise it as a new thread.
First Capital Merge Field

My question has to do with the various merge field settings (that appear under “Format:” on the Insert Field dialog box, under the Merge Field name). Specifically, I’m refering to “Title Case”, which doesn’t seem to work like it does in Word, which is a bit of a problem. (The other choices, “Uppercase”, “Lowercase” and “First capital” all work fine in Aspose.Words for me).

Anyway, in Word, with “Title Case” chosen, it converts the merged data to lowercase, then uppercases the first letter of each word. It looks like with Aspose.Words that the first letter of each word is indeed uppercased, but it doesn’t first convert the whole string to lowercase. This is obviously a problem if the data being merged is all uppercase.

I’m hoping that in a future release, you would be so kind as to consider adding this to the feature set.

Thanks guys,

Mike

Hi

Thanks for your reporting this problem to us. I managed to reproduce the problem. I have logged this problem to our defect database as issue # 4126. Please expect a reply before the next hotfix (within 2-3 weeks). We might just fix it by then or provide more information

Best regards.

Many thanks, Alexey. You all provide the best support I’ve ever seen and I greatly appreciate it.

Mike

Hi Alexey,

Just wondering if this has been addressed… I’m getting more pressure about this and wondered if you had an update.

Mike

Hi

Unfortunately this issue is unresolved yet. We will notify you as soon as it is done. Thank you for your patience.

Best regards.

Thanks for the update.

Hi Alexey,

Do you have a suggestion as to how I might use a MergeFieldEventHandler to temporarily solve this problem? It would be great if I could somehow determine that a merge field had a “Title Case” flag, and then do the data conversion to lowercase and then intial caps myself.

Unfortunately, I don’t see a way to determine whether a field has the “Title Case” property set.

Mike

Hi, Mike

Here is code of mergefield.

{ MERGEFIELD test1 \* Caps \* MERGEFORMAT }

I think that you can try using the following code as workaround.

public void TestTitlaCase_105026()

{

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

string[] names = { "test1" };

string[] values = { "TEST test1" };

doc.MailMerge.MergeField += new MergeFieldEventHandler(MailMerge_MergeField_105026);

doc.MailMerge.Execute(names, values);

doc.Save(@"274_105026_DenverMike\out.doc");

}

void MailMerge_MergeField_105026(object sender, MergeFieldEventArgs e)

{

string fieldCode = e.Field.GetFieldCode();

if (fieldCode.Contains("Caps"))

{

CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;

System.Globalization.TextInfo textInfo = cultureInfo.TextInfo;

string value = e.FieldValue.ToString().ToLower();

e.Text = textInfo.ToTitleCase(value);

}

}

Best regards.

Wow, thank you, Alexey! You really saved my bacon!

I hadn’t noticed GetFieldCode() before… that made all the difference in the world.

Mike

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.
(13)