Combination of english and arabic string not merging in word document

We are using Aspose.Words Version=19.12.0.0 for merging data in Word and PDF. I’m updating document field format for ‘NumericFormat’ field with combination of English and Arabic Number formats Like “ArabicSymbol#,##0.00;(ArabicSymbol#,##0.00)”, Once document Merged, Number format has been changes. I mean number format alignment changed in merged word document.

From our side we tried below solution but it’s not working for us. Also we tried others solutions as well as. Maybe we are doing wrong or not sure. So, Can you please guide me if I’m going to wrong way or missed anything?

https://forum.aspose.com/t/problem-with-rtl-ltr-mixed-report/53489

Here is code which I implemented.

Document document = new Document("C:\\Data\\test.docx");
var fields1 = document.Range.Fields;
foreach (Aspose.Words.Fields.Field field in fields1)
{
    if (field.Type == Aspose.Words.Fields.FieldType.FieldMergeField)
    {
        if (field.Format.NumericFormat != null)
        {
            string FormatString = "$#,##0.00;($#,##0.00)";

            FormatString = FormatString.Replace("$", ((Char)0x200F).ToString() + "د.ك" + ((Char)0x200E).ToString());

            document.Styles[StyleIdentifier.Toc1].Font.NameBi = "Andalus";
            document.Styles[StyleIdentifier.Toc1].Font.SizeBi = 40;
            document.Styles[StyleIdentifier.Toc1].Font.Bidi = true;

            field.Format.NumericFormat = FormatString;
            field.Update();
        }
    }
}
document.Save("C:\\Data\\Test-Output.docx");
//Set merge cleanup options
document.MailMerge.CleanupOptions = Aspose.Words.MailMerging.MailMergeCleanupOptions.RemoveContainingFields |
    Aspose.Words.MailMerging.MailMergeCleanupOptions.RemoveEmptyParagraphs |
    Aspose.Words.MailMerging.MailMergeCleanupOptions.RemoveUnusedFields |
    Aspose.Words.MailMerging.MailMergeCleanupOptions.RemoveUnusedRegions;

document.MailMerge.Execute(new string[] { "Date", "DateTime", "Time12Hour", "Time24Hour", "Revenue", "HidePriceOn", "UnitPrice" },
                            new object[] { "2018-09-25", "2018-09-25 23:30", "7:00 PM", "19:00", 11.34, "True", 12.234 });

document.Save("C:\\Data\\Test-Merge.docx");

Here is output image file:

Here is Word Document which I am trying to merge data.
test.docx (13.3 KB)

@variyasandip It looks like the problem is not reproducible with the latest 24.8 version of Aspose.Words:
Test-Merge.docx (10.3 KB)
Test-Output.docx (10.9 KB)

Also, it is not quite clear the reason why you are modifying Toc1 style in the loop. There is no TOC in your test document al all, so this code is not required.

@alexey.noskov Thank you for quick checking my code and back to replay.
I’m little confused, Is possible to fixed that issue with Aspose.Words Version=19.12.0.0 or I need to Aspose.Words Version?

@variyasandip Unfortunately, I do not see a way to fix the problem with 19.12. So I would suggest you to update to the latest 24.8 version of Aspose.Words.

@variyasandip I further investigated the issue. Please try wrapping Arabic text into the quotation marks:

FormatString = FormatString.Replace("$", "\"" + ((Char)0x200F).ToString() + "د.ك" + ((Char)0x200E).ToString() + "\"");

I tried with above code; Symbol position has changed.

If there is any solution with 19.12 version, then it would be beneficial for us else we will try to upgrade.

If you have any references to this issue, please suggest or share with me so I can try to resolve it with version 19.12.

@variyasandip With the above chnages and the latest 24.8 version the result is the following:


So I would suggest you to update.

@alexey.noskov with below code our issue is fixed with Aspose.Words Version 19.12 but In Merged Document Arabic Symbol wrapping behaviour unexpacted. also if we are adding addition numbers in that string Arabic currency symbol postion will be changed.

So, Is there any patch/solution for this issue with Aspose.Words version 19.12?

This behaviour we seen. See below attached image for your ready reference.

Here is merged word document output file, If you are adding addition number in word docu then Arabic symbol position will be changed. This behavior also we seen.

OutputDoc.docx (24.7 KB)
Is there any solution for this behavior? If yes,It would be fine for us.

@variyasandip

I am afraid, we do not provide any fixes or patches for old versions of Aspose.Words. All fixes and improvements are delivered with new versions of Aspose.Words.

I am afraid this is out of Aspose.Words control. It looks like MS Word peculiarity.