Reading Arabic text is wrong in Aspose.Word (.Net)

Hi,

We are facing an issue with reading Arabic text which is available in the word content control?

Actual Text is reversing after reading.

Actual:

مؤسسة فيتش ، لندن، 12 فبراير 2018: ثبَّتت مؤسسة فيتش تصنيف الشركة السعودية للصناعات الأساسية (سابك) من حيث قدرة المُصدِر على الوفاء بالالتزامات طويلة الأجل وكذلك تصنيف ديونها ذات الأولية غير المدعومة بأصول عند ‘+A’، كما حددت تصنيفها من حيث قدرة المُصدِر على الوفاء بالالتزامات قصيرة الأجل بالتصنيف “F1”، مع نظرة مستقبلية مستقرة لتصنيف قدرة المُصدِر على الوفاء بالالتزامات طويلة الأجل. أما تصنيف الالتزامات ذات الأولية غير المدعومة بأصول لسندات سابك كابيتال المضمونة فقد تم تثبيته عند تصنيف ‘+A’. القائمة الكاملة بإجراءات التصنيف واردة

Result:

مؤسسة فيتش ، لندن، 12 فبراير 2018: ثبَّتت مؤسسة فيتش تصنيف الشركة السعودية للصناعات الأساسية (سابك) من حيث قدرة المُصدِر على الوفاء بالالتزامات طويلة الأجل وكذلك تصنيف ديونها ذات الأولية غير المدعومة بأصول عند ‘A+’، كما حددت تصنيفها من حيث قدرة المُصدِر على الوفاء بالالتزامات قصيرة الأجل بالتصنيف “F1”، مع نظرة مستقبلية مستقرة لتصنيف قدرة المُصدِر على الوفاء بالالتزامات طويلة الأجل. أما تصنيف الالتزامات ذات الأولية غير المدعومة بأصول لسندات سابك كابيتال المضمونة فقد تم تثبيته عند تصنيف ‘A+’. القائمة الكاملة بإجراءات التصنيف واردة

+A–> interchanged as “A+”

Kindly help on this.

Thanks and regards,
Srinivas Merugu

@280366,

Thanks for your inquiry. Please ZIP and attach your input Word document and code example to reproduce this issue at our end for testing. We will investigate the issue on our side and provide you more information.

Aspose Support.zip (18.8 KB)

Code used to read content control:

var docTags = GetStructuredDocumentTags(doc, qCodeTagTemp);
String sectionText = String.Empty;

if (docTags.Any())
{
    foreach (var docTag in docTags.Where(dt => !dt.IsShowingPlaceholderText))
    {
        var insideDocTags = IsNestedStructuredDocumentTagsExists(docTag);  //Check inside doc Tags

        if (insideDocTags)
        {
            //Throw error message                                   
            throw new IOException("Content controls exist inside other content controls. Inside content control found in '" + docTag.Title + "'");
        }

        var tagText = docTag.ToString(SaveFormat.Text);
        sectionText = tagText + Environment.NewLine;
        if (sectionText.Any())
        {
            sectionText = sectionText.Trim();
            sectionText = sectionText.RemoveNonPrintableCharacters();
        }

        documentDataEx.Add(new DocumentDataEx(docTag.Title, qCodeTag, sectionText));
    }
}

Thanks and regards,
Srinivas Merugu

@280366,

Thanks for sharing the detail. You are converting content control into text file format and add the text into document. In your case, we suggest you please export the content control to text format with UTF8 encoding as shown below. Hope this helps you.

Document doc = new Document(MyDir + "Test_Arabic_Text.docx");
var docTags = doc.GetChildNodes(NodeType.StructuredDocumentTag, true);

TxtSaveOptions options = new TxtSaveOptions();
options.Encoding = Encoding.UTF8;
                    
String sectionText = docTags[0].ToString(options);

Hi,
Thanks for your reply. Your code is not working completely. Still having the issue with text of output. English letters are not getting properly and +A also interchanged and F1 also not getting properly.

Input:

مؤسسة فيتش ، لندن، 12 فبراير 2018: ثبَّتت مؤسسة فيتش تصنيف الشركة السعودية للصناعات الأساسية (سابك) من حيث قدرة المُصدِر على الوفاء بالالتزامات طويلة الأجل وكذلك تصنيف ديونها ذات الأولية غير المدعومة بأصول عند ‘+A’، كما حددت تصنيفها من حيث قدرة المُصدِر على الوفاء بالالتزامات قصيرة الأجل بالتصنيف “F1”، مع نظرة مستقبلية مستقرة لتصنيف قدرة المُصدِر على الوفاء بالالتزامات طويلة الأجل. أما تصنيف الالتزامات ذات الأولية غير المدعومة بأصول لسندات سابك كابيتال المضمونة فقد تم تثبيته عند تصنيف ‘+A’. القائمة الكاملة بإجراءات التصنيف واردة في نهاية هذا البيان.

Output:
‏مؤسسة فيتش‏ ‏، لندن، 12‏ فبراير 2018‏: ‏ثبَّتت‏ مؤسسة فيتش تصنيف الشركة السعودية للصناعات الأساسية (سابك) من حيث قدرة المُصدِر على الوفاء بالالتزامات طويلة الأجل وكذلك تصنيف ديونها ‏ذات الأولية‏ غير المدعومة بأص‏و‏ل عند ‘A+’، كما حددت تصنيفها من حيث قدرة المُصدِر على الوفاء بالالتزامات قصيرة الأجل بالتصنيف “F 1‏”، مع ‏نظرة المدعومة بأص‏و‏ل لسندات سابك كابيتال المضمونة فقد تم ‏تثبيته‏ ‏عند تصنيف ‘A+’. ‏ال‏قائمة ‏ال‏كاملة بإجراءات التصنيف ‏واردة ‏في نهاية هذا البيان.

Note: I am not able to paste Arabic letters in this Editor. It is also formattting while I pasting.
I will upload Images in the comments.

Arabic_Text_OutPut.zip (31.8 KB)

Uploaded input and output as images for your reference.

Thanks and regards,
Srinivas Merugu

@280366,

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-16814. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-16814) have been fixed in this Aspose.Words for .NET 18.6 update and this Aspose.Words for Java 18.6 update.

@280366,

It is to update you that we have implemented TxtSaveOptions.AddBidiMarks property as per WORDSNET-16814.

When this option is enabled, Aspose.Words inserts Unicode Character ‘RIGHT-TO-LEFT MARK’ (U+200F) before each bi-directional Run in text. This option corresponds to “Add bi-directional marks” option in Word File Conversion dialog when you export to a Plain Text format. Note, it appears in dialog only if any of Arabic or Hebrew editing languages are added in MS Word.

In addition, unlike MS Word where this option is set to false by default, in Aspose.Words this option is set by default to true.

Use case: Export to TXT format, no addition of RTL marks before each BiDi Run:

Document doc = new Document("in.docx");
 
TxtSaveOptions saveOptions = new TxtSaveOptions();
saveOptions.AddBidiMarks = false;
 
doc.Save("out.txt", saveOptions);