Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Jun 07, 2017 6:52 am

Hi team, we are testing your Spire.Doc software and face with an issue when trying to replace part of text, for example #:some_text:# to arabic word.

The issue is that arabic word is change to another, which is not equal to original word and we are don't understand why is that happen.

We are using following method: document.Replace(token, textToReplace, true, true);

Please can you clarify why is that happen?

You can test it if for example print some word into google translate, then send it into replace method and then in output doc copy the printed text and paste into translate again.

Also it's ignore font style and using some default style fon, can we set somewhere to ignore font changing, which will offer to us use the font, which we are set initially in document?

testfreespire
 
Posts: 9
Joined: Mon Feb 13, 2017 8:28 am

Wed Jun 07, 2017 7:24 am

Recently just found that for each arabic word he change symbols order, which is strange. Can we avoid this?
Mean they set last symbol as first, pre last as second, etc.
قرد change to درق

testfreespire
 
Posts: 9
Joined: Mon Feb 13, 2017 8:28 am

Wed Jun 07, 2017 8:54 am

Hello,

Thanks for your inquiry.
Unlike the left-to-right characters, Arabic is the chracter of right-to-left writing direction. If you reaplace the text in word document without declaring the specific text direction, it will apply the left-to-right text direction by default, thus the issue occurs. To solve this, please use the following code to have a try.
Code: Select all
doc.Replace("AI", "الذكاء الاصطناعي", true, true);
           //change the text direction for the specific Arabic words
            TextRange tr = doc.FindString("الذكاء الاصطناعي",true,true).GetAsOneRange();
            CharacterFormat format = new CharacterFormat(doc);
            format.Bidi = true;
            tr.ApplyCharacterFormat(format);
            doc.SaveToFile("replace.docx",FileFormat.Docx2013);

If there's still any issue, please feel free to contact us.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Fri Jun 09, 2017 7:00 am

Hello,

Has your issue got resolved? Could you please give us some feedback at your convenience?

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.Doc